UART Driver to receive asynchronous Serial Comms from a Raspberry Pi and parse the results.

Revision:
7:34c5934a01f0
Parent:
6:74b5ac7719f4
Child:
8:2cbaea485ddb
--- a/SerialComms.cpp	Fri Mar 04 05:53:11 2016 +0000
+++ b/SerialComms.cpp	Fri Mar 04 06:43:50 2016 +0000
@@ -36,6 +36,13 @@
     incomingDataUpdate = FALSE;
 }
 
+#define MOTORS_FORWARD      0x09
+#define MOTORS_BACKWARD     0x06
+#define MOTORS_LEFT         0x05      
+#define MOTORS_RIGHT        0x0A
+#define MOTORS_ARM          0x01
+
+
 
 void SerialComms::incomingDataISR()
 {
@@ -47,8 +54,16 @@
 {
     if(incomingDataUpdate == TRUE)
     {
-        incomingDataUpdate = FALSE;
-        return receiverBuffer;
+        if( (receiverBuffer>&0x0F)==MOTORS_FORWARD ||
+            (receiverBuffer>&0x0F)==MOTORS_BACKWARD ||
+            (receiverBuffer>&0x0F)==MOTORS_LEFT ||
+            (receiverBuffer>&0x0F)==MOTORS_RIGHT ||
+            (receiverBuffer>&0x0F)==MOTORS_ARM 
+            /* AND BALLAST REQUIREMENTS */)
+        {
+            incomingDataUpdate = FALSE;
+            return receiverBuffer;
+        }
     }
     else
     {