Henk Meewis / Mbed 2 deprecated USB_serial_LED_controller

Dependencies:   mbed

Fork of frdm_echo by Henk Meewis

Revision:
8:b715912d684b
Parent:
7:19da09fe546b
Child:
9:f9efd3a69c2d
--- a/shell.cpp	Mon Apr 14 03:04:28 2014 +0000
+++ b/shell.cpp	Mon Apr 14 16:41:57 2014 +0000
@@ -9,6 +9,8 @@
 {
     usbSerial = new Serial(USBTX, USBRX);
     usbSerial->baud(115200);
+    characterCount = 0;
+    characterPointer = 0;
 }
 //-----------------------------------------------------------------------------
 
@@ -38,15 +40,31 @@
         // if so, give a new line cursor
         if((character == ';') || (character == 13)) {
             usbSerial->printf("\n> ");
+            finishCharacterBuffer();
             ledColors->flashWhite(10);
         }
         
         // if not, just print the character
         else {
-            usbSerial->printf("%c", character);        
+            usbSerial->printf("%c", character); 
+            addCharacterToBuffer(character);       
             ledColors->flashGreen(10);
         }
     }
 }
 //-----------------------------------------------------------------------------
-   
\ No newline at end of file
+   
+void Shell::addCharacterToBuffer(char newCharacter)
+{
+    if(characterPointer < ItsInputBufferSize_) {
+        inputBuffer[characterPointer++] = newCharacter;
+        characterCount = characterPointer;
+    }
+}
+//-----------------------------------------------------------------------------
+
+void Shell::finishCharacterBuffer()
+{
+    characterPointer = 0;
+}
+//-----------------------------------------------------------------------------
\ No newline at end of file