Shih-Ho Hsieh / Mbed 2 deprecated pololu5mag_with_platform

Dependencies:   mbed

Fork of Motor_XYZ_UI_SPI_I2C_5mag by Shih-Ho Hsieh

Revision:
7:ee0569d49c52
Parent:
4:5cde69a36d74
--- a/parse_array/ParseArray.cpp	Fri Nov 10 02:39:32 2017 +0000
+++ b/parse_array/ParseArray.cpp	Fri Dec 08 06:30:58 2017 +0000
@@ -192,11 +192,11 @@
     return true;
 }
 // test xorValue
-bool ParseArray::testXOR()// set xindex as headerIndex
+bool ParseArray::testXOR(int hindex)// set xindex as headerIndex
 {
     int i = 0;
     byte xorValue = 0 ;
-    for (i = 0; i < length; i++) {
+    for (i = hindex; i < hindex+length; i++) {
         xorValue ^= bufferArray[i % bufferLength];
     }
     if (xorValue == 0)
@@ -237,8 +237,10 @@
     }
     // test xorValue
     if (hasCheckXOR) {
-        if (!testXOR())// fail check
+        if (!testXOR(curIndex)) { // fail check
+            printf("XOR fail");
             return false;
+        }
     }
     // pass all test
     currentHeaderIndex = curIndex;