-
Notifications
You must be signed in to change notification settings - Fork 3
RaftDeviceManagerSysMod
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.
- 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.
When a
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.
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.
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.
DeviceManager supports various device types. Some devices have dedicated documentation:
- MotorController Device - Multi-axis motor control with REST API and JSON commands
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
The API for DeviceManager is included in the Raft API List
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. |
/devman/typeinfo?type=LSM6DS
{
"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"
}{
"req": "/devman/typeinfo?type=UnknownDevice",
"rslt": "error",
"error": "failTypeNotFound"
}Other failure reasons:
-
failTypeMissing: Missingtypeparameter. -
failTypeNotFound: The specified type was not found.
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
| 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. |
/devman/cmdraw?bus=I2C1&addr=0x3C&hexWr=F00D
{
"req":"/devman/cmdraw?bus=I2CA&addr=0x6a",
"rslt":"ok"
}-
result: Indicates the success or failure of the command (ok,error).
-
failBusMissing: Missingbusparameter. -
failMissingAddr: Missingaddrparameter. -
failBusNotFound: The specified bus was not found.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
busnum |
int | Yes | The bus number to retrieve the name for. |
/devman/busname?busnum=1
{
"req": "devman/busname?busnum=1",
"rslt": "ok",
"busName": "I2CA"
}-
failInvalidBusNum: Missing or invalidbusnumparameter. -
failBusNotFound: The specified bus number was not found.
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
| 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. |
/devman/setpollinterval?bus=I2CA&device=20&intervalMs=50
or
/devman/setpollinterval?device=1_20&intervalMs=50
{
"req": "devman/setpollinterval?bus=I2CA&device=20&intervalMs=50",
"rslt": "ok"
}-
failBusMissing: Missingbusparameter. -
failDeviceMissing: Missingdeviceparameter. -
failInvalidInterval: Missing or invalidintervalMsparameter. -
failDeviceNotFound: The specified device was not found. -
failBusNotFound: The specified bus was not found.