UI--checksum checking functions. Updated to set UI to previous UI on error.

Fork of UI by Bradley Perry

Files at this revision

API Documentation at this revision

Comitter:
mzling
Date:
Mon May 11 21:48:03 2015 +0000
Parent:
5:f8d7d4505bad
Commit message:
Comments

Changed in this revision

UserInterface.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f8d7d4505bad -r e9e132f21f1b UserInterface.cpp
--- a/UserInterface.cpp	Thu Feb 26 18:28:33 2015 +0000
+++ b/UserInterface.cpp	Mon May 11 21:48:03 2015 +0000
@@ -116,12 +116,20 @@
     return true;
 }
 
+
+/**
+* This function pulls a crutch message from the XBee, and changes UI if the message is valid
+* @author Michael Ling
+* @date 5/11/2015
+*/
 void UserInterface::checkUI_XBee()
 {
     //int sum = 0;
     _buttonA_prev = _buttonA;
     _buttonB_prev = _buttonB;
+    //Find the start of a message in the xbee buffer
     char * idx = strchr(_xbeeBuffer,0x7e);
+    
     if (idx != NULL) {
         
         int size[3];
@@ -129,8 +137,9 @@
         printf("Size: %d, Datacount: %d\r\n", size[1], _dataCnt);
         _buttonA = (_xbeeBuffer[idx-_xbeeBuffer+21]>>1) & 1;  // on DIO1
         _buttonB = (_xbeeBuffer[idx-_xbeeBuffer+21]>>2) & 1;  // on DIO2
+        //Proceed if the amount of data matches up with the calculated message length
         if(_dataCnt >= size[1]) {
-
+            //Compare calculated and actual checksums
             if (checksum_check(idx+size[2], size[0])) {
                 printf("Checksums match\r\n");
             } else {