Touchpoint 4 Serial Communication Protocol Issue 1 09/07
Checksum
During transmission of the packet, an error could change the value of the data.
Supposeinourexample,forinstance,thepacket0x03,0x42,0x41,0x44isactually
0x03,0x42,0x30,0x44.Howcanyoudeterminethatthenumbersyougetarethesame
as the numbers sent?
Touchpoint4serialcommunicationprotocolusesaXORcheck-characterasamethodof
assigning a value to the packet to check if any of bytes have been modified.
IfallthedatabytesareXOR-edtogetherandthischeckmadeintoabyte,thisbyte
could be called a checksum character. For the Touchpoint4, the checksum is the bit-
wiseXORresultofallthebytesinthepacket.Inourexample,thepacketis0x03,
0x42,0x41,0x44.Forthispacket,theXORresult0x44ofallthebytesaddedtothe
checksummustbezero(0).Anyotherresultindicatesthereisanerrorwiththedata.
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
thatanalarmexistsmaystimulateavigorousandpossiblyexpensivehumanresponse.
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
previousexamples.Boththemasterandtheslavecommunicateusingthepacket
format in
Figure 2. It contains a start code, an address, a length, a command and its
associateddata,andachecksum.Thestartcodeisfixed.Theaddressistheslave
addressregardlessofthepacket’sorigin.Thelengthindicatesthenumberofbytesof
command and data field. The command indicates what type of information is being
transmittedinthepacket.TheDatafieldisnullinsomecases.Ifexist,itcontains
specificargumentsorvaluestobeinterpreted.ThechecksumisXORresultofall
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).Whentheslavereceivesthehandshakecommand(0X40)packetfrom
themaster,itwillsendbackanACKresponse.TheACKresponsewillbe0x01followed
bythehandshakecommand0x40
(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.
Themastermaysendtherequestagain.AnexampleofanACKpacketis0x7F,0x01,
0x02,0x40,0x01,0x3D(7FXOR01XOR02XOR40XOR01=0x3D).
4