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

Files at this revision

API Documentation at this revision

Comitter:
sk398
Date:
Sat Mar 05 01:07:37 2016 +0000
Parent:
10:55cb02b00338
Commit message:
Most up to date

Changed in this revision

SerialComms.cpp Show annotated file Show diff for this revision Revisions of this file
SerialComms.h Show annotated file Show diff for this revision Revisions of this file
--- 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;
+    }       
 }
--- a/SerialComms.h	Fri Mar 04 23:07:43 2016 +0000
+++ b/SerialComms.h	Sat Mar 05 01:07:37 2016 +0000
@@ -35,6 +35,7 @@
 #define MOTORS_LEFT         0x05      
 #define MOTORS_RIGHT        0x0A
 #define MOTORS_ARM          0x01
+#define MOTORS_OFF          0x00
 
 #define MAGNET_ON           0x0D
 #define MAGNET_OFF          0x0E