SDKPython SDK

Device discovery & connection

Discover serial candidates, choose automatic or explicit ports, and select named Exo devices.

Current version · 1.4.0

Device discovery & connection

Discover devices

from qnbot_sdk.exo import discover_exos

for candidate in discover_exos():
    print(candidate.transport_type.value)
    if candidate.error:
        print(candidate.port, candidate.error.code, candidate.error.message)
    else:
        print(candidate.port, candidate.device_info.product)

Each DiscoveredExo contains either device_info or error. Error codes are PORT_OPEN, PROTOCOL_ERROR, and INCOMPATIBLE.

These errors describe an individual candidate port; discovery continues with the remaining candidates. If serial enumeration itself fails, discover_exos() raises a discovery exception instead of returning a DiscoveredExo without a port.

The required DiscoveredExo.transport_type field has type ExoTransportType; its current value is ExoTransportType.SERIAL (serial). Include it when constructing or deserializing discovery records yourself.

Automatic and explicit selection

from qnbot_sdk import Sdk, SerialConnection
from qnbot_sdk.exo import ExoConfig

automatic = ExoConfig()
fixed = ExoConfig(
    name="primary-exo",
    connection=SerialConnection(port="/dev/ttyUSB0"),
)
sdk = Sdk(devices=(fixed,))
device = sdk.exo().device("primary-exo")

Windows ports look like COM3. Exo does not support locating through SerialConnection.serial_number; serial numbers are read-only device information. Give every device a unique logical name and explicit port in multi-device configurations.

Device selection

  • Use exo.device() only when exactly one Exo is configured. Zero devices reports not found; multiple devices reports an ambiguous selection.
  • exo.device("primary-exo") selects by ExoConfig.name. A missing name reports not found.
  • name is the logical application configuration name, not hardware_name or the hardware serial number.

Read device information before start

get_device_info() may be called before start(). It returns the immutable device snapshot prepared when the SDK was created and does not access the hardware again on every call.

info = device.get_device_info()
print(info.product, info.firmware)
print("encoders", info.components.encoders.available,
      "/", info.components.encoders.total_slots)
print("telemetry", info.capabilities.telemetry)

capabilities says whether a feature is available; components reports the number present and the total device slots. Do not use component counts as a substitute for capability checks—for example, still check capabilities.imus before reading IMUs.