
SSR-1U User’s Manual
Rev -, 27 Dec 2019
© 2019 Slerj, LLC
21
www.slerj.com
5
Control Protocol
The user interface module provides access to control, status, and configuration through the
interactive shell or through the control protocol. This control protocol interface provides a
structured message-response framework to support robust communication in machine
automation environments. The notation used in this section is intended to be familiar to C
programmers. Values presented in hexadecimal are prepended with
0x
. The
&
symbol
represents the bit-wise AND logical operation.
5.1
Message Format
Control protocol messages are exchanged between the SSR-1U and the user in the form of byte-
oriented packets. Each packet has a start sequence, an ID, a payload count, an optional payload,
and a checksum.
Table 10. Control Protocol Message Format
Header
Payload
Checksum
Start1 Start2
ID
Count
Payload
Cksum1 Cksum2
0x81
0xA1
0xID 0xNN
0xAA 0xBB …
0xZZ
0xC1
0xC2
The start sequence for every packet is the same (0x81 0xA1), and is followed by a single ID
character. Count identifies the number of payload bytes that are included in the packet, and can
be zero. The checksum bytes represent a Fletcher checksum as defined in internet RFC 1145. It
is computed over the ID, Count, and payload bytes. The basic algorithm for computing the
checksum is:
unsigned char Cksum1=0;
unsigned char Cksum2=0;
unsigned char *p = (address of message ID);
int i=0;
while(i<number_of_payloa2)
{
Cksum1 = p[i];
Cksum2 = Cksum1;
i = i + 1;
}
Ordinarily, having a single byte to represent payload count would suggest that the maximum
possible payload length is 255 bytes. But since many applications may require longer packets,
the most significant bit (MSb) of the Count is given special significance in the control protocol.
When the MSb is set, the lower 7 bits are interpreted as a count of 8 byte blocks. Also, since
counts without the MSb set already provide coverage for payloads between 0 and 127 bytes, this
special function starts at 128 bytes. When the MSb of Count is set, payload length is calculated
as 128 + (Count&0x7F)*8.