MAS7.1 Supplemental Guide, Rev 1.1, 9/28/07
25
K.I.S.S.™
Keep It Simple Serial
Using Command Checksums and CRC-8 Checkcodes (Continued)
An example of appending a checksum to a command:
LI 2,13;178<CR>
the ‘;’ indicates a checksum follows, the ‘178’ is the checksum of the command string up to and including the ‘;’
character.
In a similar fashion a CRC-8 checkcode can be appended to a command:
LI 2,13:213<CR>
The ‘:’ indicates that a CRC-8 checkcode follows, the ‘213’ is the calculated CRC-8 checkcode up to and
including the ‘:’ character.
Optional spaces are allowed before the ‘;’ and ‘:’ characters but NOT after them. The checksum must immedi-
ately follow the ‘;’ character, and a CRC-8 checkcode must immediately follow the ‘:’ character, anything else,
including whitespace, will cause a syntax error to be returned. Similarly the <CR> must immediately follow the
checksum or checkcode parameter or a syntax error will be returned.
See:
Checksums and CRC-8 Checkcodes
for more information on calculating checksums and
CRC-8 checkcodes, it includes source code examples of calculating both Checksums and CRC-8’s as used by
K.I.S.S.™.
Clearing the Command Buffer
All commands are buffered and nothing is executed until the <CR> character is received. To assure that there
are no extraneous characters in the command buffer, before a command string is sent, the <ESC> character
can be issued to clear the buffer and reset any checksum or CRC-8 checkcode calculations.
This is useful when communications with the Zektor device is being initialized and the state of the device is
unknown. An <ESC> will clear the command buffer and reset all checksums and CRC-8 checkcodes.
For example:
dsLG%df<ESC>V;145<CR>
will return the Version Query Response string. The “dsLG%df” represents noise that could have been in the
buffer before the command string was issued. The <ESC> clears the buffer allowing the “V;145<CR>” to be
processed error free.
It is legitimate (though seldom nessassary) to prefix all commands with the <ESC> character to assure the buf-
fer is always empty before the command string is received, which may be helpful in some very noisy environ-
ments.
The Response Strings
A response will always be returned whenever a <CR> is received. There are no conditions where a “timeout” is
a valid response to any query.
There are only three valid responses in the K.I.S.S.™ protocol, anything else should be considered a commu-
nication error, including a timeout while waiting for a response.
Each response is prefixed by a unique character. Determining which of the three responses is received can be
done simply, by examining only the first character of any response string.
The three possible prefix characters and their associated responses are
+
The Acknowledgement Response
!
The Error Response
=
The Query Response
The response to a command string will always be an Acknowledgement or an Error Response.