-
Notifications
You must be signed in to change notification settings - Fork 10
Home
Welcome to the Afproto wiki!
Afproto is a very simple data framing protocol, optimized for 8-bit microcontrollers, that provides message integrity checking and delimiting.
There are protocol bindings for embedded C, python, and go in the repository.
As described in the repository README.md page:
The protocol is a simplified version of RFC 1662.
Each frame begins and ends with byte 0x7D, with the data immediately following the start byte. Following the data is a two byte CRC (xmodem). The CRC is of the unescaped data. All of the data and CRC are escaped.
The escape byte is 0x7E. Whenever 0x7E or 0x7D occur in the message that byte is prefixed by the escape byte. That byte is then x-or'd with 0x20. As an example, 0x7E in a message would become 0x7E5E.
A depiction of a frame:
| Start Byte | Escaped Data | Escaped CRC16 | End Byte |
The "arduino" branch contains a simplified C protocol with a C++ wrapper for Arduino programming.
Each packet is in the following format
| Header Byte | Length (1 byte) | CRC (1 byte) | Escaped Message (N bytes) | End Byte |
For large messages there is a special case where length is set to 0x00.
| Header Byte | 0x00 (1 byte) | Length (2 byte) | CRC (1 byte) | Escaped Message (N bytes) | End Byte |
Message escaping is done using standard escape char syntax where header, end, and escape chars are escaped (but not x-or'd as in the master branch). See the source code for the escape, header, and footer definitions.