All messages are framed with

  • a START character 0xAA
  • an END character 0xBB


To avoid having START and END characters inside message and still being able to write all values the following characters are replaced with a 2-byte escape sequence.

Finally each message is surrounded with 0xAA and 0xBB and will not have any 0xAA or 0xBB inside Start and End.  

All occurrences of 0xCC will always be one of the 3 escape sequences.

Special Characters

Description

Hexadecimal

frame START

0xAA

frame END

0xBB

ESCAPE

0xCC

escaped START

0xDD

escaped END

0xEE

escaped ESCAPE

0xFF


Escape replacement

Character in original message

Will be replaced with sequence

0xAA

0xCC, 0xDD

0xBB

0xCC, 0xEE

0xCC

0xCC, 0xFF



Example

Original message, including CRC, before escaping

0x20

0xAA

0x30

0xCC

After escaping

0x20

0xCC

0xDD

0x30

0xCC

0xFF

After Framing

0xAA

0x20

0xCC

0xDD

0x30

0xCC

0xFF

0xBB