Module contents

class str | Path | TextIO)[source]


This is a pseudo-media layer that replays standard SocketCAN candump log files. It can be used to perform postmortem analysis of a Cyphal/CAN network based on the standard log files collected by candump.

If the dump file contains frames collected from multiple interfaces, frames from only one of the interfaces will be read and the others will be skipped. The name of that interface is obtained from the first valid logged frame. If you want to process frames from other interfaces, use grep to filter them out.

Please refer to the SocketCAN documentation for the format description. Here’s an example:

(1657800496.359233) slcan0 0C60647D#020000FB
(1657800496.360136) slcan0 10606E7D#00000000000000BB
(1657800496.360149) slcan1 10606E7D#000000000000001B
(1657800496.360152) slcan0 10606E7D#000000000000003B
(1657800496.360155) slcan0 10606E7D#0000C6565B
(1657800496.360305) slcan2 1060787D#00000000000000BB
(1657800496.360317) slcan0 1060787D#0000C07F147CB71B
(1657800496.361011) slcan1 1060787D#412BCC7B
(1657800496.361022) slcan2 10608C7D#73000000000000FB
(1657800496.361026) slcan0 1060967D#00000000000000BB
(1657800496.361028) slcan0 1060967D#00313E5B
(1657800496.361258) slcan1 1460827D#7754A643E06A96BB
(1657800496.361269) slcan0 1460827D#430000000000001B
(1657800496.361273) slcan0 1460827D#EE3C7B
(1657800496.362258) slcan0 1460A07D#335DB35CD85CFB
(1657800496.362270) slcan0 107D557D#5F000000000000FB
(1657800497.359273) slcan0 0C60647D#020000FC
(1657800497.360146) slcan0 10606E7D#00000000000000BC
(1657800497.360158) slcan0 10606E7D#000000000000001C
(1657800497.360161) slcan2 10606E7D#000000000000003C

Each line contains a CAN frame which is reported as received with the specified wall (system) timestamp. This media layer, naturally, cannot accept outgoing frames, so they are dropped (and logged).

Usage example with Yakut:

export UAVCAN__CAN__IFACE='candump:verification/integration/candump.log'
y sub uavcan.node.heartbeat 10:reg.udral.service.common.readiness 130:reg.udral.service.actuator.common.status
y mon


Currently, there is no way for this media implementation to notify the upper layers that the end of the log file is reached. It should be addressed eventually as part of #227. Meanwhile, you can force the media layer to terminate its own process when the log file is fully replayed by setting the environment variable PYCYPHAL_CANDUMP_YOU_ARE_TERMINATED to a non-zero value.

Ideally, there also should be a way to report how far along are we in the log file, but it is not clear how to reconcile that with the normal media implementations.


The API of this class is experimental and subject to breaking changes.

GLOB_PATTERN = 'candump*.log'
__init__(file: str | Path | TextIO) None[source]

file – Path to the candump log file, or a text-IO instance.

property interface_name: str[source]

The name of the log file.

property mtu: int[source]
property number_of_acceptance_filters: int[source]
start(handler: Callable[[Sequence[Tuple[pycyphal.transport._timestamp.Timestamp,]]], None], no_automatic_retransmission: bool) None[source]
configure_acceptance_filters(configuration: Sequence[]) None[source]
async send(frames: Iterable[], monotonic_deadline: float) int[source]

Sent frames are dropped.

close() None[source]
static list_available_interface_names(*, recurse: bool = False) Iterable[str][source]

Returns the list of candump log files in the current working directory.