Threads + Network Demo

Dependencies:   EthernetInterface mbed-rtos mbed-src

Fork of TestNetComm by Malcolm Nixon

Files at this revision

API Documentation at this revision

Comitter:
MalcolmNixon
Date:
Sat May 10 21:52:53 2014 +0000
Parent:
5:18415c556f04
Commit message:
Simple demo showing a crash in EthernetInterface::init

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r 18415c556f04 -r 97573a8dce83 main.cpp
--- a/main.cpp	Sun May 04 14:11:44 2014 +0000
+++ b/main.cpp	Sat May 10 21:52:53 2014 +0000
@@ -2,6 +2,8 @@
 #include "Thread.h"
 #include "mbed.h"
 
+Serial pc(USBTX, USBRX);
+
 void led2ThreadProc(const void *param)
 {
     // Toggle LED2
@@ -26,23 +28,37 @@
 
 int main(void)
 {
-    // Start LED toggle(s)
+    int nr;
+    
+    // Start LED2 toggle
+    pc.printf("Starting LED 2 thread\r\n");
     Thread led2(led2ThreadProc);
+    osDelay(1000);
+    
+    // Start LED3 toggle
+    pc.printf("Starting LED 3 thread\r\n");
     Thread led3(led3ThreadProc);
+    osDelay(1000);
 
-    // Start the network
-    EthernetInterface::init("192.168.5.100", "255.255.255.0", "0.0.0.0");
-    EthernetInterface::connect();
+    // Initialize the network
+    pc.printf("Initializing network\r\n");
+    nr = EthernetInterface::init("192.168.100.5", "255.255.255.0", "0.0.0.0");
+    pc.printf(" Network Init: %d\r\n", nr);
+    
+    // Connect to the network
+    pc.printf("Connecting to the network\r\n");
+    nr = EthernetInterface::connect();
+    pc.printf(" Connected: %d\r\n", nr);
 
     // Construct the server
     TCPSocketServer svr;
     svr.bind(1234);
     svr.listen();
 
-    TCPSocketConnection conn;
     for (;;)
     {
         // Accept the next connection
+        TCPSocketConnection conn;
         svr.accept(conn);
             
         // Manage the connection
diff -r 18415c556f04 -r 97573a8dce83 mbed-src.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Sat May 10 21:52:53 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-src/#e752b4ee7de1
diff -r 18415c556f04 -r 97573a8dce83 mbed.bld
--- a/mbed.bld	Sun May 04 14:11:44 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776
\ No newline at end of file