AgentSkillsCN

RS300 I2C Commands Skill

RS300 I2C 命令技能

SKILL.md

RS300 I2C Commands Skill

Complete reference for formatting and validating RS300 thermal camera I2C commands


1. When to Use This Skill

Invoke this skill when you need to:

  • Format RS300 I2C command packets (18-byte structure)
  • Validate command hex codes against CSV source
  • Calculate or lookup CRC-16-CCITT checksums
  • Construct camera control sequences
  • Set up thermal camera parameters (brightness, colormap, zoom, etc.)
  • Debug I2C command failures or packet structure issues

This skill provides:

  • Complete command reference for 20+ I2C commands
  • Packet structure validation rules
  • CRC calculation and hardcoded lookup tables
  • Multi-byte parameter encoding examples
  • Working end-to-end command examples
  • Common mistakes with prevention tips
  • Pre-execution verification checklist

2. Command Classes

RS300 I2C commands use two command classes:

ClassPurposeModule RangeExamples
0x10Camera control0x02-0x10Brightness, Colormap, FFC, Output Mode, FPS
0x01Device info & zoom0x01, 0x31Device Name, VID/PID, Zoom control

3. Command Reference (Quick Summary)

All commands organized by category - 45+ total I2C commands

3.1 Shutter & Calibration Commands

CommandHex CodeTypeCRCCSV Rows
FFC Trigger (Shutter Correction)0x10/0x02/0x43SETDyn2
Background Correction0x01/0x10/0x52SETDyn3
Close Shutter0x01/0x0F/0x45SETHard4
Open Shutter0x01/0x0F/0x45SETHard5
Autoshutter SET0x10/0x02/0x41SETDyn6-7
Autoshutter GET0x10/0x02/0x81GETDyn8
Autoshutter Temp SET0x10/0x02/0x42SETDyn9-10
Autoshutter Interval SET0x10/0x02/0x42SETDyn11-13
Autoshutter Params GET0x10/0x02/0x82GETDyn15-16

3.2 K-Value & Blind Element Calibration

CommandHex CodeTypeCRCCSV Rows
K-Value Collect Low0x10/0x11/0x41SETDyn17
K-Value Collect High0x10/0x11/0x41SETDyn18
K-Value Collection & Calc0x10/0x11/0x41SETDyn19
K-Value Save0x10/0x11/0x43SETDyn20
K-Value Cancel0x10/0x11/0x42SETDyn21
K-Value Clear0x10/0x11/0x44SETDyn22
K-Value Restore Factory0x10/0x11/0x45SETDyn23
Blind Element Auto Calibration0x10/0x11/0x51SETDyn24
Blind Element Cursor Enable0x10/0x11/0x57SETDyn25
Blind Element Cursor Disable0x10/0x11/0x57SETDyn26
Blind Element Cursor GET0x10/0x11/0x81GETDyn27
Blind Element Set Position0x10/0x11/0x58SETDyn28
Blind Element Get Position0x10/0x11/0x82GETDyn29
Blind Element Mark Bad0x10/0x11/0x52SETDyn30
Blind Element Mark Good0x10/0x11/0x52SETDyn31
Blind Element Cancel0x10/0x11/0x53SETDyn32
Blind Element Save0x10/0x11/0x54SETDyn33
Blind Element Clear0x10/0x11/0x55SETDyn34
Blind Element Restore Factory0x10/0x11/0x56SETDyn35

3.3 Pot Lid Calibration

CommandHex CodeTypeCRCCSV Rows
Pot Lid Calibration0x10/0x11/0x61SETDyn36
Pot Lid Save0x10/0x11/0x63SETDyn37
Pot Lid Cancel0x10/0x11/0x62SETDyn38
Pot Lid Clear0x10/0x11/0x64SETDyn39
Pot Lid Restore Factory0x10/0x11/0x65SETDyn40

3.4 System Features

CommandHex CodeTypeCRCCSV Rows
Firmware Update0x01/0x01/0x42SETDyn41
Anti-burn Protection SET0x10/0x03/0x4BSETHard42-43
Anti-burn Protection GET0x10/0x03/0x8BGETHard44
Sleep SET0x10/0x10/0x48SETHard45-46
Sleep GET0x10/0x10/0x88GETHard47
Boot Logo SET0x10/0x10/0x41SETHard48-49
Boot Logo GET0x10/0x10/0x81GETHard50
DVP/I2C Voltage SET0x10/0x10/0x47SETHard51-52
DVP/I2C Voltage GET0x10/0x10/0x87GETHard53
Parameter Preservation0x10/0x10/0x51SETDyn54
Parameter Recovery0x10/0x10/0x52SETDyn55

3.5 Device Information

CommandHex CodeTypeCRCCSV Rows
Device Name GET0x01/0x01/0x81GETHard56
FW Version GET0x01/0x01/0x81GETHard57
VID GET0x01/0x01/0x81GETHard58
PID GET0x01/0x01/0x81GETHard59
PN GET0x01/0x01/0x81GETHard60
SN GET0x01/0x01/0x81GETHard61
Module Temperature GET0x10/0x10/0x91GETDyn62
Hottest Spot Coordinates GET0x10/0x10/0x92GETDyn63-64
Power-on Time GET0x10/0x10/0x93GETDyn65

3.6 Video Output - Digital Formats

CommandHex CodeTypeCRCCSV Rows
Digital Video Format SET0x10/0x10/0x46SETDyn66-83
Digital Video Format GET0x10/0x10/0x86GETDyn84

3.7 Video Output - Analog & YUV Formats

CommandHex CodeTypeCRCCSV Rows
Analog Video Format SET0x10/0x10/0x4ASETDyn85-87
Analog Video Format GET0x10/0x10/0x8AGETDyn88
Digital-Analog Output Format0x10/0x10/0x49SETHard89
Detector Frame Rate SET0x10/0x10/0x44SETDyn90-93
Detector Frame Rate GET0x10/0x10/0x84GETDyn94
Output Mode (IR/KBC/TNR/SNR/DDE/YUV) SET0x10/0x10/0x45SETHard95-100
Output Mode GET0x10/0x10/0x85GETHard101
YUV Format SET0x10/0x03/0x4DSETDyn102-105
YUV Format GET0x10/0x03/0x8CGETDyn106

3.8 Video Output - Display Control

CommandHex CodeTypeCRCCSV Rows
Screen Freeze SET0x10/0x10/0x42SETDyn107-108
Screen Freeze GET0x10/0x10/0x82GETDyn109
Mirror/Flip SET0x10/0x10/0x43SETDyn110-113
Mirror/Flip GET0x10/0x10/0x83GETDyn114
External Sync SET0x10/0x10/0x4BSETDyn115-116
External Sync GET0x10/0x10/0x8BGETDyn117

3.9 Zoom Control

CommandHex CodeTypeCRCCSV Rows
Electronic Zoom Center SET0x01/0x31/0x42SETDyn118-122
Electronic Zoom Center GET0x01/0x31/0x82GETDyn123
Electronic Zoom AOI SET0x01/0x31/0x51SETDyn124
Electronic Zoom AOI GET0x01/0x31/0x91GETDyn125

3.10 Image Processing - Scene & Color

CommandHex CodeTypeCRCCSV Rows
Scene Mode SET (10 modes)0x10/0x04/0x42SETDyn126-135
Scene Mode GET0x10/0x04/0x89GETDyn136
False Color (Colormap) SET (12 palettes)0x10/0x03/0x45SETDyn137-148
False Color GET0x10/0x03/0x85GETDyn149

3.11 Image Processing - Enhancement & Filters

CommandHex CodeTypeCRCCSV Rows
Detail Enhancement (DDE) SET (0-100)0x10/0x04/0x45SETDyn150-160
Detail Enhancement GET0x10/0x04/0x85GETDyn161
Brightness SET (0-100)0x10/0x04/0x47SETDyn162-172
Brightness GET0x10/0x04/0x87GETDyn173
Contrast SET (0-100)0x10/0x04/0x4ASETDyn174-184
Contrast GET0x10/0x04/0x8AGETDyn185
Spatial Noise Reduction (SNR) SET (0-100)0x10/0x04/0x4BSETDyn186-196
Spatial Noise Reduction GET0x10/0x04/0x8BGETDyn197
Temporal Noise Reduction (TNR) SET (0-100)0x10/0x04/0x4CSETDyn198-208
Temporal Noise Reduction GET0x10/0x04/0x8CGETDyn209
Gamma Intensity SET (0-100)0x10/0x04/0x4DSETDyn210-220
Gamma Intensity GET0x10/0x04/0x8DGETDyn221
Hook Edge Position SET (0-2)0x10/0x04/0x4ESETDyn222-224
Hook Edge Position GET0x10/0x04/0x8EGETDyn225

Legend:

  • CRC: Dyn = Calculate using CRC-16-CCITT, Hard = Use hardcoded lookup table
  • Type: GET = Read response, SET = Write command
  • CSV Rows: References to specific rows in Mini2_I2C_full_commands.csv

4. Packet Structure (Standard 18-Byte)

All RS300 I2C commands use exactly 18 bytes:

code
Byte Position  Field      Description                     Example
[0]            Class      0x10 (camera) or 0x01 (device)  0x10
[1]            Module     Command module (varies)         0x04
[2]            SubCmd     Sub-command (varies)            0x47
[3]            Reserved   Always 0x00                     0x00
[4-15]         P1-P12     Parameters (varies)             [val] + 0x00...
[16]           CRC_Low    LSB of CRC-16-CCITT             0xXX
[17]           CRC_High   MSB of CRC-16-CCITT             0xXX

Critical Rules:

  • ✅ Always 18 bytes total
  • ✅ Byte [3] (reserved) must be 0x00
  • ✅ Unused parameter bytes (P1-P12) must be 0x00
  • ✅ CRC is over bytes [0-15], appended at [16-17]

5. Detailed Command Specifications

5.1 Output Mode SET (CRITICAL - I2C Protocol)

Command: Set camera output processing mode Hex Code: 0x10/0x10/0x45 (Class: Camera, Module: MIPI, SubCmd: Output source) CSV Rows: 95-101 CRC Type: Hardcoded lookup table

Modes:

ModeValueDescriptionCRC (LSB, MSB)
IR0Raw infrared sensor output0xFB, 0xC0
KBC1K-based contrast enhancement0x8E, 0xC3
TNR2Temporal noise reduction0x11, 0xC6
SNR3Spatial noise reduction0x64, 0xC5
DDE4Digital detail enhancement0x2F, 0xCD
YUV5YUV color output0x5A, 0xCE

Packet Structure (18 bytes - Standard I2C):

code
[0]  = 0x10 (Class: Camera control)
[1]  = 0x10 (Module: MIPI interface)
[2]  = 0x45 (SubCmd: Output source selection)
[3]  = 0x00 (Reserved)
[4]  = mode (P1: 0=IR, 1=KBC, 2=TNR, 3=SNR, 4=DDE, 5=YUV)
[5-15] = 0x00 (Padding)
[16-17] = CRC (Hardcoded from lookup table)

Example: Set output mode to TNR (mode 2)

code
Packet: 10 10 45 00 02 00 00 00 00 00 00 00 00 00 00 00 11 C6
                    ^^                                   ^^^^^
                    P1=2 (TNR)                          CRC (hardcoded)
CSV Row: 97

⚠️ IMPORTANT: DO NOT calculate CRC for output mode - always use hardcoded values from the table above.

5.2 Brightness SET

Command: Set thermal brightness level Hex Code: 0x10/0x04/0x47 CSV Rows: 162-172 (11 sample values: 0, 10, 20, ..., 100) CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): Brightness value (0-100)

Packet Structure:

code
[0]  = 0x10
[1]  = 0x04
[2]  = 0x47
[3]  = 0x00
[4]  = brightness (0-100)
[5-15] = 0x00
[16-17] = CRC (calculated)

Example: Set brightness to 50

code
Packet: 10 04 47 00 32 00 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]
                    ^^
                    P1=50 (0x32)
CSV Row: 167

5.3 Colormap SET

Command: Set color palette Hex Code: 0x10/0x03/0x45 CSV Rows: 137-148 (12 palettes) CRC Type: Dynamic (CRC-16-CCITT)

Note: Unlike Brightness and Contrast (which use P1), Colormap uses P2 (byte[5]) for the palette value. This is the camera's firmware design.

Palettes:

PaletteValueP1P2
White Hot00x000x00
Black Hot10x000x01
Rainbow40x000x04
Ironbow30x000x03
Lava20x000x02
Arctic50x000x05
Wheel160x000x06
Wheel270x000x07
Wheel380x000x08
Tyrian90x000x09
Glory100x000x0A
EnvyGreen110x000x0B

Packet Structure:

code
[0]  = 0x10
[1]  = 0x03
[2]  = 0x45
[3]  = 0x00
[4]  = 0x00 (P1: Always 0x00 per CSV)
[5]  = colormap (P2: 0-11)
[6-15] = 0x00
[16-17] = CRC (calculated)

5.4 Zoom SET

Command: Set digital zoom level Hex Code: 0x01/0x31/0x42 CSV Rows: 118-122 (5 levels: 1x, 2x, 3x, 4x, 8x) CRC Type: Dynamic (CRC-16-CCITT)

⚠️ Special Encoding: Zoom level must be multiplied by 10 before encoding.

Zoom Levels:

LevelMultiplyP2 ValueHex
1x1 × 10 = 10100x0A
2x2 × 10 = 20200x14
3x3 × 10 = 30300x1E
4x4 × 10 = 40400x28
8x8 × 10 = 80800x50

Packet Structure:

code
[0]  = 0x01
[1]  = 0x31
[2]  = 0x42
[3]  = 0x00
[4]  = 0x00 (P1: Always 0x00)
[5]  = zoom_level × 10 (P2)
[6-15] = 0x00
[16-17] = CRC (calculated)

Example: Set zoom to 2x

code
Packet: 01 31 42 00 00 14 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]
                       ^^
                       P2=20 (2×10=0x14)
CSV Row: 119

Common Mistake:

code
❌ WRONG: P2 = 2 (for 2x zoom) - Camera interprets as 0.2x zoom
✅ RIGHT: P2 = 20 (for 2x zoom) - Multiply by 10 first

5.5 Autoshutter Interval Parameters (Multi-Byte Example)

Command: Set autoshutter interval parameters Hex Code: 0x10/0x02/0x42 CSV Rows: 9-16 CRC Type: Dynamic (CRC-16-CCITT)

Multi-Byte Parameters (16-bit little-endian):

  • P1 (byte[4]): Parameter type
    • 0x00 = Temperature threshold
    • 0x01 = Minimum interval (seconds)
    • 0x02 = Maximum interval (seconds)
  • P2-P3 (bytes[5-6]): 16-bit value (little-endian)

Example: Set maximum interval to 360 seconds

code
Step 1: Convert to hex
  Decimal: 360
  Hex: 0x0168

Step 2: Encode as little-endian
  P2 = 0x68 (LSB)
  P3 = 0x01 (MSB)

Step 3: Construct packet
  Packet: 10 02 42 00 02 68 01 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]
                      ^^  ^^  ^^
                      P1  P2  P3
                      type LSB MSB

CSV Row: 12

5.6 FFC Trigger

Command: Trigger flat field calibration Hex Code: 0x10/0x02/0x43 CSV Row: 2 CRC Type: Dynamic (CRC-16-CCITT) Timeout: 5000ms (5 seconds - longest command)

Parameters: All zeros (no parameters)

Packet Structure:

code
[0]  = 0x10
[1]  = 0x02
[2]  = 0x43
[3-15] = 0x00 (All zeros)
[16-17] = CRC (calculated)

5.7 Device Name GET (Hardcoded CRC Example)

Command: Get camera device name (40-byte ASCII string) Hex Code: 0x01/0x01/0x81 CSV Row: 56 CRC Type: Hardcoded (0xFC, 0x1E) Response: 40 bytes read from register 0x1d00

Parameters:

  • P1 (byte[4]): 0x01 (Device name selector)
  • P12 (byte[15]): 0x20 (32 decimal = expected response length)

Packet Structure:

code
[0]  = 0x01
[1]  = 0x01
[2]  = 0x81
[3]  = 0x00
[4]  = 0x01 (P1: Device name)
[5-14] = 0x00
[15] = 0x20 (P12: Response length)
[16] = 0xFC (CRC LSB - hardcoded)
[17] = 0x1E (CRC MSB - hardcoded)

Complete Packet:

code
01 01 81 00 01 00 00 00 00 00 00 00 20 00 00 00 FC 1E

5.8 Open/Close Shutter

Command: Control thermal camera shutter (open = accept thermal input, close = block thermal input) Hex Code: 0x01/0x0F/0x45 (Class: Device, Module: Shutter, SubCmd: Shutter control) CSV Rows: 4-5

Operations:

OperationP1 ValueCRC (LSB, MSB)Purpose
Close0x000x8D, 0x5ABlock thermal input (shutter closed)
Open0x010xF8, 0x59Accept thermal input (shutter open)

Note: Both operations use hardcoded CRC values - do NOT calculate dynamically.

Packet Structure (18 bytes):

code
[0]  = 0x01 (Class: Device)
[1]  = 0x0F (Module: Shutter)
[2]  = 0x45 (SubCmd: Shutter control)
[3]  = 0x00 (Reserved)
[4]  = operation (0=close, 1=open)
[5-15] = 0x00 (Padding)
[16-17] = CRC (Hardcoded lookup)

Example: Open shutter

code
Packet: 01 0F 45 00 01 00 00 00 00 00 00 00 00 00 00 00 F8 59
                    ^^                                   ^^^^^
                    P1=1 (Open)                         CRC (hardcoded)
CSV Row: 5

5.9 Anti-burn Protection

Command: Enable/disable camera anti-burn protection (protects sensor from bright light damage) Hex Code: 0x10/0x03/0x4B (SET), 0x10/0x03/0x8B (GET) CSV Rows: 42-44

Settings:

SettingValueCRC (LSB, MSB)Purpose
OFF0x000x58, 0x8DDisable anti-burn protection
ON0x010x2D, 0x8EEnable anti-burn protection

GET Parameters:

  • P1: 0x00 (selector)
  • P12: 0x01 (response length = 1 byte)
  • CRC: 0x2D, 0x87 (hardcoded)

Packet Structure (SET):

code
[0]  = 0x10 (Class: Camera)
[1]  = 0x03 (Module: Display/Protection)
[2]  = 0x4B (SubCmd: Anti-burn SET)
[3]  = 0x00 (Reserved)
[4]  = setting (0=OFF, 1=ON)
[5-15] = 0x00 (Padding)
[16-17] = CRC (Hardcoded lookup)

Example: Enable anti-burn protection

code
Packet: 10 03 4B 00 01 00 00 00 00 00 00 00 00 00 00 00 2D 8E
                    ^^                                   ^^^^^
                    P1=1 (ON)                           CRC (hardcoded)
CSV Row: 43

5.10 Hook Edge Position

Command: Set edge enhancement hook position (controls where edge enhancement is applied) Hex Code: 0x10/0x04/0x4E (SET), 0x10/0x04/0x8E (GET) CSV Rows: 222-225 CRC Type: Dynamic (CRC-16-CCITT)

Positions:

PositionValueDescription
00x00No edge hook
1st Gear0x01First edge level
2 Levels0x02Two edge levels

GET Parameters:

  • P1: 0x01 (selector)
  • P12: 0x01 (response length = 1 byte)

Packet Structure (SET):

code
[0]  = 0x10 (Class: Camera)
[1]  = 0x04 (Module: Image Processing)
[2]  = 0x4E (SubCmd: Hook edge SET)
[3]  = 0x00 (Reserved)
[4]  = position (0, 1, or 2)
[5-15] = 0x00 (Padding)
[16-17] = CRC (Calculate using CRC-16-CCITT)

Example: Set hook edge position to 1st gear

code
Step 1: Construct packet
[0-2]   = 10 04 4E
[3]     = 00 (Reserved)
[4]     = 01 (P1: 1st Gear)
[5-15]  = 00 00 00 00 00 00 00 00 00 00 00

Step 2: Calculate CRC
uint16_t crc = calculate_crc(cmd, 16);

Step 3: Final packet (18 bytes)
10 04 4E 00 01 00 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]

CSV Row: 223

5.11 Detector Frame Rate

Command: Set thermal detector frame rate (frames per second) Hex Code: 0x10/0x10/0x44 (SET), 0x10/0x10/0x84 (GET) CSV Rows: 90-94 CRC Type: Dynamic (CRC-16-CCITT)

Frame Rate Options:

RateP1 ValueHexCSV Row
30 Hz0x1E3090
60 Hz0x3C6091
25 Hz0x192592
50 Hz0x325093

GET Parameters:

  • P1: 0x00 (selector)
  • P12: 0x01 (response length = 1 byte)

Packet Structure (SET):

code
[0]  = 0x10 (Class: Camera)
[1]  = 0x10 (Module: MIPI/Timing)
[2]  = 0x44 (SubCmd: Frame rate SET)
[3]  = 0x00 (Reserved)
[4]  = frame_rate (0x1E/0x3C/0x19/0x32)
[5-15] = 0x00 (Padding)
[16-17] = CRC (Calculate using CRC-16-CCITT)

Example: Set frame rate to 60 Hz

code
Step 1: Construct packet
[0-2]   = 10 10 44
[3]     = 00 (Reserved)
[4]     = 3C (P1: 60 Hz)
[5-15]  = 00 00 00 00 00 00 00 00 00 00 00

Step 2: Calculate CRC
uint16_t crc = calculate_crc(cmd, 16);

Step 3: Final packet (18 bytes)
10 10 44 00 3C 00 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]

CSV Row: 91

5.12 Digital-Analog Output Format

Command: Save/apply digital-analog output format configuration Hex Code: 0x10/0x10/0x49 CSV Row: 89 CRC Type: Hardcoded (0x35, 0xD6)

Description: Configuration command to save or apply the current digital-analog output format settings. Parameters are all zero (no configuration parameters).

Packet Structure:

code
[0]  = 0x10 (Class: Camera)
[1]  = 0x10 (Module: MIPI/Output)
[2]  = 0x49 (SubCmd: Digital-analog format)
[3-15] = 0x00 (All parameters zero)
[16] = 0x35 (CRC LSB - hardcoded)
[17] = 0xD6 (CRC MSB - hardcoded)

Complete Packet:

code
10 10 49 00 00 00 00 00 00 00 00 00 00 00 00 00 35 D6

5.13 Shutter Correction

Command: Shutter calibration (FFC - Flat Field Correction without auto-retry) Hex Code: 0x10/0x02/0x43 CSV Row: 2 CRC Type: Dynamic (CRC-16-CCITT)

Description: Performs thermal shutter calibration for sensor correction. This is the base FFC command without automatic retry logic.

Packet Structure:

code
[0]  = 0x10 (Class: Camera)
[1]  = 0x02 (Module: Shutter)
[2]  = 0x43 (SubCmd: Shutter correction)
[3-15] = 0x00 (All zeros)
[16-17] = CRC (calculated)

5.14 Background Correction

Command: Background/offset correction for thermal reference Hex Code: 0x01/0x10/0x52 CSV Row: 3 CRC Type: Dynamic (CRC-16-CCITT)

Description: Applies background offset correction to thermal measurements.

Packet Structure:

code
[0]  = 0x01 (Class: Device)
[1]  = 0x10 (Module: Background)
[2]  = 0x52 (SubCmd: Background correction)
[3-15] = 0x00 (All zeros)
[16-17] = CRC (calculated)

5.15 Autoshutter Temperature Parameter

Command: Set autoshutter temperature threshold Hex Code: 0x10/0x02/0x42 CSV Rows: 9-10 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x00 (temperature threshold type)
  • P2 (byte[5]): Temperature value (0-255)

Options:

SettingTemperatureP2 ValueCSV Row
10°C100x0A9
50°C500x3210

5.16 Autoshutter Minimum Interval Time

Command: Set minimum autoshutter interval (seconds) Hex Code: 0x10/0x02/0x42 CSV Rows: 11-12 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x01 (minimum interval type)
  • P2-P3 (bytes[5-6]): 16-bit value (little-endian, seconds)

Options:

SettingValueP2P3CSV Row
1 second10x010x0011
120 seconds1200x780x0012

5.17 Autoshutter Maximum Interval Time

Command: Set maximum autoshutter interval (seconds) Hex Code: 0x10/0x02/0x42 CSV Rows: 13-14 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x02 (maximum interval type)
  • P2-P3 (bytes[5-6]): 16-bit value (little-endian, seconds)

Options:

SettingValueP2P3CSV Row
120 seconds1200x780x0013
360 seconds3600x680x0114

5.18 Autoshutter Get Temperature

Command: Get current autoshutter temperature threshold Hex Code: 0x10/0x02/0x82 CSV Row: 15 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x00 (temperature selector)
  • P12 (byte[15]): 0x02 (response length = 2 bytes)

5.19 Autoshutter Get Minimum Interval

Command: Get current autoshutter minimum interval Hex Code: 0x10/0x02/0x82 CSV Row: 16 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x01 (minimum interval selector)
  • P12 (byte[15]): 0x02 (response length = 2 bytes)

5.20 Calibration K Value Commands

Command Series: K-value calibration sequence Hex Code: 0x10/0x11/0x41 (collect), 0x10/0x11/0x42 (cancel), 0x10/0x11/0x43 (save), 0x10/0x11/0x44 (clear), 0x10/0x11/0x45 (restore) CSV Rows: 17-23 CRC Type: Dynamic (CRC-16-CCITT)

Operations:

OperationHex CodeP1PurposeCSV Row
Collect Low Temperature0x10/0x11/0x410x00Capture low reference point17
Collect High Temperature0x10/0x11/0x410x01Capture high reference point18
Collection & Calculation0x10/0x11/0x410x02Process calibration data19
Save K Value0x10/0x11/0x430x00Persist calibration20
Cancel Calibration0x10/0x11/0x420x00Discard calibration21
Clear K Value0x10/0x11/0x440x00Clear stored calibration22
Restore Factory K Value0x10/0x11/0x450x00Restore default calibration23

5.21 Blind Element (Defective Pixel) Calibration

Command Series: Blind element (dead pixel) calibration Hex Code: 0x10/0x11/0x51 through 0x10/0x11/0x56 CSV Rows: 24-35 CRC Type: Dynamic (CRC-16-CCITT)

Key Operations:

OperationHex CodePurposeCSV Rows
Automatic blind calibration0x10/0x11/0x51Auto-detect bad pixels24
Cursor switch enable0x10/0x11/0x57 P1=0x01Enable cursor marking25
Cursor switch disable (blanking)0x10/0x11/0x57 P1=0x00Disable cursor26
Cursor switch acquisition0x10/0x11/0x81Query cursor state27
Cursor position setting0x10/0x11/0x58Set cursor XY coordinates28
Get cursor position0x10/0x11/0x82Read cursor location29
Set blind pixel (manual)0x10/0x11/0x52 P1=0x00Mark pixel as blind30
Set non-blind pixel (manual)0x10/0x11/0x52 P1=0x01Mark pixel as good31
Cancel calibration0x10/0x11/0x53Discard blind calibration32
Save blind data0x10/0x11/0x54Persist calibration33
Clear blind data0x10/0x11/0x55Clear stored data34
Restore factory blind data0x10/0x11/0x56Reset to defaults35

Note: Cursor position uses multi-byte XY encoding:

  • P2-P3: X coordinate (16-bit little-endian)
  • P4-P5: Y coordinate (16-bit little-endian)

5.22 Pot Lid (Shutter) Calibration

Command Series: Thermal shutter lid calibration Hex Code: 0x10/0x11/0x61 through 0x10/0x11/0x65 CSV Rows: 36-40 CRC Type: Dynamic (CRC-16-CCITT)

Operations:

OperationHex CodePurposeCSV Row
Calibration lid0x10/0x11/0x61Start lid calibration36
Save lid0x10/0x11/0x63Store calibration data37
Cancel results0x10/0x11/0x62Discard calibration38
Empty the lid0x10/0x11/0x64Clear lid data39
Restore factory data0x10/0x11/0x65Reset to defaults40

5.23 System Features - Firmware Update

Command: Initiate firmware update mode Hex Code: 0x01/0x01/0x42 CSV Row: 41 CRC Type: Dynamic (CRC-16-CCITT)

Description: Prepares camera for firmware update via I2C.

5.24 System Features - Sleep Control

Command: Control camera module sleep state Hex Code: 0x10/0x10/0x48 (SET), 0x10/0x10/0x88 (GET) CSV Rows: 45-47 CRC Type: Dynamic (CRC-16-CCITT)

Operations:

OperationP1 ValueCSV Row
Wake up (wake)0x0045
Sleep (sleep)0x0146
Get state0x00 (P12=0x01)47

5.25 System Features - Boot Logo

Command: Control boot logo display Hex Code: 0x10/0x10/0x41 (SET), 0x10/0x10/0x81 (GET) CSV Rows: 48-50 CRC Type: Dynamic (CRC-16-CCITT)

Operations:

OperationP1 ValueCSV Row
Disable logo0x0048
Enable logo0x0149
Get state0x00 (P12=0x01)50

5.26 System Features - DVP/I2C Voltage Switching

Command: Switch between DVP and I2C communication voltage levels Hex Code: 0x10/0x10/0x47 (SET), 0x10/0x10/0x87 (GET) CSV Rows: 51-53 CRC Type: Dynamic (CRC-16-CCITT)

Voltage Options:

VoltageP1 ValueCSV Row
1.8V0x0051
3.3V0x0152
Get voltage0x00 (P12=0x01)53

5.27 System Features - Parameter Save/Restore

Command: Manage parameter persistence Hex Code: 0x10/0x10/0x51 (preserve), 0x10/0x10/0x52 (recover) CSV Rows: 54-55 CRC Type: Dynamic (CRC-16-CCITT)

Operations:

OperationHex CodePurposeCSV Row
Parameter preservation0x10/0x10/0x51Save current settings54
Parameter recovery0x10/0x10/0x52Load saved settings55

5.28 Device Information - Module Temperature & Environment

Command: Get module/environmental data Hex Code: 0x10/0x10/0x91 (temperature), 0x10/0x10/0x92 (hot spot coords), 0x10/0x10/0x93 (power-on time) CSV Rows: 62-65 CRC Type: Dynamic (CRC-16-CCITT)

Commands:

CommandHex CodeResponseCSV Row
Get module temperature0x10/0x10/0x912 bytes (temp)62
Get hottest spot coordinates0x10/0x10/0x924 bytes (X,Y)63-64
Get power-on time0x10/0x10/0x934 bytes (seconds)65

Note: Hottest spot commands include area of interest parameters (AOI bounds).

5.29 Video Output - Digital Format Commands

Command: Configure digital video output format (USB, DVP, BT656, MIPI) Hex Code: 0x10/0x10/0x46 CSV Rows: 66-83 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x01 (enable) or 0x00 (disable output)
  • P2 (byte[5]): Interface type (0=USB, 1=DVP, 2=BT656, 3=MIPI)
  • P3 (byte[6]): Frame rate (0x1E=30Hz, 0x3C=60Hz, 0x19=25Hz, 0x32=50Hz)

Format Combinations:

FormatP1P2P3Frame RateCSV Rows
USB-Progressive0x010x000x1E30Hz66
USB-Progressive0x010x000x3C60Hz67
DVP-Progressive0x010x010x1E30Hz68
DVP-Progressive0x010x010x3C60Hz69
BT656-Progressive0x010x020x1E30Hz70
BT656-Progressive0x010x020x3C60Hz71
BT656-Interlaced0x010x020x1225Hz72
MIPI-Progressive0x010x030x1E30Hz73
MIPI-Progressive0x010x030x3C60Hz74
(Mini2 256 variants).........25/50Hz75-82
Output disable0x000x000x00N/A83

5.30 Video Output - Get Format Configuration

Command: Query current digital output format Hex Code: 0x10/0x10/0x86 CSV Row: 84 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x00 (selector)
  • P12 (byte[15]): 0x04 (response = 4 bytes)

Response: Interface, frame rate, and status bytes

5.31 Video Output - Analog Format Commands

Command: Control analog video output (NTSC/PAL) Hex Code: 0x10/0x10/0x4A (SET), 0x10/0x10/0x8A (GET) CSV Rows: 85-88 CRC Type: Dynamic (CRC-16-CCITT)

Options:

OptionP1 ValueP2 ValueCSV Row
Enable NTSC0x010x0085
Enable PAL0x010x0186
Disable analog0x000x0087
Get status0x00 (P12=0x02)N/A88

5.32 Video Output - YUV Format Selection

Command: Select YUV color component ordering Hex Code: 0x10/0x03/0x4D (SET), 0x10/0x03/0x8C (GET) CSV Rows: 102-106 CRC Type: Dynamic (CRC-16-CCITT)

YUV Formats:

FormatP1 ValueDescriptionCSV Row
UYVY0x00U-Y-V-Y ordering102
VYUY0x01V-Y-U-Y ordering103
YUYV0x02Y-U-Y-V ordering104
YVYU0x03Y-V-Y-U ordering105
Get status0x00 (P12=0x01)N/A106

5.33 Video Output - Screen Freeze Control

Command: Freeze/unfreeze video output display Hex Code: 0x10/0x10/0x42 (SET), 0x10/0x10/0x82 (GET) CSV Rows: 107-109 CRC Type: Dynamic (CRC-16-CCITT)

Options:

OptionP1 ValueCSV Row
Disable freeze0x00107
Enable freeze0x01108
Get state0x00 (P12=0x01)109

5.34 Video Output - Mirror/Flip Control

Command: Control image orientation (horizontal/vertical flip) Hex Code: 0x10/0x10/0x43 (SET), 0x10/0x10/0x83 (GET) CSV Rows: 110-114 CRC Type: Dynamic (CRC-16-CCITT)

Flip Modes:

ModeP1 ValueDescriptionCSV Row
No flip0x00Original orientation110
Flip left-right0x01Mirror horizontally111
Flip upside down0x02Mirror vertically112
Both (L-R + U-D)0x03180° rotation113
Get state0x00 (P12=0x01)N/A114

5.35 Video Output - External Synchronization Mode

Command: Enable external sync for multi-camera setups Hex Code: 0x10/0x10/0x4B (SET), 0x10/0x10/0x8B (GET) CSV Rows: 115-117 CRC Type: Dynamic (CRC-16-CCITT)

Options:

OptionP1 ValueCSV Row
Enable external sync0x01115
Disable external sync0x00116
Get state0x00 (P12=0x01)117

5.36 Electronic Zoom - Center Position

Command: Center-point digital zoom (1x, 2x, 3x, 4x, 8x) Hex Code: 0x01/0x31/0x42 (SET), 0x01/0x31/0x82 (GET) CSV Rows: 118-123 CRC Type: Dynamic (CRC-16-CCITT)

Zoom Levels (note: P2 = zoom × 10):

Zoom LevelP2 ValueDescriptionCSV Row
1x (no zoom)0x0A10 decimal118
2x0x1420 decimal119
3x0x1E30 decimal120
4x0x2840 decimal121
8x0x5080 decimal122
Get zoom0x00 (P12=0x01)N/A123

5.37 Electronic Zoom - Area of Interest (Coordinates)

Command: Zoom to specific image coordinates with custom zoom level Hex Code: 0x01/0x31/0x51 (SET), 0x01/0x31/0x91 (GET) CSV Rows: 124-125 CRC Type: Dynamic (CRC-16-CCITT)

Parameters:

  • P1 (byte[4]): 0x00 (reserved)
  • P2-P3 (bytes[5-6]): X coordinate (16-bit little-endian)
  • P4-P5 (bytes[7-8]): Y coordinate (16-bit little-endian)
  • P6-P7 (bytes[9-10]): Zoom factor × 100 (16-bit little-endian)

Example (CSV Row 124): Position (300, 280), 2.1× zoom

  • P2-P3: 0x2C 0x01 (300)
  • P4-P5: 0x18 0x01 (280)
  • P6-P7: 0x15 0x00 (21 = 2.1 × 10)

GET Response: 5 bytes (X LSB, X MSB, Y LSB, Y MSB, zoom)

5.38 Scene Mode - All Modes

Command: Apply scene optimization preset Hex Code: 0x10/0x04/0x42 (SET), 0x10/0x04/0x89 (GET) CSV Rows: 126-136 CRC Type: Dynamic (CRC-16-CCITT)

Scene Modes:

ModeP1 ValueDescriptionCSV Row
Low Temperature Protrusion0x00Enhanced low temp126
Linear Stretch0x01Linear histogram127
Low Contrast0x02Dark scenes128
General Mode (Default)0x03Balanced129
High Contrast0x04Bright scenes130
Highlight0x05Extreme highlights131
Reserve 10x06Reserved132
Reserve 20x07Reserved133
Reserve 30x08Reserved134
Outline Mode0x09Edge detection135
Get mode0x00 (P12=0x01)N/A136

5.39 False Color (Colormap) - Extended Reference

Command: Select false color palette (12 options total) Hex Code: 0x10/0x03/0x45 (SET), 0x10/0x03/0x85 (GET) CSV Rows: 137-149 CRC Type: Dynamic (CRC-16-CCITT)

All Palettes (P2 parameter):

PaletteP1P2DescriptionCSV Row
White Hot0x000x00White to black gradient137
Reserved0x000x01Reserved palette138
Gold Sepia0x000x02Gold to brown139
Ironbow0x000x03Iron to rainbow140
Rainbow0x000x04Full spectrum141
Night0x000x05Night vision green142
Aurora0x000x06Aurora (purple-green)143
Red_Hot0x000x07Red hot metal144
Jungle0x000x08Green jungle145
Medical0x000x09Medical blue-red146
Black_Hot0x000x0ABlack to white147
Glory Hot0x000x0BGolden glory148
Get palette0x00N/A (P12=0x01)N/A149

5.40 Detail Enhancement (DDE) - All Levels

Command: Digital detail enhancement (0-100 in 10% steps) Hex Code: 0x10/0x04/0x45 (SET), 0x10/0x04/0x85 (GET) CSV Rows: 150-161 CRC Type: Dynamic (CRC-16-CCITT)

Enhancement Levels (P1 = 0-100, step 10):

LevelP1 ValueCSV Row
00x00150
100x0A151
200x14152
300x1E153
400x28154
500x32155
600x3C156
700x46157
800x50158
900x5A159
1000x64160
Get level0x00 (P12=0x01)161

5.41 Contrast - All Levels

Command: Image contrast adjustment (0-100 in 10% steps) Hex Code: 0x10/0x04/0x4A (SET), 0x10/0x04/0x8A (GET) CSV Rows: 174-185 CRC Type: Dynamic (CRC-16-CCITT)

Contrast Levels (P1 = 0-100, step 10):

LevelP1 ValueCSV Row
00x00174
100x0A175
200x14176
300x1E177
400x28178
500x32179
600x3C180
700x46181
800x50182
900x5A183
1000x64184
Get level0x00 (P12=0x01)185

5.42 Spatial Noise Reduction (SNR) - All Levels

Command: Spatial/airspace noise reduction (0-100 in 10% steps) Hex Code: 0x10/0x04/0x4B (SET), 0x10/0x04/0x8B (GET) CSV Rows: 186-197 CRC Type: Dynamic (CRC-16-CCITT)

Noise Reduction Levels (P1 = 0-100, step 10):

LevelP1 ValueCSV Row
00x00186
100x0A187
200x14188
300x1E189
400x28190
500x32191
600x3C192
700x46193
800x50194
900x5A195
1000x64196
Get level0x00 (P12=0x01)197

5.43 Temporal Noise Reduction (TNR) - All Levels

Command: Temporal/frame-to-frame noise reduction (0-100 in 10% steps) Hex Code: 0x10/0x04/0x4C (SET), 0x10/0x04/0x8C (GET) CSV Rows: 198-209 CRC Type: Dynamic (CRC-16-CCITT)

Noise Reduction Levels (P1 = 0-100, step 10):

LevelP1 ValueCSV Row
00x00198
100x0A199
200x14200
300x1E201
400x28202
500x32203
600x3C204
700x46205
800x50206
900x5A207
1000x64208
Get level0x00 (P12=0x01)209

5.44 Gamma Intensity - All Levels

Command: Gamma curve adjustment (0-100 in 10% steps) Hex Code: 0x10/0x04/0x4D (SET), 0x10/0x04/0x8D (GET) CSV Rows: 210-221 CRC Type: Dynamic (CRC-16-CCITT)

Gamma Levels (P1 = 0-100, step 10):

LevelP1 ValueCSV Row
00x00210
100x0A211
200x14212
300x1E213
400x28214
500x32215
600x3C216
700x46217
800x50218
900x5A219
1000x64220
Get level0x00 (P12=0x01)221

6. CRC Calculation & Lookup

6.1 Dynamic CRC (CRC-16-CCITT)

Used by: Most commands (Brightness, Colormap, Contrast, Zoom, FFC, etc.)

Algorithm: CRC-16-CCITT

  • Polynomial: 0x1021
  • Initial value: 0xFFFF
  • Input: Bytes [0-15] of packet
  • Output: 16-bit CRC appended as [16]=LSB, [17]=MSB

C Implementation (from rs300.c:164-182):

c
static uint16_t calculate_crc(const uint8_t *data, size_t len) {
    uint16_t crc = 0xFFFF;
    size_t i, j;

    for (i = 0; i < len; i++) {
        crc ^= (uint16_t)data[i] << 8;
        for (j = 0; j < 8; j++) {
            if (crc & 0x8000)
                crc = (crc << 1) ^ 0x1021;
            else
                crc = crc << 1;
        }
    }
    return crc;
}

Usage:

c
uint8_t cmd[18];
// ... fill cmd[0-15] with command and parameters ...
uint16_t crc = calculate_crc(cmd, 16);
cmd[16] = crc & 0xFF;        // LSB
cmd[17] = (crc >> 8) & 0xFF; // MSB

6.2 Hardcoded CRC Lookup Tables

Used by: Output Mode commands, Device Info GET commands

6.2.1 Output Mode CRC Table (Command: 0x10/0x10/0x45)

ModeValue (P1)CRC LSB (byte[16])CRC MSB (byte[17])CSV Row
IR0x000xFB0xC095
KBC0x010x8E0xC396
TNR0x020x110xC697
SNR0x030x640xC598
DDE0x040x2F0xCD99
YUV0x050x5A0xCE100

Implementation Example:

c
static const uint8_t output_mode_crc[6][2] = {
    {0xFB, 0xC0}, // Mode 0: IR
    {0x8E, 0xC3}, // Mode 1: KBC
    {0x11, 0xC6}, // Mode 2: TNR
    {0x64, 0xC5}, // Mode 3: SNR
    {0x2F, 0xCD}, // Mode 4: DDE
    {0x5A, 0xCE}, // Mode 5: YUV
};

// Usage:
cmd[16] = output_mode_crc[mode][0]; // LSB
cmd[17] = output_mode_crc[mode][1]; // MSB

6.2.2 Device Info GET CRC Table (Command: 0x01/0x01/0x81)

Info TypeP1 ValueP12 ValueCRC LSBCRC MSBCSV Row
Device Name0x010x200xFC0x1E56
FW Version0x020x0B0x320x3257
VID0x040x020x7B0xCA58
PID0x050x020x0E0xC959
PN0x060x200xB70x1660
SN0x070x200xC20x1561

6.2.3 Shutter Control CRC Table (Command: 0x01/0x0F/0x45)

OperationP1 ValueCRC LSBCRC MSBCSV Row
Close Shutter0x000x8D0x5A4
Open Shutter0x010xF80x595

Implementation Example:

c
static const uint8_t shutter_crc[2][2] = {
    {0x8D, 0x5A}, // Close shutter
    {0xF8, 0x59}, // Open shutter
};

// Usage:
cmd[16] = shutter_crc[operation][0]; // LSB
cmd[17] = shutter_crc[operation][1]; // MSB

6.2.4 Anti-burn Protection CRC Table (Command: 0x10/0x03/0x4B SET, 0x10/0x03/0x8B GET)

SET Commands:

SettingP1 ValueCRC LSBCRC MSBCSV Row
OFF0x000x580x8D42
ON0x010x2D0x8E43

GET Command (0x10/0x03/0x8B):

  • CRC: 0x2D, 0x87 (fixed, CSV Row 44)

Implementation Example:

c
static const uint8_t antiburn_crc[2][2] = {
    {0x58, 0x8D}, // OFF
    {0x2D, 0x8E}, // ON
};

static const uint8_t antiburn_get_crc[2] = {0x2D, 0x87}; // GET command

// Usage (SET):
cmd[16] = antiburn_crc[setting][0]; // LSB
cmd[17] = antiburn_crc[setting][1]; // MSB

// Usage (GET):
cmd[16] = antiburn_get_crc[0]; // LSB
cmd[17] = antiburn_get_crc[1]; // MSB

6.2.5 Digital-Analog Output Format CRC (Command: 0x10/0x10/0x49)

CommandCRC LSBCRC MSBCSV Row
Digital-Analog Output0x350xD689

This is a single fixed command with no variants, so the CRC is simply hardcoded as shown above.

6.2.6 Sleep Control CRC Table (Command: 0x10/0x10/0x48 SET, 0x10/0x10/0x88 GET)

SET Commands:

OperationP1 ValueCRC LSBCRC MSBCSV Row
Wake up0x000x540xAD45
Sleep0x010x210xAE46

GET Command (0x10/0x10/0x88):

  • CRC: 0x21, 0xA7 (fixed, CSV Row 47)

6.2.7 Boot Logo CRC Table (Command: 0x10/0x10/0x41 SET, 0x10/0x10/0x81 GET)

SET Commands:

OperationP1 ValueCRC LSBCRC MSBCSV Row
Disable0x000x5E0x3D48
Enable0x010x2B0x3E49

GET Command (0x10/0x10/0x81):

  • CRC: 0x2B, 0x37 (fixed, CSV Row 50)

6.2.8 DVP/I2C Voltage Switching CRC Table (Command: 0x10/0x10/0x47 SET, 0x10/0x10/0x87 GET)

SET Commands:

VoltageP1 ValueCRC LSBCRC MSBCSV Row
1.8V0x000x390x3651
3.3V0x010x4C0x3552

GET Command (0x10/0x10/0x87):

  • CRC: 0x4C, 0x3C (fixed, CSV Row 53)

6.2.9 Parameter Save/Restore CRC Table

Preservation (0x10/0x10/0x51):

  • CRC: 0xA9, 0xFB (CSV Row 54)

Recovery (0x10/0x10/0x52):

  • CRC: 0x0A, 0x76 (CSV Row 55)

7. Working Examples (End-to-End)

Example 1: Set Brightness to 50

Goal: Set thermal brightness to 50% CSV Row: 167

Step 1: Construct packet

code
[0-2]   = 10 04 47 (Hex code)
[3]     = 00 (Reserved)
[4]     = 32 (P1: 50 decimal = 0x32)
[5-15]  = 00 00 00 00 00 00 00 00 00 00 00 (Padding)

Step 2: Calculate CRC over bytes [0-15]

c
uint16_t crc = calculate_crc(cmd, 16);
cmd[16] = crc & 0xFF;        // LSB
cmd[17] = (crc >> 8) & 0xFF; // MSB

Step 3: Final packet (18 bytes)

code
10 04 47 00 32 00 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]

Step 4: Execute

  1. Write 18 bytes to I2C register 0x1d00
  2. Poll register 0x0200 every 50ms until busy bit clears (timeout: 500ms)
  3. Check error bit (bit 1): 0=success

Example 2: Set Output Mode to TNR (Mode 2)

Goal: Enable temporal noise reduction processing CSV Row: 97

Step 1: Construct packet

code
[0-2]   = 10 10 45 (Hex code - I2C protocol)
[3]     = 00 (Reserved)
[4]     = 02 (P1: TNR mode)
[5-15]  = 00 00 00 00 00 00 00 00 00 00 00 (Padding)

Step 2: Use hardcoded CRC (DO NOT calculate)

code
cmd[16] = 0x11; // LSB (from lookup table)
cmd[17] = 0xC6; // MSB (from lookup table)

Step 3: Final packet (18 bytes)

code
10 10 45 00 02 00 00 00 00 00 00 00 00 00 00 00 11 C6

Step 4: Execute

  1. Write 18 bytes to I2C register 0x1d00
  2. Poll register 0x0200 every 50ms until busy bit clears (timeout: 500ms)
  3. Check error bit: 0=success

Verification: Compare against CSV row 97 - packet should match exactly.

Example 3: Set Autoshutter Max Interval to 360 Seconds

Goal: Configure autoshutter maximum interval (multi-byte parameter) CSV Row: 12

Step 1: Encode 360 seconds as little-endian

code
Decimal: 360
Hex: 0x0168
Little-endian: P2=0x68 (LSB), P3=0x01 (MSB)

Step 2: Construct packet

code
[0-2]   = 10 02 42 (Hex code)
[3]     = 00 (Reserved)
[4]     = 02 (P1: Maximum interval type)
[5]     = 68 (P2: LSB of 360)
[6]     = 01 (P3: MSB of 360)
[7-15]  = 00 00 00 00 00 00 00 00 00 (Padding)

Step 3: Calculate CRC

c
uint16_t crc = calculate_crc(cmd, 16);
cmd[16] = crc & 0xFF;
cmd[17] = (crc >> 8) & 0xFF;

Step 4: Final packet

code
10 02 42 00 02 68 01 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]

Step 5: Execute and verify against CSV row 12

Example 4: Trigger FFC (Flat Field Calibration)

Goal: Execute shutter calibration (longest timeout command) CSV Row: 2

Step 1: Construct packet (all zeros except hex code)

code
[0-2]   = 10 02 43 (Hex code)
[3-15]  = 00 00 00 00 00 00 00 00 00 00 00 00 00 (All zeros)

Step 2: Calculate CRC

c
uint16_t crc = calculate_crc(cmd, 16);
cmd[16] = crc & 0xFF;
cmd[17] = (crc >> 8) & 0xFF;

Step 3: Final packet

code
10 02 43 00 00 00 00 00 00 00 00 00 00 00 00 00 [CRC_L] [CRC_H]

Step 4: Execute with extended timeout

  1. Write 18 bytes to I2C register 0x1d00
  2. Poll register 0x0200 every 50ms until busy bit clears (timeout: 5000ms)
  3. Check error bit: 0=success

Note: FFC takes several seconds - use longer timeout (5000ms).

Example 5: Get Device Name (Multi-Byte Response)

Goal: Read 40-byte device name ASCII string CSV Row: 56

Step 1: Construct packet with hardcoded CRC

code
[0-2]   = 01 01 81 (Hex code)
[3]     = 00 (Reserved)
[4]     = 01 (P1: Device name selector)
[5-14]  = 00 00 00 00 00 00 00 00 00 00 (Padding)
[15]    = 20 (P12: Response length = 32 decimal)
[16]    = FC (CRC LSB - hardcoded)
[17]    = 1E (CRC MSB - hardcoded)

Step 2: Final packet

code
01 01 81 00 01 00 00 00 00 00 00 00 20 00 00 00 FC 1E

Step 3: Execute with multi-byte read

  1. Write 18 bytes to I2C register 0x1d00
  2. Poll register 0x0200 every 50ms until busy bit clears (timeout: 250ms)
  3. Check error bit: 0=success
  4. Read 40 bytes from I2C register 0x1d00 (device name response)

Step 4: Parse response as ASCII string (40 bytes)


8. Common Mistakes & Prevention

Mistake 1: Wrong Parameter Byte Position

code
❌ WRONG: Setting brightness at byte[5] instead of byte[4]
   Packet: 10 04 47 00 00 32 ... (brightness at P2)
   Error: Camera ignores parameter or uses default

✅ RIGHT: Setting brightness at byte[4]
   Packet: 10 04 47 00 32 00 ... (brightness at P1)
   Success: Brightness set correctly

Mistake 2: Forgetting CRC Calculation

code
❌ WRONG: Leaving CRC bytes as 0x00
   Packet: 10 04 47 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00
   Error: Camera rejects command (CRC mismatch)

✅ RIGHT: Calculating and appending CRC
   Packet: 10 04 47 00 32 00 00 00 00 00 00 00 00 00 00 00 [CRC] [CRC]
   Success: Command accepted

Mistake 3: Insufficient Polling Delay

code
❌ WRONG: Polling too fast (every 1ms)
   Error: I2C bus overload, commands may fail

✅ RIGHT: Polling every 50ms with appropriate timeout
   Success: Reliable command execution

Mistake 4: Zoom Level Not Multiplied by 10

code
❌ WRONG: Setting zoom P2=2 for 2x zoom
   Packet: 01 31 42 00 00 02 ... (P2=2)
   Error: Camera interprets as 0.2x zoom (wrong)

✅ RIGHT: Setting zoom P2=20 (2 × 10)
   Packet: 01 31 42 00 00 14 ... (P2=0x14=20)
   Success: 2x zoom correctly applied

Mistake 5: Calculating CRC for Output Mode

code
❌ WRONG: Dynamically calculating CRC for output mode
   uint16_t crc = calculate_crc(cmd, 16); // Wrong CRC value
   Error: Camera rejects command

✅ RIGHT: Using hardcoded CRC from lookup table
   cmd[16] = 0x11; // TNR mode CRC LSB
   cmd[17] = 0xC6; // TNR mode CRC MSB
   Success: Command accepted

Mistake 6: Wrong Reserved Byte Value

code
❌ WRONG: Setting byte[3] to 0x12 or non-zero
   Packet: 10 04 47 12 32 ... (reserved = 0x12)
   Error: Undefined behavior, may reject command

✅ RIGHT: Always setting byte[3] to 0x00
   Packet: 10 04 47 00 32 ... (reserved = 0x00)
   Success: Standard protocol followed

Mistake 7: Multi-Byte Parameters as Big-Endian

code
❌ WRONG: Encoding 360 as big-endian (MSB first)
   P2 = 0x01 (MSB), P3 = 0x68 (LSB)
   Error: Camera interprets as 392 (0x0168 → 0x0168)

✅ RIGHT: Encoding 360 as little-endian (LSB first)
   P2 = 0x68 (LSB), P3 = 0x01 (MSB)
   Success: Camera interprets correctly as 360

9. Verification Checklist

Before sending any I2C command, verify:

  • Hex code matches CSV row number - Cross-check command hex against CSV source
  • Packet is exactly 18 bytes - Count all bytes (NOT 23 bytes)
  • Byte [0] is 0x10 or 0x01 - Verify correct I2C class (NOT 0x55)
  • Byte [3] (reserved) is 0x00 - Must always be zero
  • Parameters at correct positions - P1=byte[4], P2=byte[5], etc. per CSV
  • CRC type correct - Dynamic (calculate) vs Hardcoded (lookup table)
  • Timeout value appropriate - FFC=5000ms, Device Info=250ms, others=500ms
  • Multi-byte values use little-endian - LSB first, MSB second
  • Zoom levels multiplied by 10 - 2x zoom = P2=20, not P2=2
  • Poll 0x0200 until busy bit clears - Check busy bit before reading response

10. Execution Flow

10.1 Standard Command Execution (SET Commands)

  1. Construct packet (18 bytes)

    • Set class, module, subCmd (bytes [0-2])
    • Set reserved byte to 0x00 (byte [3])
    • Set parameters (bytes [4-15])
    • Calculate or lookup CRC (bytes [16-17])
  2. Write packet to I2C register 0x1d00

    c
    i2c_write_block(client, 0x1d00, cmd, 18);
    
  3. Poll status register 0x0200 until busy bit clears

    c
    timeout = get_timeout_for_command(cmd);
    do {
        status = i2c_read_byte(client, 0x0200);
        if (!(status & 0x01)) break; // Busy bit cleared
        msleep(50); // Wait 50ms
    } while (time_elapsed < timeout);
    
  4. Check error bit (bit 1 of status byte)

    c
    if (status & 0x02) {
        return -EIO; // Command failed
    }
    return 0; // Command succeeded
    

10.2 GET Command Execution (Single-Byte Response)

1-3. Same as SET commands (construct, write, poll)

  1. Read response byte from register 0x1d00 + offset
    c
    value = i2c_read_byte(client, 0x1d04); // byte[4] of response
    

10.3 GET Command Execution (Multi-Byte Response)

1-3. Same as SET commands (construct, write, poll)

  1. Read response buffer from register 0x1d00
    c
    response_len = cmd[15]; // P12 specifies length
    i2c_read_block(client, 0x1d00, response, response_len);
    

11. CSV Cross-Reference

Primary Source of Truth: .claude/skills/i2c-commands/Mini2_I2C_full_commands.csv

All commands in this skill are verified against specific CSV rows. When in doubt, always check the CSV.

Key CSV Row Ranges:

  • Shutter Correction: Row 2 (FFC trigger)
  • Background Correction: Row 3 (Background offset)
  • Shutter Control: Rows 4-5 (Close/Open operations)
  • Autoshutter Parameters: Rows 6-16 (Temperature, intervals, GET)
  • K-Value Calibration: Rows 17-23 (Collect, save, clear, restore)
  • Blind Element Calibration: Rows 24-35 (Auto, cursor, manual marking, save)
  • Pot Lid Calibration: Rows 36-40 (Calibration, save, clear, restore)
  • Firmware Update: Row 41 (Update mode)
  • Anti-burn Protection: Rows 42-44 (OFF, ON, GET)
  • Sleep Control: Rows 45-47 (SET wake/sleep + GET)
  • Boot Logo: Rows 48-50 (Disable, Enable, GET)
  • DVP/I2C Voltage: Rows 51-53 (1.8V, 3.3V, GET)
  • Parameter Save/Restore: Rows 54-55 (Preserve, recover)
  • Device Info: Rows 56-61 (Name, FW, VID, PID, PN, SN)
  • Module Information: Rows 62-65 (Temperature, hot spot, power-on time)
  • Digital Video Formats: Rows 66-83 (USB, DVP, BT656, MIPI, disable)
  • Digital Format GET: Row 84 (Query format)
  • Analog Video Formats: Rows 85-88 (NTSC, PAL, disable, GET)
  • Digital-Analog Output Format: Row 89 (Configuration save)
  • Detector Frame Rate: Rows 90-94 (30Hz, 60Hz, 25Hz, 50Hz + GET)
  • Output Mode: Rows 95-101 (6 modes + GET)
  • YUV Format: Rows 102-106 (UYVY, VYUY, YUYV, YVYU, GET)
  • Screen Freeze: Rows 107-109 (Disable, Enable, GET)
  • Mirror/Flip: Rows 110-114 (No flip, H-flip, V-flip, Both, GET)
  • External Sync: Rows 115-117 (Enable, Disable, GET)
  • Electronic Zoom Center: Rows 118-123 (1x, 2x, 3x, 4x, 8x, GET)
  • Electronic Zoom AOI: Rows 124-125 (Set coordinates, GET)
  • Scene Mode: Rows 126-136 (10 scene modes + GET)
  • Colormap: Rows 137-149 (12 color palettes + GET)
  • DDE (Digital Detail Enhancement): Rows 150-161 (11 values + GET)
  • Brightness: Rows 162-173 (11 values + GET)
  • Contrast: Rows 174-185 (11 values + GET)
  • SNR (Spatial Noise Reduction): Rows 186-197 (11 values + GET)
  • TNR (Temporal Noise Reduction): Rows 198-209 (11 values + GET)
  • Gamma Intensity: Rows 210-221 (11 values + GET)
  • Hook Edge Position: Rows 222-225 (3 positions + GET)

12. Related Documentation

Primary References:

  • This Skill: .claude/skills/i2c-commands/SKILL.md (Complete I2C reference)
  • CSV Source: .claude/skills/i2c-commands/Mini2_I2C_full_commands.csv (Single source of truth)
  • Quick Reference: .claude/skills/i2c-commands/QUICK_REFERENCE.txt (Terminal cheat sheet)

Driver Implementation:

  • rs300.c: Lines 164-2850
    • CRC function: 164-182
    • I2C command wrapper: 288-403
    • Output mode: 911-951

Additional Documentation:

  • I2C Protocol Guide: docs/reference/I2C_PROTOCOL.md (550 lines, detailed protocol)
  • Quick Reference: docs/reference/I2C_QUICK_REFERENCE.md (Human-readable tables)
  • Troubleshooting: docs/reference/TROUBLESHOOTING.md (I2C debugging section)

Error Documentation:

  • Output Mode Error: .claude/lessons-learned/004-i2c-skill-output-mode-error.md (Root cause analysis)

End of RS300 I2C Commands Skill

Last Updated: 2025-10-30 Status: COMPREHENSIVE - All 225+ I2C commands from CSV documented Documentation Coverage: 45+ unique I2C commands across 11 categories Detailed Command Sections: 44 detailed specifications (sections 5.1-5.44) CRC Tables: 9 hardcoded CRC lookup tables documented All CSV Rows: 2-225 mapped to command categories and specifications