Model 621 User’s Manual APPLICATION PROGRAMMING INTERFACE (API)
Bristol Instruments, Inc. 29
0x7E XOR 0x20 = 0x5E escaping an ST
0x5E XOR 0x20 = 0x7E un-escaping an ST
0x7D XOR 0x20 = 0x5D escaping an ET
0x5D XOR 0x20 = 0x7D un-escaping an ET
The rules for escaping bytes on send are as follows:
Send Bytes on Interface As
0x7E as part of message data
Send 0x7D (0x20 XOR 0x7E)
0x7D as part of message data
Send 0x7D (0x20 XOR 0x7D)
The rules for un-escaping bytes on receive are as follows:
Received Bytes on Interface
XOR of next byte with 0x20
Messages sent over the serial interface will begin with a message ID followed by a
message sequence number, followed by a checksum, followed by the data length,
followed by the message data.
Message sequence numbers will work through the values 0x01 to 0xFF and will rollover
from 0xFF back to 0x01. The value 0x00 will never be used as a sequence number. The
sender is responsible for initializing the sequence number to 0x01 for the first send,
incrementing the sequence number by one for each successive send and rolling the
sequence number over from 0xFF to 0x01. The receiver should flag an error if either 1)
two successive messages are received that contain the same sequence number or 2)
two successive messages are received that have a sequence number delta greater than
one.
The checksum is the exclusive OR of all word (16 bit) values of the message without
embedded escapes. For odd length messages, the final word is exclusive OR’d with the
high byte set to zero. The checksum location is not included when calculating. When
verifying, the entire message, included checksum, is used and should result in a
checksum of zero.
Data lengths will indicate the length of the un-escaped data. The maximum data
component length is 0xFF. This is a result of the maximum value that can be represented
in a byte.