USBSerial echo example

Dependencies:   mbed USBDevice

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Thu Nov 17 12:01:32 2011 +0000
Parent:
3:64ff9e0a52bd
Child:
5:fa2fa6aa36b1
Commit message:

Changed in this revision

USBDevice.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
--- a/USBDevice.lib	Tue Nov 15 21:13:03 2011 +0000
+++ b/USBDevice.lib	Thu Nov 17 12:01:32 2011 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/samux/code/USBDevice/#f9400a831815
+http://mbed.org/users/samux/code/USBDevice/#76071370dd0a
--- a/main.cpp	Tue Nov 15 21:13:03 2011 +0000
+++ b/main.cpp	Thu Nov 17 12:01:32 2011 +0000
@@ -6,11 +6,17 @@
 Serial pc(USBTX, USBRX);
 
 int main(void) {
-    uint8_t buf[128];
+    char buf[128];
+    char echo[128];
     while(1)
     {
         serial.scanf("%s", buf);
-        serial.printf("recv: %s\r\n", buf);
-        pc.printf("recv: %s\r\n", buf);
+        
+        // build the echo response
+        sprintf(echo, "recv: %s\r\n", buf);
+        
+        //send to the virtual serial port and the mbed serial port
+        serial.print(echo);
+        pc.printf("%s", echo);
     }
 }