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.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Device id. |
type |
Model
|
Device type. |
fw_ver |
float
|
Device firmware version. |
__init__(can, device_id)
Init device with interface and id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
can |
CanBus
|
Can bus interface. |
required |
device_id |
int
|
Device id. |
required |
Raises:
Type | Description |
---|---|
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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
float
|
Timeout in seconds. |
None
|
Returns:
Type | Description |
---|---|
dict | None
|
Device firmware version and type. |