Touchpoint 4 Serial Communication Protocol Issue 1 09/07
Checksum
During transmission of the packet, an error could change the value of the data.
Suppose in our example, for instance, the packet 0x03, 0x42, 0x41, 0x44 is actually
0x03, 0x42, 0x30, 0x44. How can you determine that the numbers you get are the same
as the numbers sent?
Touchpoint4 serial communication protocol uses a XOR check-character as a method of
assigning a value to the packet to check if any of bytes have been modified.
If all the data bytes are XOR-ed together and this check made into a byte, this byte
could be called a checksum character. For the Touchpoint4, the checksum is the bit-
wise XOR result of all the bytes in the packet. In our example, the packet is 0x03,
0x42, 0x41, 0x44. For this packet, the XOR result 0x44 of all the bytes added to the
checksum must be zero (0). Any other result indicates there is an error with the data.
It is usually important for the master to thoroughly check data coming from the slave
for validity before accepting it. This is because in many installations, an alarm from the
Touchpoint4 indicates severe danger to life and property. The master's determination
that an alarm exists may stimulate a vigorous and possibly expensive human response.
Therefore it is important to avoid false alarms. The master should reject any packets
that contain an invalid start character, an invalid address, an invalid length byte or
an invalid checksum. Otherwise the probability of an evacuation because of simple
network noise is unnecessarily large.
The actual data in the packet is interpreted in a somewhat different manner from our
previous examples. Both the master and the slave communicate using the packet
format in
Figure 2
. It contains a start code, an address, a length, a command and its
associated data, and a checksum. The start code is fixed. The address is the slave
address regardless of the packet’s origin. The length indicates the number of bytes of
command and data field. The command indicates what type of information is being
transmitted in the packet. The Data field is null in some cases. If exist, it contains
specific arguments or values to be interpreted. The checksum is XOR result of all
previous bytes.
ACK/NAK Handshake
Each slave (Touchpoint4) uses a handshake scheme between itself and the master.
The simplest response back from the instrument is called an ACK (an abbreviation for
ACKnowledge). When the slave receives the handshake command (0X40) packet from
the master, it will send back an ACK response. The ACK response will be 0x01 followed
by the handshake command 0x40
(see Handshake command)
.
If however, the checksum does not match, the slave will send a NAK (an abbreviation
for Negative AcKnowledge). A NAK indicates that a data packet has been received, but
the checksum did not match with the packet data.
The master may send the request again. An example of an ACK packet is 0x7F, 0x01,
0x02, 0x40, 0x01, 0x3D (7F XOR 01 XOR 02 XOR 40 XOR 01 = 0x3D).
4