跳转至

CanBusDevice

robodyno.components.can_bus.can_bus_device

Base class for all robodyno devices which use can bus as communication

All robodyno devices which use can bus as communication interface should inherit this class.

Examples:

>>> from robodyno.components import CanBusDevice
>>> from robodyno.interfaces import CanBus
>>> can_bus = CanBus()
>>> device = CanBusDevice(can_bus, 0x01)
>>> device.get_version()
{'main_version': 1, 'sub_version': 0, 'type': <Model.THIRD_PARTY: 255>}
>>> device.fw_ver
1.0
>>> device.type
<Model.THIRD_PARTY: 255>
>>> can_bus.disconnect()

CanBusDevice

Bases: object

Base class for all robodyno devices which use can bus as communication interface.

This class provides basic functions for all robodyno devices which use can bus as communication interface. It provides functions to get device firmware version and device type.

属性:

名称 类型 描述
id int

Device id.

type Model

Device type.

fw_ver float

Device firmware version.

__init__(can, device_id)

Init device with interface and id.

参数:

名称 类型 描述 默认
can CanBus

Can bus interface.

必需
device_id int

Device id.

必需

引发:

类型 描述
ValueError

If device id is not in range [0x01, 0x40).

TypeError

If can is not CanBus.

get_version(timeout=None)

Get device firmware version and type.

参数:

名称 类型 描述 默认
timeout float

Timeout in seconds.

None

返回:

类型 描述
dict | None

Device firmware version and type.