just to test TO BE DELETED

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
eboily1
Date:
Thu Dec 06 21:04:26 2018 +0000
Commit message:
temp for test

Changed in this revision

main.cpp 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 06 21:04:26 2018 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+
+RawSerial pc(D1, D0, 115200);
+#define OK  0
+#define TOO_LONG 1
+#define TIMEOUT  2
+
+int readLine(RawSerial serialport, char * bufferin, int maxlenght, int Timeout)
+{
+    Timer timer;
+    timer.start();
+    int bytesReaded = 0;
+    
+    while (timer.read_ms() < Timeout) 
+    {
+        if (serialport.readable()) 
+        {
+            bufferin[bytesReaded] = serialport.getc();
+            if (bufferin[bytesReaded] == '\n')
+            {
+                if (bytesReaded < maxlenght-1)
+                    bufferin[bytesReaded++] = 0;
+                return OK;              
+            }
+            bytesReaded++;
+            if (bytesReaded >= maxlenght)
+                return TOO_LONG;       
+        }
+    }
+    return TIMEOUT;
+}
+
+
+int main() 
+{
+    char buffer[128];
+    pc.printf("start\r");
+    while(true)
+    {
+        if(pc.readable()) 
+        {
+            readLine(pc, buffer, 128, 600);
+            //pc.scanf("%s", buffer);
+            pc.printf(buffer);
+        }
+    }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 06 21:04:26 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b
\ No newline at end of file