Shih-Ho Hsieh / Mbed 2 deprecated pololu5mag_with_platform

Dependencies:   mbed

Fork of Motor_XYZ_UI_SPI_I2C_5mag by Shih-Ho Hsieh

Revision:
4:5cde69a36d74
Child:
7:ee0569d49c52
diff -r 9ffe7ef07124 -r 5cde69a36d74 parse_array/ParseArray.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/parse_array/ParseArray.h	Wed Nov 08 07:49:05 2017 +0000
@@ -0,0 +1,83 @@
+#ifndef ParseArray_h
+#define ParseArray_h
+
+
+#include <string>
+using namespace std;
+typedef unsigned char byte;
+class ParseArray
+{
+
+public :
+    //header
+    bool hasHeader;
+    int headerIndex;
+    int headerLength;
+    byte* headerValue;
+    string headerValueTmp;
+    // current header index
+    int currentHeaderIndex;
+    // Footer
+    bool hasFooter;
+    int footerIndex;
+    int footerLength;
+    byte* footerValue;
+    string footerValueTmp;
+    // current footer index
+    int currentFooterIndex;
+    // check
+    // CRC
+    bool hasCRC;
+    int checkCRCIndex;
+    int checkCRCLength;
+    // check xorValue
+    bool hasCheckXOR;
+    int  checkXORIndex;
+    // length
+    bool lengthFix;
+    int length;
+
+    // index
+    int currentIndex;
+
+    // array
+    byte* bufferArray;
+    int bufferLength;
+    byte* dataArray;
+
+    // constructor
+    ParseArray();
+    // string to byte function
+    byte* stringToByte(string hex, int length);
+    // buffer setting
+    void setBufferValue(byte* buf, int lengthTmp, int checkSumStart);
+    void setBufferValueAdjustFooterIndex(byte* buf, int buflength, int checkSumStart);
+    void setBufferValue(byte* buf,int lengthTmp);
+
+    // header
+    void enableHeader(int headerindex, int headerlength, string headervalue);
+    // footer
+    void enableFooter(int footerindex, int footerlength, string footervalue);
+    // crc
+    void enableCRC(int crcindex, int crclength);
+    // xorValue
+    void enableCheckXOR(int xorindex);
+
+    // check Header
+    bool testHeader(int hindex) ;
+    // check Footer
+    bool testFooter(int findex);
+    // test XOR // set xindex as headerIndex
+    bool testXOR();
+    // parsing
+    bool parse(int curIndex);
+    // compute xor
+    byte computeXOR(byte t1[], int len);
+
+
+};
+
+
+
+#endif
+