-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
60 lines (45 loc) · 1.04 KB
/
main.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 "util/util.h"
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <poll.h>
struct pollfd fds[1];
int timeout;
int main() {
//Determine which /dev/ file is the device on
char* name = "A";
char* portname = "/dev/ttyUSB1";
int fd = 0;
int wlen = 0;
int BAUD_RATE = B19200;
Radio* radA = init_Radio(name);
setup_interface(radA, &fd, portname, BAUD_RATE);
printf("Name: %s\n",radA->ID);
radA->setDestination(radA,"B");
printf("Destination: %s\n",radA->destAddr);
/* Todo: Poll init function */
fds[0].fd = fd;
fds[0].events = 0;
fds[0].events |= POLLIN;
timeout = 1000;
int pret;
int bytes;
Packet data;
/* Handshake */
if(radA->init_connection(radA) < 0) {
printf("Error establishing connection to node: %s\n",radA->destAddr);
exit(1);
}
/* Repeatedly request temperature from Node B */
while(1) {
while(radA->getTemp(radA) < 0);
sleep(1);
}
return 0;
//radA->sendCmd("CMD");
//radA->getTemp();
//radA->close_connection();
}