Reveive the full data from the application board

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dannellyz
Date:
Sun Apr 19 19:37:35 2015 +0000
Commit message:
Code to receive the full appborad data

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
diff -r 000000000000 -r 89906fbcaff9 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Apr 19 19:37:35 2015 +0000
@@ -0,0 +1,33 @@
+// Example of parsing the serial string from the fullAppBaordSend
+/* Code derived from the work of Joe Bradshaw: 
+                                            http://developer.mbed.org/users/jebradshaw/ */
+/******************Declaration of necessary libraries and objects************************/  
+#include "mbed.h"
+DigitalOut myled(LED1);     //LED to show functionality
+Serial pc(USBTX, USBRX);    //tx, rx via USB connection
+Serial xbee(p9, p10);       //tx, rx via Xbee socket
+int main() {
+/******************Establishment of Vaiables*********************************************/
+    char abstr[25];     //used to store the whole app board string
+    int joystick;       //int value corresponding to the joystick bus
+    float Lpot;         //float corresponding to left potentiometer
+    float Rpot;         //float corresponding to right potentiometer
+/******************While loop call to run code indefinitely******************************/
+    while(1) {       
+        //clear out the remaining characters in the buffer     
+        while(xbee.readable())      
+            char c = xbee.getc();  
+        //read the serial string from the xbee (starts with '$', ends with \r\n            
+        xbee.scanf("$%s\r\n", &abstr);    
+        //Verify that the string has the APPBOARD header
+        if(strncmp(abstr, "APPBOARD", 9)){
+            //Verify the tring was able to be parsed
+            if (sscanf(abstr, "APPBOARD,%f,%f,%d",&Lpot,&Rpot,&joystick) >= 1) {
+                //Print values to screen
+                pc.printf("Mbed: L-%.02f: R-%.02f Joystick:%d\r\n",Lpot,Rpot,joystick);}
+            //Incorrect parse
+            else{pc.printf("BAD parse %s\r\n", abstr);}
+            }//if(sscanf 
+        myled = !myled; //toggle LED for activity verification   
+    }//while(1)
+}//main
diff -r 000000000000 -r 89906fbcaff9 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Apr 19 19:37:35 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file