feathersdk.comms.can_system Module

exception feathersdk.comms.can_system.CanSystemError

Bases: Exception

Error raised when a system error occurs.

Check if a CAN/vCAN link is a vCAN interface. Assumes link is a CAN/vCAN link.

Parameters:

link (Dict[str, Any])

Return type:

bool

Check if a CAN/vCAN link is enabled. Assumes link is a CAN/vCAN link.

Parameters:

link (Dict[str, Any])

Return type:

bool

Return a dictionary of JSON records for CAN/vCAN interfaces, keyed by interface name.

Parameters:
Return type:

Dict[str, Dict[str, Any]]

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

Get the bitrate of a CAN link. Assumes link is a CAN link.

Parameters:

link (Dict[str, Any])

Return type:

int

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.

Parameters:
  • interface (str)

  • iface_type (Literal['can', 'canopen', 'ip'])

Return type:

int

feathersdk.comms.can_system.get_all_enabled_can_interfaces(include_vcan=True, timeout=2.0)

Return a list of all enabled CAN/vCAN interfaces.

Parameters:
Return type:

List[str]

feathersdk.comms.can_system.disable_can_interface(interface, timeout=2.0)

Disable a CAN/vCAN interface. Sets CANs down, and deletes vCANs.

Parameters:
Return type:

None

feathersdk.comms.can_system.maybe_enable_all_can_interfaces(timeout=2.0)

Attempt to enable all CAN (not vCAN) interfaces. Returns a list of interfaces that were enabled.

Parameters:

timeout (float)

Return type:

List[str]