The VESC uses a consistent framed serial protocol over both UART and USB. Understanding the packet format lets you communicate with a VESC from any microcontroller or host with a serial port. The protocol is implemented inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/vedderb/bldc/llms.txt
Use this file to discover all available pages before exploring further.
comm/packet.c and comm/packet.h.
Packet structure
Every packet is wrapped in a frame that provides length and integrity information.- Short packet (≤ 255 bytes)
- Long packet (256 – 512 bytes)
| Byte(s) | Field | Value |
|---|---|---|
| 0 | Start byte | 0x02 |
| 1 | Payload length | 1 – 255 |
| 2 … (1 + length) | Payload | Command ID + data |
| last 2 | CRC16 | Big-endian CRC of payload |
| last | Stop byte | 0x03 |
- The maximum payload length is 512 bytes (
PACKET_MAX_PL_LENinpacket.h). - The first byte of the payload is always the
COMM_PACKET_IDcommand byte. - The CRC is computed over the payload bytes only (not the start byte, length, or stop byte).
- The stop byte is
0x03for both short and long frames.
The start byte distinguishes frame types:
0x02 means a one-byte length field follows; 0x03 means a two-byte length field follows.Packet layer API
Thepacket.h API manages framing state for each communication channel:
Communicating from an external microcontroller
Connect UART
Connect your microcontroller’s TX to the VESC RX pin and RX to the VESC TX pin. Use the baud rate configured in VESC Tool under App Settings -> UART -> Baud Rate (default: 115200). Ensure common ground.
Build a packet
Construct a payload starting with the
COMM_PACKET_ID byte followed by any required data bytes for that command. Encode it into a frame (start byte, length, payload, CRC16, stop byte).Minimal C example: set duty cycle
COMM_PACKET_ID command reference
The first byte of every payload is aCOMM_PACKET_ID value, defined in datatypes.h.
Motor control commands
| ID | Name | Direction | Description |
|---|---|---|---|
| 5 | COMM_SET_DUTY | Host → VESC | Set duty cycle (int32, scale 100000) |
| 6 | COMM_SET_CURRENT | Host → VESC | Set motor current (int32, scale 1000) |
| 7 | COMM_SET_CURRENT_BRAKE | Host → VESC | Set braking current (int32, scale 1000) |
| 8 | COMM_SET_RPM | Host → VESC | Set RPM (int32, scale 1) |
| 9 | COMM_SET_POS | Host → VESC | Set rotor position in degrees (int32, scale 1000000) |
| 10 | COMM_SET_HANDBRAKE | Host → VESC | Set handbrake current (int32, scale 1000) |
| 84 | COMM_SET_CURRENT_REL | Host → VESC | Set relative current -1.0 to 1.0 (int32, scale 100000) |
Telemetry commands
| ID | Name | Direction | Description |
|---|---|---|---|
| 4 | COMM_GET_VALUES | Host → VESC | Request full motor/system telemetry |
| 50 | COMM_GET_VALUES_SELECTIVE | Host → VESC | Request a bitmask-selected subset of values |
| 47 | COMM_GET_VALUES_SETUP | Host → VESC | Request setup values |
| 22 | COMM_ROTOR_POSITION | VESC → Host | Rotor position (streamed) |
Configuration commands
| ID | Name | Direction | Description |
|---|---|---|---|
| 13 | COMM_SET_MCCONF | Host → VESC | Write motor configuration |
| 14 | COMM_GET_MCCONF | Host → VESC | Read motor configuration |
| 15 | COMM_GET_MCCONF_DEFAULT | Host → VESC | Read default motor configuration |
| 16 | COMM_SET_APPCONF | Host → VESC | Write app configuration |
| 17 | COMM_GET_APPCONF | Host → VESC | Read app configuration |
| 18 | COMM_GET_APPCONF_DEFAULT | Host → VESC | Read default app configuration |
System commands
| ID | Name | Description |
|---|---|---|
| 0 | COMM_FW_VERSION | Get firmware version |
| 29 | COMM_REBOOT | Reboot the device |
| 30 | COMM_ALIVE | Keepalive (no response) |
| 156 | COMM_SHUTDOWN | Shut down the device |
| 20 | COMM_TERMINAL_CMD | Send a terminal command string |
| 21 | COMM_PRINT | Print message from VESC |
Firmware update commands
| ID | Name | Description |
|---|---|---|
| 1 | COMM_JUMP_TO_BOOTLOADER | Jump to bootloader for firmware update |
| 2 | COMM_ERASE_NEW_APP | Erase application flash area |
| 3 | COMM_WRITE_NEW_APP_DATA | Write firmware image chunk |
CAN forwarding
| ID | Name | Description |
|---|---|---|
| 34 | COMM_FORWARD_CAN | Forward packet to another VESC on CAN bus by ID |
| 62 | COMM_PING_CAN | Ping a device on the CAN bus |
| 85 | COMM_CAN_FWD_FRAME | Forward a raw CAN frame |
datatypes.h and the handler in comm/commands.c.
