Skip to content

Class espos_n2k::TwaiTransmitter

ClassList > espos_n2k > TwaiTransmitter

Accepts CanMessage values and transmits them on the CAN bus.More...

  • #include <espos_n2k/twai_transmitter.h>

Public Functions

Type Name
TwaiTransmitter (size_t tx_queue_depth=32)
bool ever_transmitted () const
True if we have queued at least one frame since boot.
int64_t seconds_since_last_tx () const
Seconds since the last frame was queued.
void set (const CanMessage & msg)
ValueConsumer interface — queues a frame for transmission.
void start ()
void stop ()
uint32_t tx_fail_count () const
~TwaiTransmitter ()

Detailed Description

The bus itself belongs to the receiver, which configures the pins and the bitrate; start the receiver first. Queueing is the driver's — esp_twai has a transmit queue of its own, so this class no longer runs a task.

Public Functions Documentation

function TwaiTransmitter

explicit espos_n2k::TwaiTransmitter::TwaiTransmitter (
    size_t tx_queue_depth=32
) 

function ever_transmitted

True if we have queued at least one frame since boot.

inline bool espos_n2k::TwaiTransmitter::ever_transmitted () const

(Queued, not acknowledged on the wire — the driver reports that asynchronously and this class does not subscribe to it.)


function seconds_since_last_tx

Seconds since the last frame was queued.

inline int64_t espos_n2k::TwaiTransmitter::seconds_since_last_tx () const

INT64_MAX if none yet. Replaces the old uint32_t tx_count_ which would overflow at ~20 days of busy traffic.


function set

ValueConsumer interface — queues a frame for transmission.

void espos_n2k::TwaiTransmitter::set (
    const CanMessage & msg
) 

Does not block: a full transmit queue drops the frame and counts a failure.


function start

void espos_n2k::TwaiTransmitter::start () 

function stop

void espos_n2k::TwaiTransmitter::stop () 

function tx_fail_count

inline uint32_t espos_n2k::TwaiTransmitter::tx_fail_count () const

function ~TwaiTransmitter

espos_n2k::TwaiTransmitter::~TwaiTransmitter () 


The documentation for this class was generated from the following file espos_n2k/include/espos_n2k/twai_transmitter.h