-
Notifications
You must be signed in to change notification settings - Fork 2
/
rx_status_test.c
60 lines (47 loc) · 1.37 KB
/
rx_status_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
#include <utime.h>
#include <unistd.h>
#include <getopt.h>
#include <pcap.h>
#include <endian.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "lib.h"
wifibroadcast_rx_status_t *status_memory_open(void) {
int fd = shm_open("/wifibroadcast_rx_status_0", O_RDWR, S_IRUSR | S_IWUSR);
if(fd < 0) {
perror("shm_open");
exit(1);
}
if (ftruncate(fd, sizeof(wifibroadcast_rx_status_t)) == -1) {
perror("ftruncate");
exit(1);
}
void *retval = mmap(NULL, sizeof(wifibroadcast_rx_status_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (retval == MAP_FAILED) {
perror("mmap");
exit(1);
}
return (wifibroadcast_rx_status_t*)retval;
}
int main(void) {
wifibroadcast_rx_status_t *t = status_memory_open();
for(;;) {
printf("\033[2J\r");
printf("Card 0\n------\n");
printf("Signal:\t\t\t%ddBm\n", t->adapter[0].current_signal_dbm);
printf("Received Pkg:\t\t%d\n", t->adapter[0].received_packet_cnt);
printf("Wrong CRC ad0:\t\t%d\n", t->adapter[0].wrong_crc_cnt);
printf("\nWifibroadcast\n-------------\n");
printf("Wifi cards:\t\t%d\n", t->wifi_adapter_cnt);
printf("Received Blocks:\t\t%d\n", t->received_block_cnt);
printf("Damaged Blocks:\t\t%d\n", t->damaged_block_cnt);
printf("TX restarts:\t\t%dn", t->tx_restart_cnt);
usleep(1e5);
}
return 0;
}