UDP ROS Communication program

Branch:
test
Revision:
4:4b38a500167b
Parent:
2:ad02959c2003
Child:
5:2b2cf11243b1
diff -r 9a1e9d376a73 -r 4b38a500167b main.cpp
--- a/main.cpp	Tue Mar 02 02:06:57 2021 +0900
+++ b/main.cpp	Tue Mar 02 02:15:24 2021 +0900
@@ -1,19 +1,26 @@
 #include "EthernetInterface.h"
 #include "mbed.h"
+
 //イーサネット関連
 const char *myIP = "192.168.0.13";
 const char *mask = "255.255.255.0";
 const char *pcIP = "192.168.0.10";
 const int myPORT = 8080, pcPORT = 8080;
-const int PORT = 8080;
 EthernetInterface eth;
 UDPSocket socket;
-SocketAddress sockAddr;
 SocketAddress myAddr(myIP, myPORT);
 SocketAddress pcAddr(pcIP, pcPORT);
 #define MAX_LEN 1208
 char txdata[MAX_LEN];
+char rxdata[MAX_LEN];
+
+void initialize_txdata() { // 0123...'A''B''C'...
+  for (int i = 0; i < MAX_LEN; i++)
+    txdata[i] = i % 0x100;
+}
+
 int network_init() {
+  initialize_txdata();
   // network ip set
   eth.set_network(myIP, mask, "");
   // connection test (return 0 @status is OK)
@@ -21,7 +28,6 @@
     printf("eth connetction error\n");
     return -1;
   }
-
   socket.open(&eth);
   return true;
 }