COM 端口命令 CRC XOR

COM Port Commands CRC XOR

我有一台 支票打印机,我想通过 COM 端口连接到 Delphi7 并运行。

我有一个用串行端口监视器提取的命令:

STX "PIRI(781" FS NULL ETX "0B"02 50 49 52 49 28 37 38 31 1c 00 03 30 42十六进制

手册是这样说的:

CRC (which is the last two digits after the ETX) - packet checksum. It is calculated by the following algorithm: executing XOR for every byte of the block including ETX by excluding STX. The data of the checksum take up two bytes and are a symbolic representation of the numeric in a hexadecimal calculation system.

我尝试了一个在线 CRC 计算器和 return 一个 1B 结果和一个 27 数字。

文档错误地将校验值标识为 CRC。它不是。它只是注释字节的 exclusive-or。 50 49 52 49 28 37 38 31 1c 00 03 的 exclusive-or 是 0b。然后将 0b 转换为十六进制(大写 B,即 0B),得到 30 42.