|
@@ -31,6 +31,7 @@
|
31
|
31
|
#include <netinet/in.h>
|
32
|
32
|
#include <arpa/inet.h>
|
33
|
33
|
int sock = 0;
|
|
34
|
+const char* host = "127.0.0.1";
|
34
|
35
|
#define PORT 6699
|
35
|
36
|
#endif
|
36
|
37
|
|
|
@@ -88,14 +89,14 @@ int ComRobot::Open(string usart) {
|
88
|
89
|
}
|
89
|
90
|
struct timeval tv;
|
90
|
91
|
tv.tv_sec = 0;
|
91
|
|
- tv.tv_usec = 80000;
|
|
92
|
+ tv.tv_usec = 200000;
|
92
|
93
|
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*) &tv, sizeof tv);
|
93
|
94
|
|
94
|
95
|
serv_addr.sin_family = AF_INET;
|
95
|
96
|
serv_addr.sin_port = htons(PORT);
|
96
|
97
|
|
97
|
98
|
// Convert IPv4 and IPv6 addresses from text to binary form
|
98
|
|
- if (inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr) <= 0) {
|
|
99
|
+ if (inet_pton(AF_INET, host, &serv_addr.sin_addr) <= 0) {
|
99
|
100
|
printf("\nInvalid address/ Address not supported \n");
|
100
|
101
|
return -1;
|
101
|
102
|
}
|
|
@@ -156,6 +157,7 @@ Message *ComRobot::Write(Message* msg) {
|
156
|
157
|
|
157
|
158
|
s = MessageToString(msg);
|
158
|
159
|
#ifdef __SIMULATION__
|
|
160
|
+ s += "\r";
|
159
|
161
|
|
160
|
162
|
char buffer[1024] = {0};
|
161
|
163
|
cout << "[" << __PRETTY_FUNCTION__ << "] Send command: " << s << endl << flush;
|