在pchar后面加上两位的crc
Function CheckCRC(MSBchar):Boolean;
var
i,MSBlen:Integer;
tmp:Byte;
A,B:char;
begin
MSBlen:=StrLen(MSB);
tmp:=ord(MSB[0]);
for i:=1 to MSBlen-4do
begin
tmp:=tmp xor ord(MSB);
end;
A:= chr(tmp and $F0);
B:= chr(tmp and $0F);
if (A<>MSB[MSBlen-3]) or (B<>MSB[MSBlen-2]) then
Result:=False
else
Result:=True;
end;
procedure MakeCRC(MSBchar);
var
i,MSBlen:Integer;
tmp:byte;
begin
MSBlen:=StrLen(MSB);
tmp:=ord(MSB[1]);
for i:=2 to MSBlen-1do
begin
tmp:=(tmp xor ord(MSB));
end;
if ((tmp and $F0) shr 4) >=10 then
MSB[MSBlen]:=chr(((tmp and $F0) shr 4)+55)
else
MSB[MSBlen]:=chr(((tmp and $F0) shr 4)+48);
if (tmp and $0F)>=10 then
MSB[MSBlen+1]:=chr((tmp and $0F)+55)
else
MSB[MSBlen+1]:=chr((tmp and $0F)+48);