function CheckCrc16(const ABuf; ALen: Integer): Boolean;
var
uwTemp: WORD;
i, j: BYTE;
P: PByte;
begin
Result := False;
P := PByte(@ABuf);
uwTemp := $FFFF;
for i := 1 to ALen do
begin
uwTemp := uwTemp xor P^;
for j := 1 to 8 do
begin
if (uwTemp and 1) = 1 then
uwTemp := (uwTemp shr 1) xor $A001
else
uwTemp := uwTemp shr 1
end;
Inc(P);
end;
if P^ = BYTE(uwTemp) then
begin
Inc(P);
if P^ = BYTE(uwTemp shr 8) then
begin
Result := True;
end
end
end;