Class espos_n2k::TwaiReceiver¶
ClassList > espos_n2k > TwaiReceiver
Reads CAN frames from the TWAI peripheral and emits them as CanMessage values, on the shared node's RX task.
#include <espos_n2k/twai_receiver.h>
Public Types¶
| Type | Name |
|---|---|
| typedef std::function< void(const CanMessage &)> | FrameFn |
Public Functions¶
| Type | Name |
|---|---|
| TwaiReceiver (const TwaiReceiverConfig & config={}) |
|
| uint32_t | bus_off_count () const Bus-off events counted by the shared node since it came up. |
| bool | bus_running () const Is the shared TWAI node up? False means the driver never started (bad pins, a failed twai_new_node_onchip) which from a candump socket looks exactly like a bus with nothing on it. |
| uint32_t | error_count () const Bus errors seen by the controller, and the flags of the most recent one (arb_lost, bit_err, form_err, stuff_err, ack_err IDF's twai_error_flags_t). |
| bool | ever_received () const True if we have received at least one frame since boot. |
| uint32_t | frames_dropped () const |
| uint32_t | frames_received () const Frames the ISR accepted, and frames it had to drop because the queue was full. |
| uint32_t | last_error_flags () const |
| int64_t | seconds_since_last_rx () const Seconds since the last received frame. |
| void | set_on_frame (FrameFn fn) Called on the receiver task for every frame. Set before start() . |
| void | start () |
| void | stop () |
| ~TwaiReceiver () |
Public Types Documentation¶
typedef FrameFn¶
Public Functions Documentation¶
function TwaiReceiver¶
function bus_off_count¶
Bus-off events counted by the shared node since it came up.
function bus_running¶
Is the shared TWAI node up? False means the driver never started (bad pins, a failed twai_new_node_onchip) which from a candump socket looks exactly like a bus with nothing on it.
function error_count¶
Bus errors seen by the controller, and the flags of the most recent one (arb_lost, bit_err, form_err, stuff_err, ack_err IDF's twai_error_flags_t).
Errors rising while frames stay at zero is the signature of a bus that is wired but wrong: an ack error on every transmission means nothing else is listening, and a stuff or form error storm usually means the bitrate does not match.
function ever_received¶
True if we have received at least one frame since boot.
function frames_dropped¶
function frames_received¶
Frames the ISR accepted, and frames it had to drop because the queue was full.
A rising drop count is a consumer that cannot keep up, not a bus problem.
function last_error_flags¶
function seconds_since_last_rx¶
Seconds since the last received frame.
Returns INT64_MAX if no frame has ever been received. esp_timer_get_time() returns int64 microseconds since boot — overflows in ~292,000 years, so no rollover concerns. (Was rx_count_ uint32 which overflowed at ~20 days of busy N2K traffic.)
function set_on_frame¶
Called on the receiver task for every frame. Set before start() .
function start¶
function stop¶
function ~TwaiReceiver¶
The documentation for this class was generated from the following file espos_n2k/include/espos_n2k/twai_receiver.h