-
Notifications
You must be signed in to change notification settings - Fork 2
UART communication
Gonzalo Cervetti edited this page Apr 12, 2020
·
4 revisions
This page describes how does UART communication works. This protocol serves as a bridge between the STM32 firmware in the PCB and the ROS processes running on raspberry.
The communication is based on asynchronous packages. Each package has the following format:
| start package | command | arguments | stop package |
|---|---|---|---|
| 1 byte | 1 byte | 0 .. nbytes | 1 byte |
Each valid package has a start and a stop byte. The current values of each of them are:
| command | value |
|---|---|
| start package | 0xA0 |
| stop package | 0xB0 |
The commands are formed by 2 nibbles. The first nibble sets the number of arguments that are going to be pass while the other nibble sets the command ID.
- Arguments with float values: they are sent starting with the left value, split in bytes and using big-endian format.
- Arguments with integer values: they are sent starting with the left value, split in bytes and using big-endian format.
The possible commands to send are being shown in the following table:
| command | value | Description |
|---|---|---|
| COMMAND_ECHO | 0x00 | Responds with the same package. Used to check connectivity |
| COMMAND_OFF | 0x02 | Turns off SMPS of the PCB |
| COMMAND_PWM_DUTY | 0x80 | Sets the speed of both motors (float values). |
| COMMAND_ENCODER_TICKS | 0x40 | Contains the current tick count of each encoder (int16_t format). |