CodePudding user response:
The data on the chart is the same calibration methodCodePudding user response:
CRC - 16/CCITT - FALSE (x16 + x12 + x 5 + 1)http://www.ip33.com/crc.html
CodePudding user response:
CodePudding user response:
References from algorithm: https://www.cnblogs.com/yf142857/p/7245758.html
The function CRC16_CCITT_0xFFFF (Bytes: TBytes) : Word;
Const
Polynomial=$1021;
Var
CRC: Word;
I, J: Integer;
B: a Byte;
Bit, C15: Boolean;
The begin
CRC:=$FFFF;//initial value
For I:=0 to High (Bytes) do
The begin
B:=Bytes [I];
For J:=0 to 7 do
The begin
Bit:=(((B SHR (7 - J)) and 1)=1);
C15:=(SHR CRC (15) and (1)=1);
The CRC: CRC SHL=1;
If (C15 xor Bit) then CRC:=CRC xor Polynomial;
end;
end;
Result:=CRC and $FFFF;
end;
Procedure TForm1. FormCreate (Sender: TObject);
Const
Data: TBytes=[$FC, $6 d, $0 d];
Var
CRC: Word;
HexStr: AnsiString;
The begin
The CRC: CRC16_CCITT_0xFFFF=(Data);
SetLength (HexStr, 4);
BinToHex (@ CRC, PAnsiChar (HexStr), 4);
ShowMessage (String (HexStr));
end;
CodePudding user response: