28
MAS7.1 Suplemental Guide, Rev 1.1, 9/28/07
K.I.S.S.™
Keep It Simple Serial
The Asynchronous Mode of Operation (Continued)
When issuing commands in the Asynchronous mode, the controller must be aware of any unsolicited Query
Responses that may be interjected into the communications flow.
For example:
LI?<CR>
Sent: Controller issues query command
=SZ 1,3
Received: (unsolicited) Zone 1 remapped to Input 3
+<CR><LF>
Received: Acknowledgment Response
=P 0
Received: (unsolicited) Power turned off
=LI 3,2,13<CR><LF>
Received: Query Response for LED intensities
This represents a worst case scenario where unsolicited responses appear throughout the communication
sequence.
First the “LI?<CR>” command was issued by the controller.
While looking for an Acknowledgement or Error Response string, an unsolicited Query Response is received,
indicating the user has remapped Zone 1 to Input 3, while the “LI?<CR>” command was being issued by the
controller.
Next the Acknowledgment Response of the “LI?<CR>” command is received.
Next an unsolicited Query Response is received indicating the power has been turned off.
Finally the Query Response indicating the LED intensities is received.
The K.I.S.S.™ command structure was designed to make the above scenario easy to deal with. Since all
Query Responses start with the ‘=’ character, they can be handled asynchronously, as they are received. One
approach would be to write a “Get Response” routine that handles all Query Response internally (by looking for
the ‘=’ character), and only passing through non-query responses.
By using such a routine the above scenario becomes:
LI?<CR>
Sent: Controller issues command
+<CR><LF>
Received: Acknowledgement (or Error) Response
The unsolicited Query Responses were handled internally by the new “Get Response” routine, and filtered
from the communication flow, and only the Acknowledgement (or possible Error) Responses were allowed to
pass. When the “=LI 3,2,13<CR><LF>” response is eventually received, it will be handled like any other unso-
licited response.
Using K.I.S.S.™ in the Asynchronous mode is nearly as easy as using it in the Master / Slave mode, allowing
for the creation of simple to write, but highly efficient device drivers.
Checksums and CRC-8 Checkcodes
The use of a checksums or CRC-8 checkcodes can increase the reliability of communications between the
controller and any Zektor device.
A checksum is calculated by using an unsigned byte as an accumulator, and adding together all the ASCII
characters of a command string, up to and including the ‘;’ character, while ignoring any overflow, and append-
ing it as a decimal parameter to the end of the command.
A CRC-8 checkcode is calculated in a very similar way, but a CRC-8 algorithm is used instead of a simply add-
ing together the ASCII characters. The CRC-8 byte is initialized to ‘FF’ hex, and the resultant value is sent
inverted (one's compliment).
The CRC polynomial used is: x^8 +x^6 +x^3 +x^2 +1.