Files
yolocam-linux/docs/protocol-reference.md
2026-02-15 12:50:49 -08:00

16 KiB

YoloCam S3 Protocol Technical Reference

Complete documentation of the YoloCam S3 camera control protocol.

Hardware Overview

Property Value
Manufacturer YoloLiv (Yunxi Technology)
Model YoloCam S3
USB VID:PID 46f8:0855
SoC HiSilicon HI3519DV500
Architecture aarch64, musl libc
OS BusyBox Linux
Camera app /app/bin/live_camera_app
Firmware YunxiCamera-ch131b-0.0.6
Sys code 1188

USB Interfaces

The camera is a composite USB device with two functional interfaces:

Interface Class Function
0-1 CDC NCM Network adapter (camera: 192.168.126.10, host: 192.168.126.11/24 via DHCP)
2-3 UVC Video Class webcam (live video feed)

Network Services

On the CDC NCM network (192.168.126.10):

Port Service Credentials
21 FTP root:yunxi.tv
23 Telnet root:yunxi.tv
12345 Control protocol (TCP) None

Wire Format

All control communication uses TCP on port 12345. Each message is wrapped in a dual-envelope wire format.

Frame Structure

Offset  Size  Field                 Description
──────  ────  ────────────────────  ─────────────────────────────────────
 0      1     outer_start           Always 0x08
 1      1     client_type           0x01 for client->camera, 0x00 for camera->client
 2      2     padding               Always 0x00 0x00
 4      4     inner_size            Little-endian uint32: proto_size + 8
 8      1     inner_start           Always 0xA5
 9      4     proto_size            Big-endian uint32: serialized protobuf length
13      1     header_checksum       XOR of bytes [8..12] (inner_start + proto_size)
14      N     payload               Serialized protobuf Message
14+N    1     data_checksum         XOR of all payload bytes
15+N    1     inner_end             Always 0x5A

Total frame size: 16 + proto_size bytes.

Checksum Algorithm

Simple XOR of all bytes in the specified range:

def xor_checksum(data: bytes) -> int:
    result = 0
    for b in data:
        result ^= b
    return result

The header checksum covers bytes 8-12 (inner start flag + 4-byte proto_size). The data checksum covers the entire protobuf payload.

Example Frame

Setting brightness to 50 (CID_BRIGHTNESS = 7, value = 50):

Protobuf Message:
  type: TYPE_SET (2)
  id: CID_BRIGHTNESS (7)
  body: { int_val: 50 }

Serialized protobuf (hex): 08 02 28 07 32 02 08 32
  proto_size = 8

Wire frame (hex):
  08 01 00 00  10 00 00 00     Outer: start=0x08, client=0x01, inner_size=16
  A5 00 00 00  08 AD            Inner: start=0xA5, proto_size=8, hdr_xor=0xAD
  08 02 28 07  32 02 08 32     Payload: protobuf bytes
  0B 5A                        Trailer: data_xor=0x0B, end=0x5A

Protobuf Schema

Package: tv.yunxi.protobuf

Message Wrapper

message Message {
    MessageType type = 1;   // Request type
    uint32 seq = 2;         // Sequence number (echoed in response)
    uint32 timeout = 3;     // Request timeout (ms), typically 3000
    uint32 resp_code = 4;   // Response code (200=OK, 100=unsupported/out-of-range)
    CommandId id = 5;       // Which command
    CommandBody body = 6;   // Payload
}

Message Types

Value Name Description
1 TYPE_REQUEST Client reads a parameter (GET)
2 TYPE_SET Client writes a parameter (SET)
3 TYPE_POST Client sends data (file transfer, CLUT upload)
4 TYPE_RESPONSE Camera response to any request
5 TYPE_NOTIFY Asynchronous camera notification

Response Codes

Code Meaning
200 Success
100 Unsupported command or value out of range

Command Body

message CommandBody {
    oneof value {
        uint32 int_val = 1;
        string str_val = 2;
        ManualExposureParams exposure_params = 3;
        WhiteBalanceManual white_balance_manual = 4;
        TransportFile transport_file = 5;
        Size size = 6;
        Range range = 7;
        Rect rect = 8;
        FileInfo file_info = 9;
        VersionInfo version_info = 10;
        UpgradeEvent upgrade_event = 11;
        LensStatusEvent lens_event = 12;
        WhiteBalanceOffset white_balance_offset = 13;
        RectF rect_f = 14;
        LensInfo lens_info = 15;
        TuningFileInfo tuning_file_info = 16;
        TuningParam tuning_param = 17;
        ListInt list_int = 18;
        ListRectF list_rect_f = 19;
        LensDetail lens_detail = 20;
        LensAmend lens_amend = 21;
        LensReset lens_reset = 22;
        BleScanParam ble_scan_param = 23;
        AdvInfo adv_info = 24;
        LightConnection light_connection = 25;
        LightStatus light_status = 26;
        LightParam light_param = 27;
        LightConnectedList light_connected_list = 28;
        IndicatorCtl indicator_ctl = 29;
        RawImgInfo raw_img_info = 30;
        TuningClutFile tuning_clut_file = 31;
        WlanConf wlan_conf = 32;
        StreamParam stream_param = 33;
        DiskInfo disk_info = 34;
        PtzCtrl ptz_ctrl = 35;
        DumpPdParam dump_pd_param = 36;
        RCEvent rc_event = 37;
        WifiScanResults wifi_list = 38;
        AiTrackingCtrl ai_tracking_ctrl = 39;
        AiParams ai_params = 40;
        VideoStatus video_status = 41;
        DrawInfoList draw_info_list = 42;
        AdvInfoList adv_list = 43;
        LensVersionInfo lens_version_info = 44;
    }
}

Command Reference

Image Quality

CID Name Type Range Default Description
7 CID_BRIGHTNESS int 0-100 50 Image brightness
8 CID_SHARPNESS int -10 to 30 5 Sharpness. Wire encoding: 0-30 sent as-is, -1 to -10 sent as 61-70
9 CID_CONTRAST int 0-100 50 Contrast
10 CID_SATURATION int 0-100 50 Color saturation
11 CID_HUE int 0-100 50 Hue. Wire protocol 0-100 maps to UI 0-360 via hue * 100 / 360
12 CID_GAMMA int 0-100 50 Gamma correction

Zoom

CID Name Type Range Default Description
13 CID_ZOOM int 50-98 (raw) 50 Digital zoom. Conversion: mult = 0.0625 * raw - 2.125. Raw 50 = 1.0x, 98 = 4.0x
112 CID_ZOOM_SPEED int 1-5 3 Zoom animation speed (set-only)

Exposure

CID Name Type Range Default Description
14 CID_EXPOSURE_MODE int 0-1 0 0=Auto, 1=Manual
15 CID_EXPOSURE_EV int 0-16 8 EV compensation. 8 = 0EV
16 CID_ANTI_FLICKER int 0-2 0 0=Off, 1=50Hz, 2=60Hz
17 CID_EXPOSURE_ISO int actual 400 ISO value sent directly (100, 125, ..., 12800)
18 CID_EXPOSURE_TIME int microseconds 16666 Shutter in microseconds (16666=1/60s, 1000=1/1000s, 125=1/8000s)
20 CID_EXPOSURE_APERTURE int 0-31 10 Aperture index. 0=F1.0, 10=F2.8, 31=F32.0
98 CID_ENABLE_HDR int 0-1 0 HDR toggle
102 CID_DYNAMIC_RANGE int 0-100 50 Dynamic range
106 CID_EXPOSURE_LOCK int 0-1 0 Lock exposure

Shutter Speed Table

Denominator Microseconds Denominator Microseconds
1/8000 125 1/500 2000
1/6400 156 1/400 2500
1/5000 200 1/320 3125
1/4000 250 1/250 4000
1/3200 312 1/200 5000
1/2500 400 1/160 6250
1/2000 500 1/125 8000
1/1600 625 1/100 10000
1/1250 800 1/80 12500
1/1000 1000 1/60 16666
1/800 1250 1/50 20000
1/640 1562 1/30 33333
1/25 40000

ISO Values

100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, 9600, 12800

White Balance

CID Name Type Range Default Description
21 CID_WHITE_BALANCE_MODE int 0-1 1 0=Manual, 1=Auto
22 CID_WHITE_BALANCE_TEMPERATURE int 2000-10000 5500 Color temp in Kelvin
33 CID_WHITE_BALANCE_OFFSET WhiteBalanceOffset R/B offset (body.white_balance_offset)
104 CID_WHITE_BALANCE_LOCK int 0-1 0 Lock WB
105 CID_WHITE_BALANCE_TEMPERATURE_SHIFT int 0-128 64 WB temp shift

Focus

CID Name Type Range Default Description
23 CID_FOCUS_MODE int 1-4 1 1=AFS, 2=Manual, 3=AFC, 4=Face
38 CID_FOCUS_RECT_LEVEL int 0-2 0 0=Large, 1=Medium, 2=Small
42 CID_ENABLE_CAF int 0-1 0 Continuous AF
47 CID_TRIGGER_SPEED int AF trigger speed
111 CID_MANU_FOCUS_CODE int Manual focus step (set-only)
214 CID_ENABLE_FACE_ROI int 0-1 0 Face-detect ROI (set-only)

Audio

CID Name Type Range Default Description
73 CID_AU_VOLUME int 0-100 50 Audio volume
75 CID_AU_DENOISE int 0-3 2 0=Close, 1=Weak, 2=Middle, 3=Strong
76 CID_AU_REVERB int 0-3 0 0=Close, 1=Weak, 2=Middle, 3=Strong
77 CID_AU_DELAY int 0-400 0 Audio delay in ms
78 CID_AU_AUTO_GAIN int 0-1 0 Auto gain toggle
79 CID_AU_MIC_TYPE int 0-1 0 0=Line, 1=Mic (set-only)

Video / Streaming

CID Name Type Range Description
5 CID_FRAME_RATE int 25/30/50/60 Frame rate
6 CID_RESOLUTION int Resolution setting
202 CID_STREAM_CFG StreamConfig Stream configuration (set-only)
203 CID_STREAMING_START int Start streaming
204 CID_STREAMING_STOP int Stop streaming
205 CID_RECORDING_START int Start recording
206 CID_RECORDING_STOP int Stop recording
211 CID_ENABLE_UVC int 0-1 UVC output (set-only)

HDMI

CID Name Type Range Default Description
61 CID_HDMI_OUTPUT_FORMAT int 0-3 0 0=Auto, 1=4K, 2=1080p, 3=720p
65 CID_HDMI_COLOR_SPACE int 0-2 0 0=Auto, 1=RGB, 2=YUV422

Color LUT (CLUT)

CID Name Type Description
94 CID_ENABLE_CLUT int (0/1) Enable/disable 3D color LUT on ISP
95 CID_CLUT_FILE TuningClutFile Upload CLUT data (5508 uint32 entries)
96 CID_CLUT_ATTR int (0-255) CLUT blend intensity
53 CID_TUNING TuningParam Image tuning (brightness, curve, color_temp)

CLUT Data Format

The ISP uses a 17x17x17 3D color lookup table stored as 5508 uint32 entries in an interleaved octant layout. Each uint32 packs three signed 10-bit RGB delta values in s0.9 fixed-point format (range [-1.0, +0.998]).

Entry packing: (R_delta << 20) | (G_delta << 10) | B_delta

Each 10-bit delta is interpreted as signed fixed-point divided by 512:

  • Value 0: no change
  • Value 511: +0.998 (maximum positive delta)
  • Value 512 (0x200): -1.0 (maximum negative delta, two's complement)

Octant interleaving: The 4913 grid nodes (17^3) are grouped into 8 octants based on the parity of (x, y, z) indices. Octant = (x&1) + ((y&1)<<1) + ((z&1)<<2).

Octant Even/Odd pattern Size Cumulative offset
0 (E,E,E) 729 (9x9x9) 0
1 (O,E,E) 648 (8x9x9) 729
2 (E,O,E) 648 (9x8x9) 1377
3 (O,O,E) 576 (8x8x9) 2025
4 (E,E,O) 648 (9x9x8) 2601
5 (O,E,O) 576 (8x9x8) 3249
6 (E,O,O) 576 (9x8x8) 3825
7 (O,O,O) 512 (8x8x8) 4401

Total: 729+648+648+576+648+576+576+512 = 4913 entries (with 595 padding to 5508).

Upload via protobuf: CLUT data is sent using TuningClutFile message on CID_CLUT_FILE (95) as a TYPE_POST:

message TuningClutFile {
    uint32 clut_size = 1;           // Always 5508
    repeated uint32 clut_data = 2;  // The CLUT entries
    string hsv_data = 3;            // JSON string with HSV grid state
    string extra = 4;               // Additional metadata
    string updataflag = 5;          // Update flag
}

AI Features

CID Name Type Range Default Description
99 CID_AI_TRACKING_CTRL AiTrackingCtrl 0-2 2 0=Portrait, 1=Thing, 2=Off
59 CID_FACE_BOUNDING_BOXES ListRectF Face detection boxes (NOTIFY, fires constantly)

Device Info (Read-Only)

CID Name Response Type Description
1 CID_VERSION_INFO VersionInfo Firmware version, serial, unique ID, sys_code
60 CID_USB_VERSION int USB protocol version
48 CID_LENS_STATUS int Lens connection status
63 CID_GET_LENS_DETAIL LensDetail Lens ID, aperture, focal, serial, drive times
113 CID_LENS_VERSION LensVersionInfo Lens firmware version
210 CID_VIDEO_STATUS_CHANGED VideoStatus Video pipeline status
103 CID_AU_VERSION int Audio module version
301 CID_DISK_INFO DiskInfo SD card total/available size, filesystem type
213 CID_LOWPOWER_STATUS int Low power status
31 CID_RANGE_OF_APERTURE Range Min/max aperture for current lens
32 CID_RANGE_OF_EXP_TIME Range Min/max exposure time range

Notifications

CID Name Description
59 CID_FACE_BOUNDING_BOXES Face detection rectangles (high frequency, suppress in logs)
209 CID_DURATION_CHANGED Recording duration update
210 CID_VIDEO_STATUS_CHANGED Video pipeline state change
207 CID_STREAMING_STOPPED Streaming stopped
208 CID_RECORDING_FINISHED Recording finished
303 CID_DISK_EVENT SD card insertion/removal

Heartbeat

The camera requires a periodic heartbeat to maintain the control connection:

CID_STREAM_HEARTBEAT (215) = 1, sent every 30 seconds

If the heartbeat stops, the camera may drop the TCP connection.

Communication Patterns

GET (Read Parameter)

Client -> Camera:
  Message {
    type: TYPE_REQUEST (1)
    seq: N
    timeout: 3000
    id: CID_BRIGHTNESS (7)
  }

Camera -> Client:
  Message {
    type: TYPE_RESPONSE (4)
    seq: N
    resp_code: 200
    id: CID_BRIGHTNESS (7)
    body: { int_val: 50 }
  }

SET (Write Parameter)

Client -> Camera:
  Message {
    type: TYPE_SET (2)
    seq: N
    timeout: 3000
    id: CID_BRIGHTNESS (7)
    body: { int_val: 60 }
  }

Camera -> Client:
  Message {
    type: TYPE_RESPONSE (4)
    seq: N
    resp_code: 200
    id: CID_BRIGHTNESS (7)
  }

POST (Send Complex Data)

Used for CLUT uploads, file transfers, and other structured data:

Client -> Camera:
  Message {
    type: TYPE_POST (3)
    seq: N
    timeout: 3000
    id: CID_CLUT_FILE (95)
    body: {
      tuning_clut_file: {
        clut_size: 5508
        clut_data: [0, 0, 0, ..., 5508 entries]
        hsv_data: "{\"hue\": [...], \"sat\": [...]}"
      }
    }
  }

NOTIFY (Camera Event)

Unsolicited messages from camera to client:

Camera -> Client:
  Message {
    type: TYPE_NOTIFY (5)
    id: CID_FACE_BOUNDING_BOXES (59)
    body: { list_rect_f: { values: [...] } }
  }

Camera Behavior Notes

Rate Limiting

The camera overwhelms easily with rapid requests. After approximately 25+ rapid requests without delays, it stops responding to all commands except CID_VERSION_INFO.

Mitigation:

  • Insert 100ms+ delays between requests
  • Use single persistent TCP connections
  • Restart live_camera_app via telnet if camera becomes unresponsive

Recovery

If the camera stops responding:

telnet 192.168.126.10
# Login: root / yunxi.tv
killall live_camera_app
/app/bin/live_camera_app &

Or power-cycle the camera.

Set-Only Parameters

Some parameters only accept SET commands and return resp_code=100 for GET:

CID_ZOOM_SPEED, CID_MANU_FOCUS_CODE, CID_ENABLE_FACE_ROI, CID_SCENE, CID_STREAM_CFG, CID_ENABLE_UVC, CID_AU_MIC_TYPE, CID_INDICATOR_CTL

Filesystem

The camera's filesystem (accessible via FTP at root:yunxi.tv):

/app/bin/live_camera_app    Main camera application
/app/                       Application directory
/tmp/                       Temporary files (CLUT saves go here)

CLUT files are persisted as /tmp/clut_0_0.info on the camera's filesystem.