Skip to content

Cyphal ExecuteCommand

The ExecuteCommand service handler implements the uavcan.node.ExecuteCommand service, allowing remote execution of node management commands such as restart, power off, software update, and custom device-specific actions.

Library Commands

Command Name Identifier Description Status/Output
COMMAND_RESTART 65535 Restarts the node after a short delay. Returns SUCCESS if scheduled.
COMMAND_BEGIN_SOFTWARE_UPDATE 65533 Initiates firmware update if DFU is enabled and available. Returns SUCCESS or BAD_STATE.
CMD_GET_RTC_TIME (custom) 100 Returns the current RTC time as a formatted string. Output: "YYYY-MM-DD HH:MM:SS"
CMD_SET_RTC_TIME (custom) 101 Sets the RTC time from a formatted string. Output: new RTC time, returns SUCCESS/FAILURE
CMD_GET_RTC_CALIBRATION (custom) 102 Returns the RTC calibration value in ppm. Output: calibration value, returns SUCCESS
CMD_SET_RTC_CALIBRATION (custom) 103 Sets the RTC calibration value. Output: new value, returns SUCCESS/FAILURE
CMD_SET_RTC_TIME_DUMP (custom) 104 Dumps the RTC time to the console. No status change.
CMD_LED_SET_STATIC (custom) 200 Schedules an LED color/state change at a specific time. Returns SUCCESS/BAD_PARAMETER/BAD_STATE
Command Name Identifier Description Status/Output
COMMAND_POWER_OFF 65534 Attempts to power off the node (not implemented, logs warning). No status change.
COMMAND_FACTORY_RESET 65532 Placeholder for factory reset (no implementation). No status change.
COMMAND_EMERGENCY_STOP 65531 Placeholder for emergency stop (no implementation). No status change.
COMMAND_STORE_PERSISTENT_STATES 65530 Placeholder for storing persistent states (no implementation). No status change.
COMMAND_IDENTIFY 65529 Placeholder for identify command (no implementation). No status change.

Note

Custom commands are available only if the corresponding features (RTC, RTC calibration, BMS LEDs) are enabled at compile time.

Command Parameters

  • Standard commands: Parameters are typically ignored.
  • Custom commands:
    • CMD_SET_RTC_TIME, CMD_GET_RTC_TIME: Use date/time strings according to RFC-3339 (date --rfc-3339=seconds).
    • CMD_SET_RTC_CALIBRATION, CMD_GET_RTC_CALIBRATION: Use integer values for calibration (ppm value).
    • CMD_LED_SET_STATIC: Expects a string with LED parameters:
      <led_nr> <r> <g> <b> <brightness> <duration_ms> <start_time:HH:MM:SS.mmm>

Example Usage

# general command
y cmd <node_id> <cmd>

# restart
y cmd <node_id> restart

# Set actual RTC time
y cmd <node_id> 101 `date --rfc-3339=seconds`

# Set LED color to red for 1s at 12:34:56.789
y cmd 200 "0 255 0 0 255 1000 12:34:56.789"

Logging

Command execution is logged with appropriate severity (LOG_INF, LOG_WRN, LOG_ERR) for traceability and debugging.

Extending

To add new commands, extend the switch statement in execute_command_handler and define the corresponding command code and logic.