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

Revision:
11:b5f4a9e69d96
Parent:
10:55cb02b00338
--- a/SerialComms.cpp	Fri Mar 04 23:07:43 2016 +0000
+++ b/SerialComms.cpp	Sat Mar 05 01:07:37 2016 +0000
@@ -46,21 +46,28 @@
 {
     if(incomingDataUpdate == TRUE)
     {
-        if( (receiverBuffer&0x0F)==MOTORS_FORWARD ||
+        if( ((receiverBuffer&0x0F)==MOTORS_FORWARD ||
             (receiverBuffer&0x0F)==MOTORS_BACKWARD ||
             (receiverBuffer&0x0F)==MOTORS_LEFT ||
             (receiverBuffer&0x0F)==MOTORS_RIGHT ||
-            (receiverBuffer&0x0F)==MOTORS_ARM 
-            /* AND BALLAST REQUIREMENTS */)
+            (receiverBuffer&0x0F)==MOTORS_ARM ||
+            (receiverBuffer&0x0F)==MOTORS_OFF ||
+            (receiverBuffer>>4)&(0x0F)==MAGNET_ON ||
+            (receiverBuffer>>4)&(0x0F)==MAGNET_OFF
+            /* AND BALLAST REQUIREMENTS */              ) )
         {
             incomingDataUpdate = FALSE;
             return receiverBuffer;
         }
-    }
+        else
+        {
+            incomingDataUpdate = FALSE;
+            return 0xFF;
+        } 
+    }  
     else
     {
         incomingDataUpdate = FALSE;
         return 0xFF;
-    }
-    return;
+    }       
 }