samcrow / canadensis

A Rust implementation of Cyphal
Apache License 2.0
44 stars 5 forks source link

CAN Loopback #21

Closed samcrow closed 1 year ago

samcrow commented 1 year ago

This is a basic implementation of loopback transfers and frames for Cyphal/CAN.

The timestamp of a loopback frame is taken from the now timestamp passed to the driver's transmit function. That may or may not be accurate enough for time synchronization.

To receive a loopback transfer, the node needs to have a corresponding subscription. That means that it will also receive transfers on the same port from all other nodes. Sometimes we don't want that. In the future, there should be a way to subscribe to loopback transfers only.

This includes one test that uses message transfers (not requests) and tests the node and CAN transport code.

Closes #11

samcrow commented 1 year ago

With recent changes, the bxcan driver now has access to the clock and calls clock.now() for every frame, so the timestamps of the loopback frames can be more accurate.