Sample of how to use multi uart interupt driven serial command processor.

Dependencies:   mbed multi-serial-command-listener

This is example code for how to use the multi-serial-command-listener library. See https://developer.mbed.org/users/joeata2wh/code/multi-serial-command-listener/wiki/Homepage for details about the library.

This was tested on a NUCLEO-F401RE board.

Files at this revision

API Documentation at this revision

Comitter:
joeata2wh
Date:
Thu Mar 31 22:16:33 2016 +0000
Parent:
1:89bd9b1fe280
Commit message:
update for minor API changes

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
multi-serial-command-listener.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Mar 31 21:06:11 2016 +0000
+++ b/main.cpp	Thu Mar 31 22:16:33 2016 +0000
@@ -19,12 +19,15 @@
 Serial pc(USBTX, USBRX);
 char myCommand[SCMD_MAX_CMD_LEN+1];
 
-void commandCallback(char *cmdIn) {
+void commandCallback(char *cmdIn, void *extraContext) {
   strcpy(myCommand, cmdIn);
   // all our commands will be recieved async in commandCallback
   // we don't want to do time consuming things since it could
   // block the reader and allow the uart to overflow so we simply 
   // copy it out in the callback and then process it latter. 
+  
+  // See data_log one of dependants of this library for example 
+  // of using *extraContext
 }
 
 int main() {
@@ -33,7 +36,7 @@
     
     // Instantiate our command processor for the 
     // USB serial line. 
-    struct SCMD *cmdProc = scMake(&pc, commandCallback)  ;
+    struct SCMD *cmdProc = scMake(&pc, commandCallback, NULL)  ;
     
     while(1) {        
         if (myCommand[0] != 0) {     
--- a/multi-serial-command-listener.lib	Thu Mar 31 21:06:11 2016 +0000
+++ b/multi-serial-command-listener.lib	Thu Mar 31 22:16:33 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/joeata2wh/code/multi-serial-command-listener/#d06fb5798df1
+http://mbed.org/users/joeata2wh/code/multi-serial-command-listener/#b0212513533c