Command Set
interprets a command, it looks for the two extra characters and assumes that it is a checksum. If the checksum is not present, the module will perform the command normally. If the two extra characters are present, the module will calculate the checksum for the message. If the calculated checksum does not agree with the transmitted checksum, the module will respond with a ‘BAD CHECKSUM’ error message and the command will be aborted. If the checksums agree, the command will be executed. If the module receives a single extra character, it will respond with a ‘SYNTAX ERROR’ and the command will be aborted. For example:
Command: | $1WE | (no checksum) |
Response: | * |
|
Command: | #1WEF0 | (with checksum) |
Response: | * |
|
Command: | $1WEF1 | (incorrect checksum) |
Response: | ?1 BAD CHECKSUM |
|
Command: | $1WEF | (one extra character) |
Response: | ?1 SYNTAX ERROR |
|
Response Checksums
If the long form ‘#’ version of a command is transmitted to a module, a checksum will be appended to the end of the response. For example:
Command: | $1RD | (short form) |
Response: | *+99999.99 |
|
Command: | #1RD | (long form) |
Response: | *1RD+99999.99D9 |
|
Checksum Calculation
The checksum is calculated by summing the hexadecimal values of all the ASCII characters in the message. The lowest order two hex digits of the sum are used as the checksum. These two digits are then converted to their ASCII character equivalents and appended to the message. This ensures that the checksum is in the form of printable characters.