Chain Angle UART Control Protocol (Documentation V1)
1. Basic Information
| Item | Description |
|---|---|
| Communication method | UART / serial port asynchronous communication |
| Device | Chain Angle |
| SKU | U208 |
| Baud Rate | 115200 bps |
| Data Bits | 8 bit |
| Stop bit | 1 bit |
| Parity | None |
| Flow Control | None |
| Document version | V1 |
2. Data Frame Format
All packets start with 0xAA 0x55 and end with 0x55 0xAA. Multi-byte length fields are entered low byte first.
2.1 Request Frame Format
| Field | length | Description |
|---|---|---|
| Header | 2 | Fixed to 0xAA 0x55 |
| Length | 2 | Number of bytes from Index to CRC, low byte first |
| Index | 1 | The index ID of the device in the Chain link |
| Cmd | 1 | request command code |
| Req Data | n | Request parameters; if there are no parameters, the length is 0 |
| CRC | 1 | See "3. Verification Instructions" |
| Tail | 2 | Fixed to 0x55 0xAA |
Request Frame:
AA 55 <Length_low> <Length_high> <Index> <Cmd> <Req Data...> <CRC> 55 AA 2.2 Response Frame Format
| Field | length | Description |
|---|---|---|
| Header | 2 | Fixed to 0xAA 0x55 |
| Length | 2 | Number of bytes from Index to CRC, low byte first |
| Index | 1 | The index ID of the device in the Chain link |
| Cmd | 1 | Consistent with request Cmd |
| Resp Data | n | Response data, the structure is defined by the corresponding command |
| CRC | 1 | See "3. Verification Instructions" |
| Tail | 2 | Fixed to 0x55 0xAA |
Response Frame:
AA 55 <Length_low> <Length_high> <Index> <Cmd> <Resp Data...> <CRC> 55 AA 2.3 Response Data Convention
| situation | response rules |
|---|---|
| Reply with status code | Operation_status = 0 means the operation failed, Operation_status = 1 means the operation was successful |
| Reply without status code | The judgment method of success or failure shall be based on the "Notes" of the corresponding instruction. |
3. Checksum
| Item | rules |
|---|---|
| Check field | CRC |
| Checksum range | Starting from Index, accumulate to the last byte of Data |
| Checksum algorithm | Excluding the packet header, packet trailer, Length and CRC, the remaining bytes are accumulated and the lower 8-bits are taken. |
| Empty Data | CRC = (Index + Cmd) & 0xFF |
| Checksum failure | discard the frame |
CRC = (Index + Cmd + Data[0] + ... + Data[n]) & 0xFF 3.1 Checksum Example
#include <stddef.h>
#include <stdint.h>
uint8_t chain_calc_crc(uint8_t index, uint8_t cmd,
const uint8_t *data, size_t data_len)
{
uint16_t sum = index + cmd;
for (size_t i = 0; i < data_len; i++) {
sum += data[i];
}
return (uint8_t)(sum & 0xFF);
} 4. Quick overview of commands
| Cmd | Command name | Request Length | Reply Length | Request clarification | Response description | Details |
|---|---|---|---|---|---|---|
0x20 | Set RGB values | 0x0005+Num*3 | 0x0004 | Index_id (device index ID), Index (starting coordinates of the RGB lamp), Num (number of RGB to be set), RGB value | Operation_status | 5.1 |
0x21 | Get RGB value | 0x0005 | 0x0004+Num*3/0x04 | Index_id (device index ID), Index (starting coordinates of RGB lights), Num (number of RGB lights to be read) | RGB value | 5.2 |
0x22 | Set RGB light brightness | 0x0005 | 0x0004 | Index_id (device index ID), Light (RGB brightness, 0~100, default 40), Save_to_flash (whether to save to internal Flash) | Operation_status | 5.3 |
0x23 | Get RGB light brightness | 0x0003 | 0x0004 | Index_id (device index ID) | Light (RGB brightness) | 5.4 |
0x30 | Read Angle's 12-bit ADC | 0x0003 | 0x0005 | Index_id (device index ID) | ADC value | 5.5 |
0x31 | Read Angle's 8-bit ADC | 0x0003 | 0x0004 | Index_id (device index ID) | ADC value | 5.6 |
0x32 | Set the rotation control state to determine whether the encoder value increases or decreases when rotating clockwise | 0x0005 | 0x0004 | Index_id (device index ID), Clockwise_direct (clockwise status direction), Save_to_flash (whether to save the configuration to internal Flash) | Operation_status | 5.7 |
0x33 | Get rotation control status | 0x0003 | 0x0004 | Index_id (device index ID) | Clockwise_direct value | 5.8 |
0xF8 | Query device unique UID | 0x0004 | 0x0004+4/12 | Index_id (device index ID), UID_Type | Operation_status、UID | 5.9 |
0xF9 | Query the upgrade program version number | 0x0003 | 0x0004 | Index_id (device index ID) | Bootloader_version | 5.10 |
0xFA | Query the device software version number | 0x0003 | 0x0004 | Index_id (device index ID) | Firmware_version | 5.11 |
0xFB | Query device type | 0x0003 | 0x0005 | Index_id (device index ID) | Device_type | 5.12 |
0xFC | Enumeration request, sent by the chain link change end device, and when the device is powered on, notifying the host to update the link device status | Device-initiated report | Device-initiated report | none | none | 5.13 |
0xFD | Heartbeat packets, regular communication between chain devices, can self-discover whether they are end devices, and the host can also use heartbeat packets to determine whether there is a chain device connected. | 0x0003 | 0x0003 | none | none | 5.14 |
0xFE | Users can obtain the number of link devices through enumeration | 0x0004 | 0x0004 | Send_num (default 0, used to record the number of devices) | Receive_num (the value represents the number of devices) | 5.15 |
5. Command Details
5.1 Set RGB value - Cmd 0x20
Request data
Input parameters: Index_id (device index ID), Index (starting coordinates of the RGB lamp), Num (number of RGB to be set), RGB value
Request Frame:
AA 55 | 0x05+Num*3 | 0x00 | Index_id | 0x20 | Index | Num | R | G | B | ... | CRC | 55 AA Response Data
Return parameters: Operation_status
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x20 | Operation_status | CRC | 55 AA Things to note
- Operation_status operation status
0: Operation failed1: Operation successful
- Index is the starting coordinate of the RGB light, starting from 0. The Angle device has only one RGB light, so Index = 0, Num = 1
5.2 Get RGB value - Cmd 0x21
Request data
Input parameters: Index_id (device index ID), Index (starting coordinates of RGB lights), Num (number of RGB lights to be read)
Request Frame:
AA 55 | 0x05 | 0x00 | Index_id | 0x21 | Index | Num | CRC | 55 AA Response Data
Return parameter: RGB value
Response Frame:
AA 55 | 0x04+Num*3/0x04 | 0x00 | Index_id | 0x21 | Operation_status | R | G | B | ... | CRC | 55 AA Things to note
- Operation_status operation status
0: Operation failed1: Operation successful
- Index is the starting coordinate of the RGB light, starting from 0. The Angle device has only one RGB light, so Index = 0, Num = 1
- The operation failed and the returned data packet did not contain RGB values.
5.3 Set RGB light brightness - Cmd 0x22
Request data
Input parameters: Index_id (device index ID), Light (RGB brightness, 0~100, default 40), Save_to_flash (whether to save to internal Flash)
Request Frame:
AA 55 | 0x05 | 0x00 | Index_id | 0x22 | Light | Save_to_flash | CRC | 55 AA Response Data
Return parameters: Operation_status
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x22 | Operation_status | CRC | 55 AA Things to note
- Operation_status operation status
0: Operation failed1: Operation successful
- Save_to_flash Whether to save internal Flash
0: Do not save1:Save
- Successful setting takes effect immediately
- Saving to the internal Flash requires erasing the page, which is a time-consuming process (about 20ms). During this period, the serial port interrupt will be turned off, and frequent operations will affect the life of the device. If you need to adjust the brightness frequently, please avoid saving to the internal Flash every time.
5.4 Get RGB light brightness - Cmd 0x23
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0x23 | CRC | 55 AA Response Data
Return parameters: Light (RGB brightness)
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x23 | Light | CRC | 55 AA Things to note
5.5 Read Angle’s 12bit ADC - Cmd 0x30
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0x30 | CRC | 55 AA Response Data
Return parameter: ADC value
Response Frame:
AA 55 | 0x05 | 0x00 | Index_id | 0x30 | ADC_low | ADC_high | CRC | 55 AA Things to note
- Angle_ADC = (uint16_t)((ADC_high << 8) | ADC_low)
- The theoretical value range is 0 ~ 4095, but due to device differences, there is an error offset of 0 ~ 10 in the upper and lower limits, so the actual available range will be reduced accordingly.
5.6 Read Angle’s 8bit ADC - Cmd 0x31
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0x31 | CRC | 55 AA Response Data
Return parameter: ADC value
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x31 | ADC | CRC | 55 AA Things to note
- Angle_ADC = ADC
- The theoretical value range is 0 ~ 255, but due to device differences, there is an error offset of 0 ~ 3 in the upper and lower limits, so the actual available range will be reduced accordingly.
5.7 Set the rotation control status to determine whether the encoder value increases or decreases when rotating clockwise - Cmd 0x32
Request data
Input parameters: Index_id (device index ID), Clockwise_direct (clockwise status direction), Save_to_flash (whether to save the configuration to the internal Flash)
Request Frame:
AA 55 | 0x05 | 0x00 | Index_id | 0x32 | Clockwise_direct | Save_to_flash | CRC | 55 AA Response Data
Return parameters: Operation_status
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x32 | Operation_status | CRC | 55 AA Things to note
- Clockwise_direct encoder direction
0: Decrease clockwise1: increasing clockwise (default state)
- Operation_status operation status
0: Operation failed1: Operation successful
- Save_to_flash Whether to save internal Flash
0: Do not save1:Save
- Successful setting takes effect immediately
- Saving to the internal Flash requires erasing the page, which is a time-consuming process (about 20ms). During this period, the serial port interrupt will be turned off, and frequent operations will affect the life of the device.
5.8 Get rotation control status - Cmd 0x33
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0x33 | CRC | 55 AA Response Data
Return parameter: Clockwise_direct value
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0x33 | Clockwise_direct | CRC | 55 AA Things to note
- Clockwise_direct encoder direction
0: Decrease clockwise1: increasing clockwise (default state)
5.9 Query the unique UID of the device - Cmd 0xF8
Request data
Input parameters: Index_id (device index ID), UID_Type
Request Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0xF8 | UID_Type | CRC | 55 AA Response Data
Return parameters: Operation_status, UID
Response Frame:
AA 55 | 0x04+4/12 | 0x00 | Index_id | 0xF8 | Operation_status | UID (multi-byte) | CRC | 55 AA Things to note
- Operation_status operation status
0: Operation failed1: Operation successful
- UID_Type UID type
0:4byte UID1:12byte UID
5.10 Query the upgrade program version number - Cmd 0xF9
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0xF9 | CRC | 55 AA Response Data
Return parameters: Bootloader_version
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0xF9 | Bootloader_version | CRC | 55 AA Things to note
5.11 Query the device software version number - Cmd 0xFA
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0xFA | CRC | 55 AA Response Data
Return parameters: Firmware_version
Response Frame:
AA 55 | 0x04 | 0x00 | Index_id | 0xFA | Firmware_version | CRC | 55 AA Things to note
5.12 Query device type - Cmd 0xFB
Request data
Input parameter: Index_id (device index ID)
Request Frame:
AA 55 | 0x03 | 0x00 | Index_id | 0xFB | CRC | 55 AA Response Data
Return parameters: Device_type
Response Frame:
AA 55 | 0x05 | 0x00 | Index_id | 0xFB | Device_type_low | Device_type_high | CRC | 55 AA Things to note
- Device_type = (uint16_t)((Device_type_high << 8) | Device_type_low)
- The device type code of Angle is 0x0002
5.13 Enumeration request, sent by the end device of chain link change, and sent when the device is powered on, notifying the host to update the link device status - Cmd 0xFC
Request data
Input parameters: none
Request Frame:
Device-initiated report,No host request frame Response Data
Return parameters: none
Response Frame:
Device-initiated report,No response frame Things to note
None.
5.14 Heartbeat packet, regular communication between chain devices, you can self-discover whether it is an end device, and the host can also use the heartbeat packet to determine whether there is a chain device connection - Cmd 0xFD
Request data
Input parameters: none
Request Frame:
AA 55 | 0x03 | 0x00 | 0xFF | 0xFD | CRC | 55 AA Response Data
Return parameters: none
Response Frame:
AA 55 | 0x03 | 0x00 | 0xFF | 0xFD | CRC | 55 AA Things to note
5.15 Users can obtain the number of link devices through enumeration - Cmd 0xFE
Request data
Input parameter: Send_num (default 0, used to record the number of devices)
Request Frame:
AA 55 | 0x04 | 0x00 | 0xFF | 0xFE | Send_num | CRC | 55 AA Response Data
Return parameter: Receive_num (the value represents the number of devices)
Response Frame:
AA 55 | 0x04 | 0x00 | 0xFF | 0xFE | Receive_num | CRC | 55 AA Things to note
None.
6. Status code/enumeration value
6.1 Operating status
| value | Name | Description |
|---|---|---|
0 | Failure | Operation failed |
1 | Success | Operation successful |
Other modes, ranges, and event enumeration values are defined in the "Notes" of the corresponding instructions.
7. Version records
| Document version | Date | Description |
|---|---|---|
V1 | 2025-10-23 | Organized according to the official Chain Angle protocol |