RunCam Split Communication protocol

RunCam Split Communication protocol

Serial Port Configuration

Baud Rate Data Bits Stop Bits Patiry
115200 8 1 none

 

Field Length(byte) content Description
HEADER 1 0x55 Packet Header
COMMAND 1 1 - 255 Please refer "Command code"
ARGUMENT 1 1 - 255 Please refer"Command code"
CRC 1 1 - 255 CRC8 Verification code,for the specific calculation method, please refer to "CRC verify"
TAILER 1 0xaa Packet tailer

Packet Format

Command code

Command Command ID Description
CAMERA_CONTROL 0x1 Camera control instructions

CAMERA_CONTROL Parameter Description

Parameter Parameter ID Description
SIMULATE_WIFI 0x1 Turn on /Turn off Wi-Fi/Enter(OSD Setup Mode)
SIMULATE_POWER 0x2 Start/Stop recording/Next(OSD Setup Mode)
SIMULATE_CHANGEMODE 0x3 Switch camera mode/Exit the current menu(OSD Setup Mode)

CRC verify

When the camera firmware receives the packet, it will calculate the CRC8 checksum of the received data and compares it with the value of the CRC field in the packet to verify the integrity of the packet.
When calculating the CRC8 checksum of the packet, only calculates this 4 bytes:  HEADER+COMMAND+ARGUMENT+TAILER.

Here we use the CRC8 checksum algorithm

static uint8_t crc_high_first(uint8_t *ptr, uint8_t len)
{
    uint8_t i; 
    uint8_t crc = 0x00;
    while (len--) {
        crc ^= *ptr++;  
        for (i = 8; i > 0; --i) { 
            if (crc & 0x80)
                crc = (crc << 1) ^ 0x31;
            else
                crc = (crc << 1);
        }
    }
    return (crc); 
}

The following is the code that generates a packet, the code comes from Cleanflight and BetaFlight io/rcsplit.c

uint8_t uart_buffer[5] = {0};
uint8_t crc = 0;
uart_buffer[0] = RCSPLIT_PACKET_HEADER;
uart_buffer[1] = RCSPLIT_PACKET_CMD_CTRL;
uart_buffer[2] = argument;
uart_buffer[3] = RCSPLIT_PACKET_TAIL;
crc = crc_high_first(uart_buffer, 4);

uart_buffer[3] = crc;
uart_buffer[4] = RCSPLIT_PACKET_TAIL;

Testing

Here are a few commands, when using corresponding parameters, if the generated code not the same as the following, it indicates that the code for the generated packet is incorrect.

Function Data pack
Turn on/Turn off Camera Wi-Fi 0x55 0x01 0x01 0xd8 0xaa
Start/End recording 0x55 0x01 0x02 0xf5 0xaa
Switch camera mode 0x55 0x01 0x03 0x01 0xaa

Have more questions? Submit a request

Comments