Dependencies:   EthernetInterface mbed-rtos mbed-src

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Fri Jan 17 03:21:00 2014 +0000
Commit message:
bug fix: Arch Pro hangs up when calling semihost function

Changed in this revision

EthernetInterface.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-src.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 61973ed15ae1 EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Fri Jan 17 03:21:00 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
diff -r 000000000000 -r 61973ed15ae1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 17 03:21:00 2014 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+
+
+Serial uart(USBTX, USBRX);
+DigitalOut led(LED4);
+
+void led_thread(void const *args)
+{
+    while (true) {
+        led = !led;
+        Thread::wait(1000);
+    }
+}
+
+int main() {
+    Thread thread(led_thread);
+    
+    uart.baud(115200);
+    uart.printf("------------ Ethernet ------------\n");
+   
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    
+    TCPSocketConnection sock;
+    sock.connect("mbed.org", 80);
+    
+    char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+    sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    
+    char buffer[300];
+    int ret;
+    while (true) {
+        ret = sock.receive(buffer, sizeof(buffer)-1);
+        if (ret <= 0)
+            break;
+        buffer[ret] = '\0';
+        printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }
+      
+    sock.close();
+    
+    eth.disconnect();
+    
+    while(1) {}
+}
diff -r 000000000000 -r 61973ed15ae1 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri Jan 17 03:21:00 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#29007aef10a4
diff -r 000000000000 -r 61973ed15ae1 mbed-src.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Fri Jan 17 03:21:00 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/yihui/code/mbed-src/#af844aac7b8c