testmg

Dependencies:   USBHost mbed

Fork of USBHostSerial_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Tue Mar 12 17:33:20 2013 +0000
Parent:
0:7528379ed84d
Child:
2:8f3478b5d434
Commit message:
use latest USBHost

Changed in this revision

USBHost.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/USBHost.lib	Wed Mar 06 17:07:28 2013 +0000
+++ b/USBHost.lib	Tue Mar 12 17:33:20 2013 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/USBHost/#a554658735bf
+https://mbed.org/users/mbed_official/code/USBHost/#b320d68e98e7
--- a/main.cpp	Wed Mar 06 17:07:28 2013 +0000
+++ b/main.cpp	Tue Mar 12 17:33:20 2013 +0000
@@ -5,34 +5,27 @@
 Serial pc(USBTX, USBRX);
 
 void serial_task(void const*) {
-    char buf[100];
     USBHostSerial serial;
     
     while(1) {
-    
-        // try to connect a virtual serial port
         while(!serial.connect())
             Thread::wait(500);
-    
-        while(1) {
         
-            // if serial not connected, try to connect again
+        while (1) {
             if (!serial.connected())
                 break;
-                
-            // if char available on the virtual serial port, print them
-            if (serial.available()) {
-                serial.scanf("%s", buf);
-                printf("recv: %s\r\n", buf);
+
+            while (serial.available()) {
+                printf("%c", serial.getc());
             }
             
+            Thread::wait(50);
         }
-        
     }
 }
 
 int main() {
-    Thread serialTask(serial_task, NULL, osPriorityNormal, 1024 * 4);
+    Thread serialTask(serial_task, NULL, osPriorityNormal, 256 * 4);
     while(1) {
         led=!led;
         Thread::wait(500);