RS232 Serial String Checksum
Checksum
CRC of message
CRC Calculation example :
s[n] is a string containing the message
Polynomial:= 4129
CRC:=0;
for Loop:=1 to Length(s) do
begin
Temp:=s[Loop];
CRC:= CRC xor (integer(Temp) * 256);
CRC:= CRC mod 65536;
for i:=7 downto 0 do
begin
if ( (CRC and 32768)=32768) then
begin
CRC:= CRC *2 ;
CRC:= CRC xor Polynomial;
end
else
begin
CRC:= CRC *2 ;
end;
CRC:=CRC mod 65536;
end;
end;
result:=CRC;