Home > Back-end >  Do you have any similar I VB code provided by the CRC code, please provide, thank you
Do you have any similar I VB code provided by the CRC code, please provide, thank you

Time:10-09

Do you have any similar I VB code provided by the CRC code, please provide, thank

The Function CRC8 (ByRef Data () As Byte, beg the As Byte, zijie As Byte, ByRef YanzhengMa () As Byte, shi As Byte) As Boolean
Dim CRC16Lo As Byte, CRC16Hi As Byte CRC register
'Dim CL As Byte, ch As Byte 'polynomial code & amp; HA001
Dim SaveHi As Byte, SaveLo As Byte
Dim I As Byte
Dim flag As Integer
CRC8=False

CRC16Lo=& amp; H0
CL=& amp; H8C
For I=beg To beg + zijie - 1
CRC16Lo=CRC16Lo Xor Data (I) 'every Data with CRC register for exclusive or
For flag=0 To 7
SaveLo=CRC16Lo
CRC16Lo=CRC16Lo \ 2 'low moves to the right a
If ((SaveLo And & amp; H1)=& amp; H1) Then 'if the LSB is 1 with polynomial code for exclusive or
CRC16Lo=CRC16Lo Xor CL
End the If
Next flag
Next I

YanzhengMa (shi)=CRC16Lo
CRC8=True
End the Function

CodePudding user response:

Take a look at this is what you need at http://www.tansoo.cn/? Tag=CRC

CodePudding user response:

The unit unCRC16;

Interface

The function CalCRC16 (AData: an array of Byte; AStart, AEnd: Integer) : Word;

Implementation

The function CalCRC16 (AData: an array of Byte; AStart, AEnd: Integer) : Word;
Const
GENP=$A001;

Var
CRC: Word;
I: Integer;
TMP: Byte;

Procedure CalOneByte (AByte: Byte);
Var
J: Integer;
The begin
CRC:=CRC xor AByte;
For j:=0 to 7 do
The begin
TMP:=CRC and 1;
The CRC: CRC SHR=1;
CRC:=CRC and $7 FFF;
If TMP=1 then
CRC:=CRC xor GENP;
CRC:=CRC and $FFFF;
end;
end;

The begin
CRC:=$FFFF;
For I:=AStart to AEnd do
CalOneByte (AData [I]);
Result:=CRC;
end;

end.
  • Related