48 Manual Documentation Number: ZP8D-24RM-LR -0912m
B&B Electronics Mfg Co Inc – 707 Dayton Rd - PO Box 1040 - Ottawa IL 61350 - Ph 815-433-5100 - Fax 815-433-5104 –
www.bb-elec.com
B&B Electronics – Westlink Commercial Park – Oranmore, Galway, Ireland – Ph +353 91-792444 – Fax +353 91-792445 –
www.bb-europe.com
API Operation
– with Escape Characters (AP Parameter = 2)
When this API mode is enabled (AP=2), the UART data frame structure is
defined as follows
UART Data Frame Structure
– with escape control characters:
Escape Characters
– When sending or receiving a UART data frame,
specific data values must be escaped (flagged) so they do not interfere with
the data frame sequencing. To escape an interfering data byte, insert 0X7D
and follow it with the byte to be escaped XOR’d with 0X20.
Data bytes that need to be escaped:
0x7E
– Frame Delimiter
0x7D
– Escape
0x11
– XON
0x13
– XOFF
Example
– Raw UART Data Frame (before escaping interfering bytes:
0x7E 0x00 0x02 0x23 0x11 0xCB
0x11 needs to be escaped which results in the following frame:
0x7E 0x00 0x02 0x23 0x7D 0x31 0xCB
Note: in the above example, the length of the raw data (excluding the
checksum) is 0x0002 and the checksum of the non-escaped data (excluding
frame delimiter and length) is calculated as:
0xFF
– (0x23 + 0x11) = (0xFF – 034) = 0xCB