Skip to content

OriginMan Extended Communication Protocol Specification

Communication Protocol

The OriginMan Extended communication protocol is parsed and represented in hexadecimal format, following this basic structure:

Command Format

Frame Header Function Code Data Length Parameters Checksum
0xAA 0x55 (uint8_t)Function (uint8_t)Length Data (uint8_t)CRC
  • Frame Header: When 0xAA and 0x55 are received consecutively, it indicates a data packet has arrived.

  • Function Code: Indicates the purpose of an information frame.

  • Data Length: Number of parameters.

  • Parameters: Additional control information beyond the function command.

  • Checksum: Verifies data integrity using CRC checksum (CRC calculates Function, Length, and Data values, taking the lower 8 bits).

Currently Supported Functions

    PACKET_FUNC_SYS = 0
    PACKET_FUNC_LED = 1        # LED control
    PACKET_FUNC_BUZZER = 2     # Buzzer control
    PACKET_FUNC_MOTOR = 3      # Motor control
    PACKET_FUNC_PWM_SERVO = 4  # PWM servo control
    PACKET_FUNC_BUS_SERVO = 5  # Bus servo control
    PACKET_FUNC_KEY = 6        # Key input
    PACKET_FUNC_IMU = 7        # IMU data
    PACKET_FUNC_GAMEPAD = 8    # Gamepad input
    PACKET_FUNC_SBUS = 9       # RC remote control input
    PACKET_FUNC_OLED = 10      # OLED display content setting
    PACKET_FUNC_RGB = 11       # RGB color setting
    PACKET_FUNC_NONE = 12

Code Implementation

def buf_write(self, func, data):
    buf = [0xAA, 0x55, int(func)]
    buf.append(len(data))
    buf.extend(data)
    buf.append(checksum_crc8(bytes(buf[2:])))
    self.port.write(buf)

Sensor Data Format Introduction

LED

Function Code: 0x01 (PACKET_FUNC_LED)

Protocol Example: 0xAA 0x55 0x01 0x07 0x01 0x64 0x00 0x64 0x00 0x05 0x00 [CRC]

Effect: Controls LED to blink 5 times (100ms on, 100ms off each time)

Code Implementation:

def set_led(self, on_time, off_time, repeat=1, led_id=1):
    on_time = int(on_time * 1000)  # Convert to milliseconds
    off_time = int(off_time * 1000)
    self.buf_write(PacketFunction.PACKET_FUNC_LED, struct.pack("<BHHH", led_id, on_time, off_time, repeat))

Buzzer

Function Code: 0x02 (PACKET_FUNC_BUZZER)

Protocol Example: 0xAA 0x55 0x02 0x08 0x60 0x09 0x64 0x00 0x84 0x03 0x01 0x00 [CRC]

Effect: Controls buzzer at 2400Hz frequency, on for 0.1s, off for 0.9s, repeating once

Code Implementation:

def set_buzzer(self, freq, on_time, off_time, repeat=1):
    on_time = int(on_time * 1000)
    off_time = int(off_time * 1000)
    self.buf_write(PacketFunction.PACKET_FUNC_BUZZER, struct.pack("<HHHH", freq, on_time, off_time, repeat))

Motor

Function Code: 0x03 (PACKET_FUNC_MOTOR)

Protocol Example: 0xAA 0x55 0x03 0x16 0x01 0x04 0x00 0x00 0x00 0x80 0xBF 0x01 0x00 0x00 0x80 0xBF 0x02 0x00 0x00 0x80 0xBF 0x03 0x00 0x00 0x80 0xBF

Effect: Controls 4 motors to rotate at -1r/s

Code Implementation:

def set_motor_speed(self, speeds):
    data = [0x01, len(speeds)]
    for i in speeds:
        data.extend(struct.pack("<Bf", int(i[0] - 1), float(i[1])))
    self.buf_write(PacketFunction.PACKET_FUNC_MOTOR, data)

  • Data Format: Switch status (1 byte), number of motors (1 byte) + N groups of (Motor ID 1 byte + Speed 4 bytes).

  • Motor ID starts from 0 (input 1 is converted to 0), speed is a floating-point number.

Reference Materials

Complete Protocol Specification

Code Implementation