Skip to content

RaftDeviceManagerSysMod

Rob Dobson edited this page Feb 8, 2026 · 7 revisions

DeviceManager SysMod

Overview

The DeviceManager SysMod is responsible for managing devices and buses. It sets up and monitors the status of devices, handles bus communication, and provides an interface for interacting with devices via REST API endpoints. The DeviceManager interacts with the system manager (SysManager) to register devices and manage data sources.

Features

  • Device Setup and Management: Initializes and manages devices based on configuration.
  • Bus Management: Monitors and handles bus operations and element statuses.
  • REST API Interface: Provides REST endpoints for interacting with devices.
  • Device Data Change Callbacks: Supports registering callbacks for device data changes.
  • Status Monitoring: Continuously monitors the status of devices and buses.

Device Factory and Classes

When a

I2C Device Scanning

I2C buses are scanned to detect devices, including those connected through bus multiplexers. Scanning uses priority-based address ordering for efficient detection and supports device hot-swapping.

For detailed information about the scanning process, priority lists, multiplexer handling, and bus stuck recovery, see I2C Device Scanning.

I2C Device Identification and Polling

After devices are detected through scanning, DeviceManager identifies device types, initializes devices, and polls them for data at configured intervals. Device type records define how to identify, initialize, and poll each supported device type.

For detailed information about device type detection, initialization sequences, polling configuration, and data collection, see I2C Device Identification and Polling.

Device Data Publishing

DeviceManager automatically publishes device data through the StatePublisher system using two topics:

  • devjson: Human-readable JSON format for device data
  • devbin: Compact binary format for efficient transmission

For detailed information about the message formats, subscription methods, and integration details, see Device Data Publishing.

Supported Devices

DeviceManager supports various device types. Some devices have dedicated documentation:

DeviceManager Settings

When constructed normally (in RaftCoreApp for instance) the DeviceManager is configured using the contents of the SysTypes key DevMan. The settings available to configure DeviceManager are described in Device Manager Settings

DeviceManager API

The API for DeviceManager is included in the Raft API List

1. /devman/typeinfo

Description:

This endpoint is used to retrieve detailed information about a specific device type on a given bus. It returns information such as the device's capabilities, status, and configuration details.

GET Parameter Type Required Description
type string Yes The type name of the device to retrieve information for.

Example Request:

/devman/typeinfo?type=LSM6DS

Example Success Response:

{
    "req": "/devman/typeinfo?type=LSM6DS",
    "devinfo": {
        "name": "LSM6DS",
        "desc": "6-Axis IMU",
        "manu": "ST",
        "type": "LSM6DS",
        "resp": {
            "b": 12,
            "a": [
                {
                    "n": "gx",
                    "t": "<h",
                    "u": "dps",
                    "r": [
                        -2000,
                        2000
                    ],
                    "d": 16.384,
                    "f": ".2f",
                    "o": "float"
                },
                {
                    "n": "gy",
                    "t": "<h",
                    "u": "dps",
                    "r": [
                        -2000,
                        2000
                    ],
                    "d": 16.384,
                    "f": ".2f",
                    "o": "float"
                },
                {
                    "n": "gz",
                    "t": "<h",
                    "u": "dps",
                    "r": [
                        -2000,
                        2000
                    ],
                    "d": 16.384,
                    "f": ".2f",
                    "o": "float"
                },
                {
                    "n": "ax",
                    "t": "<h",
                    "u": "g",
                    "r": [
                        -4,
                        4
                    ],
                    "d": 8192,
                    "f": ".2f",
                    "o": "float"
                },
                {
                    "n": "ay",
                    "t": "<h",
                    "u": "g",
                    "r": [
                        -4,
                        4
                    ],
                    "d": 8192,
                    "f": ".2f",
                    "o": "float"
                },
                {
                    "n": "az",
                    "t": "<h",
                    "u": "g",
                    "r": [
                        -4,
                        4
                    ],
                    "d": 8192,
                    "f": ".2f",
                    "o": "float"
                }
            ]
        }
    },
    "rslt": "ok"
}

Example Failure Response

{
  "req": "/devman/typeinfo?type=UnknownDevice",
  "rslt": "error",
  "error": "failTypeNotFound"
}

Other failure reasons:

  • failTypeMissing: Missing type parameter.
  • failTypeNotFound: The specified type was not found.

2. /devman/cmdraw

Description:
This endpoint allows raw commands to be sent to a device on a specified bus. It can be used to send low-level control commands to devices, such as writing specific data to a device register.

Method: GET

URL Parameters:

Parameter Type Required Description
bus string Yes The name of the bus where the device is located.
addr string Yes The address of the device on the bus.
hexWr string No A hex-encoded string representing the data to write to the device.
numToRd int No The number of bytes to read from the device.

Example Request:

/devman/cmdraw?bus=I2C1&addr=0x3C&hexWr=F00D

Example Response:

{
    "req":"/devman/cmdraw?bus=I2CA&addr=0x6a",
    "rslt":"ok"
}

Response Fields:

  • result: Indicates the success or failure of the command (ok, error).

Error Responses:

  • failBusMissing: Missing bus parameter.
  • failMissingAddr: Missing addr parameter.
  • failBusNotFound: The specified bus was not found.

3. /devman/busname

Description:
This endpoint retrieves the bus name from a bus number. Bus numbers start from 1 and match the numbering used in device data JSON/binary messages. Only buses with valid device interfaces are numbered.

Method: GET

URL Parameters:

Parameter Type Required Description
busnum int Yes The bus number to retrieve the name for.

Example Request:

/devman/busname?busnum=1

Example Success Response:

{
    "req": "devman/busname?busnum=1",
    "rslt": "ok",
    "busName": "I2CA"
}

Error Responses:

  • failInvalidBusNum: Missing or invalid busnum parameter.
  • failBusNotFound: The specified bus number was not found.

4. /devman/setpollinterval

Description:
This endpoint sets the polling interval for a bus-connected device. Only works for devices connected via a bus (I2C, Serial, etc.).

Method: GET

URL Parameters:

Parameter Type Required Description
bus string or int Yes The bus name (e.g., "I2CA") or bus number.
device string Yes The device ID or device address (e.g. "20" or "I2CA_20").
intervalMs int Yes The polling interval in milliseconds.

Example Request:

/devman/setpollinterval?bus=I2CA&device=20&intervalMs=50

or

/devman/setpollinterval?device=1_20&intervalMs=50

Example Success Response:

{
    "req": "devman/setpollinterval?bus=I2CA&device=20&intervalMs=50",
    "rslt": "ok"
}

Error Responses:

  • failBusMissing: Missing bus parameter.
  • failDeviceMissing: Missing device parameter.
  • failInvalidInterval: Missing or invalid intervalMs parameter.
  • failDeviceNotFound: The specified device was not found.
  • failBusNotFound: The specified bus was not found.

Clone this wiki locally