-
1Writing a Protocol
A big disclaimer to start with: I'm not an advanced developer/programmer -- I'm just an EE with a propensity for programming!
This is also my first shot at writing a complete protocol so I'm sure there is quite a lot I'm missing but I approached this with just a few requirements. The protocol had to be:
- Simple and human readable.
- Extensible.
- Suitable for transmission over I2C and Serial.
Packet Structure
<START><ADDRESS><ACTION><COMMAND><DATA><END><CHECKSUM>
- The START byte is ASCII "{" (123 decimal, 0x7B).
- The ADDRESS byte is any value from 64 to 95 decimal (0x40 to 0x5F, ASCII “@” to “_”).
- The ACTION byte is an ASCII “?” for GET and ASCII “$” for SET.
- The COMMAND bytes are three characters.
- The DATA bytes are variable length and are described in the Data section.
- The END byte is ASCII "}" (125 decimal, 0x7D).
- The CHECKSUM is calculated by subtracting 32 from all the characters in the packet (excluding the checksum) and summing them. The modulo 95 of this value is then calculated and 32 is added back to that value.
Available Commands
Command
Description
ARM
Arm / Disarm System
MTR
Motor Speed
SRV
Servo Position / Speed
ULT
Ultrasonic Distance
IRS
IR Value
DGT
Digital Pin
ANL
Analog Pin
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.