Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Motor_XYZ_UI_SPI_I2C_5mag by
Diff: parse_array/ParseArray.h
- Revision:
- 4:5cde69a36d74
- Child:
- 7:ee0569d49c52
--- /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 +