C API Snippets
This directory contains C API documentation snippets for the Stark SDK, organized by functionality.
File Organization
Core Device Management
auto_detect.h- Auto-detection functions for Revo1/Revo2 devicesdevice_handler.h- Device handler creation and managementdevice_info.h- Device information, voltage, baudrate settingsdevice_helpers.h- Helper functions (serial number parsing)device_settings.h- Device settings (slave ID, LED, buzzer, vibration, calibration, reset)
Connection Protocols
modbus_revo1.h- Modbus connection for Revo1modbus_revo2.h- Modbus connection for Revo2canfd.h- CANFD initializationethercat.h- EtherCAT master controlmodbus/device.h- Modbus device operations with auto-detectmodbus/finger_status.h- Motor status via Modbus
Finger Control
finger_position.h- Basic finger position and speed control (Revo1)finger_position_revo2.h- Advanced finger control for Revo2 (position, speed, current, PWM)motor_status.h- Motor status reading (positions, speeds, currents, states)force_level.h- Force level control (deprecated, Revo1 basic only)
Action Sequences
action_sequence.h- Built-in gestures and custom action sequences
Touch Sensors
touch.h- Touch sensor enable, calibrate, reset, and data reading- Raw channel data
- Single finger status
- All fingers status
Device Features
led.h- LED color and mode controlbutton.h- Button press event readingturbo_mode.h- Turbo mode (continuous squeezing)
System Configuration
setup.h- SDK initialization (protocol type, log level)
Firmware Update
ota.h- DFU (Device Firmware Update) operations
Advanced Features
callbacks.h- Callback functions for Modbus and CAN operations
API Coverage
All APIs from stark-sdk.h are documented in these snippet files:
Initialization & Configuration
- ✅
init_cfg()- Initialize SDK - ✅
list_available_ports()- List serial ports
Auto-Detection
- ✅
auto_detect_device()- Auto-detect any device - ✅
auto_detect_modbus_revo1()- Auto-detect Revo1 - ✅
auto_detect_modbus_revo2()- Auto-detect Revo2
Connection Management
- ✅
modbus_open()- Open Modbus connection - ✅
modbus_close()- Close Modbus connection - ✅
canfd_init()- Initialize CANFD - ✅
ethercat_open_master()- Open EtherCAT master - ✅
ethercat_close()- Close EtherCAT master - ✅
ethercat_setup_sdo()- Setup EtherCAT SDO - ✅
ethercat_reserve_master()- Reserve EtherCAT master - ✅
ethercat_start_loop()- Start EtherCAT loop - ✅
ethercat_stop_loop()- Stop EtherCAT loop - ✅
ethercat_start_dfu()- EtherCAT firmware update
Device Information
- ✅
stark_get_device_info()- Get device info - ✅
is_touch_hand_by_sn()- Check if touch hand - ✅
is_revo2_hand_by_sn()- Check if Revo2 - ✅
stark_get_voltage()- Get battery voltage - ✅
stark_get_rs485_baudrate()- Get RS485 baudrate - ✅
stark_set_rs485_baudrate()- Set RS485 baudrate - ✅
stark_get_canfd_baudrate()- Get CANFD baudrate - ✅
stark_set_canfd_baudrate()- Set CANFD baudrate
Device Settings
- ✅
stark_set_slave_id()- Set slave ID - ✅
get_led_enabled()/set_led_enabled()- LED enable/disable - ✅
get_buzzer_enabled()/set_buzzer_enabled()- Buzzer enable/disable - ✅
get_vibration_enabled()/set_vibration_enabled()- Vibration enable/disable - ✅
stark_get_auto_calibration()/stark_set_auto_calibration()- Auto-calibration - ✅
stark_send_calibrate_position()- Manual calibration - ✅
stark_reset_default_gesture()- Reset gestures - ✅
stark_reset_default_settings()- Reset all settings
Finger Control (Unified Range: 0-1000)
- ✅
stark_set_finger_position()- Single finger position - ✅
stark_set_finger_positions()- All fingers positions - ✅
stark_set_finger_speed()- Single finger speed - ✅
stark_set_finger_speeds()- All fingers speeds - ✅
stark_set_finger_current()- Single finger current - ✅
stark_set_finger_currents()- All fingers currents - ✅
stark_set_finger_pwm()- Single finger PWM (Revo2) - ✅
stark_set_finger_pwms()- All fingers PWM (Revo2) - ✅
stark_set_finger_position_with_millis()- Position + duration (Revo2) - ✅
stark_set_finger_positions_and_durations()- Positions + durations (Revo2) - ✅
stark_set_finger_position_with_speed()- Position + speed (Revo2) - ✅
stark_set_finger_positions_and_speeds()- Positions + speeds (Revo2)
Finger Configuration (Revo2)
- ✅
stark_set_finger_unit_mode()/stark_get_finger_unit_mode()- Unit mode - ✅
stark_set_finger_max_position()/stark_get_finger_max_position()- Max position - ✅
stark_set_finger_min_position()/stark_get_finger_min_position()- Min position - ✅
stark_set_finger_max_speed()/stark_get_finger_max_speed()- Max speed - ✅
stark_set_finger_max_current()/stark_get_finger_max_current()- Max current - ✅
stark_set_finger_protected_current()/stark_get_finger_protected_current()- Protection current - ✅
stark_set_thumb_aux_lock_current()/stark_get_thumb_aux_lock_current()- Thumb AUX lock
Motor Status
- ✅
stark_get_motor_status()- Get motor status (positions, speeds, currents, states)
Action Sequences
- ✅
stark_run_action_sequence()- Run action sequence - ✅
stark_set_action_sequence()- Set custom action sequence
Touch Sensors
- ✅
stark_enable_touch_sensor()- Enable sensors - ✅
stark_get_touch_raw_data()- Get raw channel data - ✅
stark_get_single_touch_status()- Get single finger status - ✅
stark_get_touch_status()- Get all fingers status - ✅
stark_reset_touch_sensor()- Reset sensors - ✅
stark_calibrate_touch_sensor()- Calibrate sensors
LED & Button
- ✅
stark_get_led_info()- Get LED info - ✅
stark_get_button_event()- Get button event
Turbo Mode
- ✅
stark_get_turbo_mode_enabled()/stark_set_turbo_mode_enabled()- Turbo mode - ✅
stark_get_turbo_config()- Get turbo config
Force Level (Deprecated)
- ✅
stark_set_force_level()/stark_get_force_level()- Force level (Revo1 basic only)
Firmware Update
- ✅
start_dfu()- Start DFU - ✅
stop_dfu()- Stop DFU - ✅
set_dfu_state_callback()- DFU state callback - ✅
set_dfu_progress_callback()- DFU progress callback
Callbacks
- ✅
set_modbus_operation_callback()- Modbus async callback - ✅
set_modbus_read_input_callback()- Modbus read input callback - ✅
set_modbus_read_holding_callback()- Modbus read holding callback - ✅
set_modbus_write_callback()- Modbus write callback - ✅
set_can_rx_callback()- CAN RX callback - ✅
set_can_tx_callback()- CAN TX callback
Memory Management
- ✅
free_device_config()- Free device config - ✅
free_device_info()- Free device info - ✅
free_device_handler()- Free device handler - ✅
free_motor_status_data()- Free motor status - ✅
free_touch_raw_data()- Free touch raw data - ✅
free_touch_finger_data()- Free touch finger data - ✅
free_touch_finger_item()- Free touch finger item - ✅
free_turbo_config()- Free turbo config - ✅
free_led_info()- Free LED info - ✅
free_button_event()- Free button event - ✅
free_string()- Free string
Key Features
Unified Range
All position, speed, and current values use unified ranges across all devices and protocols:
- Position: 0-1000 (0=fully open, 1000=fully closed)
- Speed: -1000 to +1000 (negative=open, positive=close)
- Current: -1000 to +1000 (negative=open, positive=close)
The SDK handles internal conversion automatically.
English Documentation
All comments and documentation are in English for international developers.
Complete API Coverage
Every function from stark-sdk.h is documented with:
- Parameter descriptions
- Return value documentation
- Usage examples
- Notes and warnings
- Cross-references
Usage
Include the relevant header files in your documentation or code:
cpp
#include "auto_detect.h"
#include "device_info.h"
#include "finger_position_revo2.h"
#include "motor_status.h"
#include "touch.h"
// ... etcThese snippets are designed to be used in documentation generation tools or as reference for developers.