pycyphal.transport.can.media.socketcand package

Module contents

class pycyphal.transport.can.media.socketcand.SocketcandMedia(channel: str, host: str, port: int = 29536)[source]

Bases: Media

Media interface adapter for Socketcand using the built-in interface from Python-CAN. Please refer to the Socketcand documentation for information about supported hardware, configuration, and installation instructions.

This media interface supports only Classic CAN.

Here is a basic usage example based on the Yakut CLI tool. Suppose you have two computers: One connected to a CAN-capable device and that computer is able to connect and receive CAN data from the CAN device. Using socketcand with a command such as socketcand -v -i can0 -l 123.123.1.123 on this first computer will bind it too a socket (default port for socketcand is 29536, so it is also default here).

Then, on your second computer:

export UAVCAN__CAN__IFACE="socketcand:can0:123.123.1.123"
yakut sub 33:uavcan.si.unit.voltage.scalar

This will allow you to remotely receive CAN data on computer two through the wired connection on computer 1.

__init__(channel: str, host: str, port: int = 29536) None[source]
Parameters:
  • channel – Name of the CAN channel/interface that your remote computer is connected to; often can0 or vcan0. Comes after the -i in the socketcand command.

  • host – Name of the remote IP address of the computer running socketcand; should be in the format 123.123.1.123. In the socketcand command, this is the IP address after -l.

  • port – Name of the port the socket is bound too. As per socketcand’s default value, here, the default is also 29536.

property interface_name: str[source]
property channel_name: str[source]
property host_name: str[source]
property port_name: int[source]
property mtu: int[source]
property number_of_acceptance_filters: int[source]

The value is currently fixed at 1 for all interfaces. TODO: obtain the number of acceptance filters from Python-CAN.

start(handler: Callable[[Sequence[Tuple[Timestamp, Envelope]]], None], no_automatic_retransmission: bool) None[source]
configure_acceptance_filters(configuration: Sequence[FilterConfiguration]) None[source]
async send(frames: Iterable[Envelope], monotonic_deadline: float) int[source]
close() None[source]
static list_available_interface_names() Iterable[str][source]

Returns an empty list. TODO: provide minimally functional implementation.