我欧姆龙读卡器BCC校验的代码,参考一下:
function TForm1.GetCmd(S: string): string;
var
I: Integer;
BCC: Byte;
begin
BCC := $10;
for I := 1 to Length(S) do
begin
BCC := BCC xor Ord(S);
end;
BCC := BCC xor Byte(DLE);
BCC := BCC xor Byte(ETX);
Result := DLE + STX + S + DLE + ETX + Char(BCC);
end;