FA 80 31 30 30 30 34 05 00 01 30 81 FC
FA 80 31 30 30 30 34 05 00 01 31 80 FC
FA 80 31 30 30 30 34 05 00 32 83 FC 01
FA 80 31 30 30 30 34 05 00 33 82 FC 01
FA 80 31 30 30 30 34 05 00 01 85 FC
CodePudding user response:
Is the custom communication protocol? Or general agreement? A serial port communication is more CRC16 and accumulative and validationCodePudding user response:
Should be to CRC, but backward agreement difficulty is a little big ~ ~ ~ ~CodePudding user response:
Don't know what kind of communication protocol, there are many kinds of CRC protocol? If you have a lot, please use gm help me explain, CRC16 concrete is how to calculate out ah, thank you very much!CodePudding user response:
Give you a sticker used CRC16 algorithm example see///////////////////////////////////////////////////////////
//16 bit CRC: according to the calculation, the slowest, taking up space at least
//note: the data flow is high first
///////////////////////////////////////////////////////////
The function CalCRC16 (data, CRC, genpoly: Word) : Word;
Var I: Integer;
The begin
//method 1: from XMODEM protocol
CRC:=CRC xor data;//(data SHL 8);
For I:=0 to 7 do
If (CRC and $0001) & lt;> 0 then//tests only highest
The CRC: (1) CRC SHR xor genpoly=1//that high displacement and exclusive or processing
Else CRC: CRC SHR=1;//otherwise only shift (passenger 2)
Result:=CRC;
{
//method 2: algorithm is somewhat different, but the result is the same
Data:=data SHL 8;//move to the high byte
For I:=7 downto 0 do
The begin
If (data xor (CRC) and $8000) & lt;> 0 then//tests only highest
The CRC: (1) CRC SHL xor genpoly=1//that high displacement and exclusive or processing
Else CRC: CRC SHL=1;//otherwise only shift (passenger 2)
Data:=data SHL 1;//processing under a
end;
Result:=CRC;
//method 3: from & lt;
For I:=7 downto 0 do
The begin
If (CRC and $8000) & lt;> 0 then
CRC:=(CRC * 2) xor genpoly//remainder CRC multiplied by 2 to CRC
The else CRC:=CRC * 2;
If (data and SHL I) (1) & lt;> 0 then
CRC:=CRC xor genpoly;//plus standard CRC
end;
Result:=CRC;
}
CodePudding user response:
What do you want to ask?CodePudding user response:
The experience is still less help hat with this respectCodePudding user response:
Thanks for your replyPlease give to the c + + builder warrior can directly use the code, thank you very much!
Better data FA 80 31 30 30 30 to 34 05 00 01 30 81 FC, the red 81 calculated directly, other data through the algorithm, many thanks! Thank you very much!
CodePudding user response: