CRCH
STX: Single byte indicating the start of a message - 0x7F hex.
SEQ/Slave ID: Bit 7 is the sequence flag of the packet, bits 6-0 represent the address of
the slave the packet is intended for, the highest allowable slave ID is 0x7D
LENGTH: The length of the data included in the packet - this does not include STX, the CRC
or the slave ID.
Slave ID: Single byte used to identify the address of the slave the packet is intended for.
DATA: Commands or data to be transferred.
CRCL, CRCH: Low and high byte of a forward CRC-16 algorithm using the Polynomial (X16
+ X15 + X2+1) calculated on all bytes, Except STX. It is initialised using the seed 0xFFFF.
The CRC is calculated before byte stuffing.
4.2 PACKET SEQUENCING
Byte stuffing is used to encode any STX bytes that are included in the data to be
transmitted. If 0x7F (STX) appears in the data to be transmitted then it should be
replaced by 0x7F, 0x7F.
Byte stuffing is done after the CRC is calculated, the CRC its self can be byte stuffed. The
maximum length of data is 0xFF bytes. The sequence flag is used to allow the slave to
determine whether a packet is a re-transmission due to its last reply being lost.
Each time the master sends a new packet to a slave it alternates the sequence flag. If a
slave receives a packet with the same sequence flag as the last one, it does not execute
the command but simply repeats its last reply.
In a reply packet the address and sequence flag match the command packet. This
ensures that no other slaves interpret the reply as a command and informs the master
that the correct slave replied.
After the master has sent a command to one of the slaves, it will wait for 1 second for a
reply. After that, it will assume the slave did not receive the command intact so it will re-
transmit it with the same sequence flag.
The host should also record the fact that a gap in transmission has occurred and prepare
to poll the slave for its serial number identity following the current message. In this way,
the replacement of the host’s validator by a fraudulent unit can be detected.
The frequency of polling should be selected to minimise the possibility of swapping a
validator between polls. If the slave has not received the original transmission, it will see
the re-transmission as a new command so it will execute it and reply. If the slave had seen
the original command but its reply had been corrupted then the slave will ignore the
command but repeat its reply. After twenty retries, the master will assume that the slave
has crashed.
A slave has no time-out or retry limit. If it receives a lone sync byte part way through
receiving a packet it will discard the packet received so far and treat the next byte as an
address byte.
Copyright Innovative Technology GA138 –14G