-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBase.c
92 lines (57 loc) · 1.61 KB
/
Base.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "Exception/Exception.h"
#include "TCP/TCP.h"
#include "GPSDevice/GPSDevice.h"
#include "ComPort/ComPort.h"
#include "PacketLogger/PacketLogger.h"
#include "RTKBase.h"
const char* com_path = "/dev/ttyACM0";
const char* ip = "192.168.0.68";
const uint16_t port = 3000;
int main() {
Exception e = { 0 };
ComPort com;
TCPServer server;
TCPConnection correction_out;
PacketLogger logger;
ECEF ecef;
GPSPacket packet;
GPSDevice base;
char out[40];
// =======================
#ifdef _WIN32
sprintf_s(out, 40, "%s:%i", ip, port);
#elif __linux__
sprintf(out, "%s:%i", ip, port);
#endif
ComPort_create(&e, &com, com_path);
_EXCEPTION_PROMPT(e);
TCPServer_create(&e, &server, ip, port);
_EXCEPTION_PROMPT(e);
PacketLogger_create(&e, &logger, NULL);
_EXCEPTION_PROMPT(e);
GPSDevice_create(&e, &base);
_EXCEPTION_PROMPT(e);
ComPort_serial_transceiver(&com, &base.transceiver);
printf("Performing survey-in... \n");
RTKBase_survey_in(&e, &base, 60000, &ecef);
_EXCEPTION_PROMPT(e);
printf("Survey-in finished... \n");
TCPServer_start(&e, &server);
_EXCEPTION_PROMPT(e);
printf("Waiting for connection...\n");
TCPServer_wait_for_connection(&e, &server, &correction_out);
_EXCEPTION_PROMPT(e);
printf("Connection established...\n");
while (1) {
GPSDevice_read_packet(&e, &base, &packet);
_EXCEPTION_PROMPT(e);
PacketLogger_log(&e, &logger, &packet, "COM8", out);
_EXCEPTION_PROMPT(e);
if (packet.type == RTCM) {
TCPConnection_tx(&e, &correction_out, packet.buffer.data, packet.buffer.size);
_EXCEPTION_PROMPT(e);
}
free(packet.buffer.data);
}
return 0;
}