feathersdk.comms.can_system Module¶
- exception feathersdk.comms.can_system.CanSystemError¶
Bases:
ExceptionError raised when a system error occurs.
- feathersdk.comms.can_system.is_can_link_vcan(link)¶
Check if a CAN/vCAN link is a vCAN interface. Assumes link is a CAN/vCAN link.
- feathersdk.comms.can_system.is_can_link_enabled(link)¶
Check if a CAN/vCAN link is enabled. Assumes link is a CAN/vCAN link.
- feathersdk.comms.can_system.get_can_links(include_can=True, include_vcan=True, timeout=2)¶
Return a dictionary of JSON records for CAN/vCAN interfaces, keyed by interface name.
- feathersdk.comms.can_system.enable_can_interface(interface, bitrate=1000000, is_vcan=None, timeout=2.0, _links=None)¶
Enable a CAN interface or multiple interfaces.
For a “can” interface: - If it doesn’t exist, raise an error - If it exists but is down, enable it - If it exists and is up, make sure the bitrate is correct. Raise an error if it is not.
For a “vcan” interface: - If it doesn’t exist, create it - If it exists but is down, enable it - Bitrate is ignored
- Parameters:
interface (str | List[str]) – The interface to enable. Can be a single interface or a list of interfaces.
bitrate (int) – The bitrate to set for the interface. Only used for CAN interfaces, ignored for vCAN interfaces.
is_vcan (bool | None) – Whether the interface is a vCAN interface. If not provided, will be inferred from the interface type if it already exists, or the interface name if it doesn’t. If provided and interface is a list, then this will apply to all interfaces in the list.
timeout (float) – The timeout for any shell commands to run.
_links (Dict[str, Any] | None) – Internal use only. A list of dictionaries of CAN/vCAN links, keyed by interface name.
- Return type:
None
- feathersdk.comms.can_system.get_can_link_bitrate(link)¶
Get the bitrate of a CAN link. Assumes link is a CAN link.
- feathersdk.comms.can_system.get_iface_uid(interface, iface_type)¶
Return the unique identifier of an interface.
For CAN/vCAN interfaces, returns the unique identifier of the interface (which will change even if the interface is deleted and recreated with the same name). For ip addresses, returns integer value created by removing all ‘.’s and the ‘:’ from the ip address.
- feathersdk.comms.can_system.get_all_enabled_can_interfaces(include_vcan=True, timeout=2.0)¶
Return a list of all enabled CAN/vCAN interfaces.
- feathersdk.comms.can_system.disable_can_interface(interface, timeout=2.0)¶
Disable a CAN/vCAN interface. Sets CANs down, and deletes vCANs.