Playing with the UDPEchoClient to prototype delivery of data over UDP.

Dependencies:   EthernetInterface FXOS8700CQ mbed-rtos mbed

Fork of UDPEchoClient by mbed official

Files at this revision

API Documentation at this revision

Comitter:
trm
Date:
Tue Jun 03 19:21:31 2014 +0000
Parent:
7:9d51be7aab27
Commit message:
Initial commit of example of the FXOS8700CQ that causes the EthernetInterface to stall during initialization. Comment out line 9 to make the UDP echo function.

Changed in this revision

FXOS8700CQ.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 9d51be7aab27 -r c9e4f2e15e2d FXOS8700CQ.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXOS8700CQ.lib	Tue Jun 03 19:21:31 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/trm/code/FXOS8700CQ/#e2fe752b881e
diff -r 9d51be7aab27 -r c9e4f2e15e2d main.cpp
--- a/main.cpp	Wed May 14 15:33:15 2014 +0000
+++ b/main.cpp	Tue Jun 03 19:21:31 2014 +0000
@@ -1,31 +1,55 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+#include "FXOS8700CQ.h"
 
-const char* ECHO_SERVER_ADDRESS = "10.2.200.94";
-const int ECHO_SERVER_PORT = 7;
+const char* ECHO_SERVER_ADDRESS = "10.0.0.73";
+const int ECHO_SERVER_PORT = 7001; // changed from example code
+
+// TODO: figure out why this line breaks the code:
+FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); // SDA, SCL, (addr << 1)
+
+RawSerial pc(USBTX, USBRX);
+
+Timer t; // Microsecond timer, 32 bit int, maximum count of ~30 minutes
 
-int main() {
+int main()
+{
+    pc.baud(115200);
+    
+    printf("Starting setup.\n");
+
     EthernetInterface eth;
-    eth.init(); //Use DHCP
+    eth.init(); // Use DHCP
     eth.connect();
-    
+    printf("IP Address is %s\n", eth.getIPAddress());
+
     UDPSocket sock;
     sock.init();
-    
+
     Endpoint echo_server;
     echo_server.set_address(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
-    
-    char out_buffer[] = "Hello World\n";
-    sock.sendTo(echo_server, out_buffer, sizeof(out_buffer));
-    
+
+    char out_buffer[] = "Hello World";
     char in_buffer[256];
-    int n = sock.receiveFrom(echo_server, in_buffer, sizeof(in_buffer));
-    
-    in_buffer[n] = '\0';
-    printf("%s\n", in_buffer);
+
+    t.reset();
+    t.start();
+
+    for(int i = 0; i < 20; ++i) {
+        sock.sendTo(echo_server, out_buffer, sizeof(out_buffer));
+
+        int n = sock.receiveFrom(echo_server, in_buffer, sizeof(in_buffer));
+
+        in_buffer[n] = '\0';
+        printf("%d, %d: %s\n", t.read_us(), i, in_buffer);
+        
+        t.reset();
+    }
     
     sock.close();
+    eth.disconnect();
     
-    eth.disconnect();
+    printf("Disconnected and closed.");
+    
     while(1) {}
 }
\ No newline at end of file
diff -r 9d51be7aab27 -r c9e4f2e15e2d mbed-rtos.lib
--- a/mbed-rtos.lib	Wed May 14 15:33:15 2014 +0000
+++ b/mbed-rtos.lib	Tue Jun 03 19:21:31 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#5dfe422a963d
+http://mbed.org/users/mbed_official/code/mbed-rtos/#015df9e602b6
diff -r 9d51be7aab27 -r c9e4f2e15e2d mbed.bld
--- a/mbed.bld	Wed May 14 15:33:15 2014 +0000
+++ b/mbed.bld	Tue Jun 03 19:21:31 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file