Socket Stage (CAN)
This stage allows you to receive CAN packets from a CANbus via the Linux SocketCAN
interface. Packets will be grouped together into CanPacketGroup
messages before publishing.
Grouping is intended as a mechanism to batch messages on high-rate sensors, reducing
performance overhead of publishing and logging individual CAN packets. If your data rates
are low, just leave the group_size
parameter set to one (or zero for the default).
Configuration
Basic configuration is in the SocketCanStageConfig
:
device_name
- Device name to connect to (ie,vcan0
)group_size
- The number of packets to bundle before publishing a group.thread_priority
- Priority to set the for the reading thread.data_receive_timeout_ms
- Reconnects if data hasn’t been received in this interval.
Interacting
All packet groups are published under packet_group
in the stage’s namespace.
The stage listens for data to publish on the egress_packets
channel. Anything received
will be written over the CANbus when connected (or dropped otherwise). Packets are
written 1:1.
Notice
CAN-FD is not currently supported by this interface.Metrics
The stage periodically (at 1Hz) emits a SocketStats
structure containing
rate and size information. This is published under the socket_stats
channel
within the stage’s namespace.