12.3.
CRC checksum example
Note:
A checksum of “00” will bypass checksum field verification by the controller.
The command to be sent to the unit is 0x01 - get controller model
Full command is: ‘~ 01 01 XX’ + cr Where XX is an unknown checksum at this
time and ‘cr’ is ASCII carriage return character.
Note:
This command assumes the unit address is set to 1.
1.
To calculate command checksum, add decimal values of all characters in
the packet, excluding start, checksum, and terminator. Divide result by
256 and the integer remainder converted to two ASCII hex digits is the
checksum for the command.
2.
Example in decimal, take 290 mod 256 and result is 34, which converted
to hex is 0x22. This is the command checksum. Example in hex, take
0x122 mod 0x100 and result is 0x22. This is the command checksum.
3.
The command to be sent to the unit is, ‘~ 01 01 22’ + cr.
4.
The unit will respond with, ’01 OK 00 DIGITEL QPC E1’.
5.
To verify checksum for the response, perform similar calculations.
6.
Example in decimal, take 1249 mod 256 and result is 225, which
converted to hex is 0xE1. This is the response checksum. Example in hex,
take 0x4E1 mod 0x100 and result is 0xE1. This is the response checksum.
Table 7. Command CRC checksum
Characters
Value (Decimal)
Value (Hex)
space
32
0x20
0
48
0x30
1
49
0x31
space
32
0x20
0
48
0x30
1
49
0x31
space
32
0x20
Total = 290
Total = 0x122
Table 8. Response CRC checksum
Characters
Value (Decimal)
Value (Hex)
0
48
0x30
1
49
0x31
Space
32
0x20
O
79
0x4F
K
75
0x4B
Page 41
900031_J
900031_J - Serial communication