HardFOC Core
API reference
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
hf::can::PipePort Class Referencefinal

ICanPort over a PipeHub. More...

#include <PipePort.h>

Inheritance diagram for hf::can::PipePort:
hf::can::ICanPort

Classes

struct  Options
 

Public Member Functions

 PipePort (Options options)
 
 ~PipePort () override
 
 PipePort (const PipePort &)=delete
 
PipePort & operator= (const PipePort &)=delete
 
bool Open ()
 Connect (starting a hub if allowed and needed) and start the I/O thread.
 
void Close ()
 Stop the I/O thread and disconnect (and stop a hub this port started).
 
bool IsOpen () const noexcept
 
bool HostsHub () const noexcept
 True when this port started the hub it uses.
 
PortCaps Caps () const override
 Static capabilities.
 
TxResult Send (const CanFrame &frame) override
 Queue frame without blocking.
 
void SetRxSink (RxSink sink, void *ctx) override
 Install the RX sink (nullptr detaches).
 
PortStatus Status () const override
 Error counters and state.
 
bool Recover () override
 Request bus-off recovery; false when not possible now.
 
void SetTxDoneSink (TxDoneSink sink, void *ctx) override
 Install the TX-done sink. Ports without a TX-done event ignore it.
 
bool RxBackpressure () const override
 The pipe bus never drops: a refused frame is held and offered again.
 
- Public Member Functions inherited from hf::can::ICanPort
virtual ~ICanPort ()=default
 

Private Member Functions

bool Connect ()
 
void IoLoop ()
 
void Wake () const
 
bool Deliver (const CanFrame &f)
 

Private Attributes

Options opt_
 
std::unique_ptr< PipeHub > hub_
 
int fd_ {-1}
 
int wake_ [2] {-1, -1}
 
std::thread io_
 
std::atomic< bool > run_ {false}
 
std::atomic< bool > connected_ {false}
 
std::mutex tx_mu_
 
std::vector< CanFrame > tx_ring_
 
std::size_t tx_head_ {0}
 
std::size_t tx_count_ {0}
 
bool tx_was_full_ {false}
 
std::mutex sink_mu_
 
RxSink rx_sink_ {nullptr}
 
void * rx_ctx_ {nullptr}
 
TxDoneSink tx_sink_ {nullptr}
 
void * tx_ctx_ {nullptr}
 
std::atomic< uint32_t > tx_queue_full_ {0}
 
uint16_t seq_ {0}
 
uint32_t epoch_ {0}
 

Additional Inherited Members

- Protected Member Functions inherited from hf::can::ICanPort
 ICanPort ()=default
 
 ICanPort (const ICanPort &)=default
 
ICanPort & operator= (const ICanPort &)=default
 

Detailed Description

ICanPort over a PipeHub.

Constructor & Destructor Documentation

◆ PipePort() [1/2]

hf::can::PipePort::PipePort ( Options  options)
explicit

◆ ~PipePort()

hf::can::PipePort::~PipePort ( )
override

◆ PipePort() [2/2]

hf::can::PipePort::PipePort ( const PipePort &  )
delete

Member Function Documentation

◆ Caps()

PortCaps hf::can::PipePort::Caps ( ) const
overridevirtual

Static capabilities.

Implements hf::can::ICanPort.

◆ Close()

void hf::can::PipePort::Close ( )

Stop the I/O thread and disconnect (and stop a hub this port started).

◆ Connect()

bool hf::can::PipePort::Connect ( )
private

◆ Deliver()

bool hf::can::PipePort::Deliver ( const CanFrame &  f)
private

◆ HostsHub()

bool hf::can::PipePort::HostsHub ( ) const
inlinenoexcept

True when this port started the hub it uses.

◆ IoLoop()

void hf::can::PipePort::IoLoop ( )
private

◆ IsOpen()

bool hf::can::PipePort::IsOpen ( ) const
inlinenoexcept

◆ Open()

bool hf::can::PipePort::Open ( )

Connect (starting a hub if allowed and needed) and start the I/O thread.

◆ operator=()

PipePort & hf::can::PipePort::operator= ( const PipePort &  )
delete

◆ Recover()

bool hf::can::PipePort::Recover ( )
overridevirtual

Request bus-off recovery; false when not possible now.

Implements hf::can::ICanPort.

◆ RxBackpressure()

bool hf::can::PipePort::RxBackpressure ( ) const
inlineoverridevirtual

The pipe bus never drops: a refused frame is held and offered again.

Reimplemented from hf::can::ICanPort.

◆ Send()

TxResult hf::can::PipePort::Send ( const CanFrame &  frame)
overridevirtual

Queue frame without blocking.

Implements hf::can::ICanPort.

◆ SetRxSink()

void hf::can::PipePort::SetRxSink ( RxSink  sink,
void *  ctx 
)
overridevirtual

Install the RX sink (nullptr detaches).

Implements hf::can::ICanPort.

◆ SetTxDoneSink()

void hf::can::PipePort::SetTxDoneSink ( TxDoneSink  sink,
void *  ctx 
)
overridevirtual

Install the TX-done sink. Ports without a TX-done event ignore it.

Reimplemented from hf::can::ICanPort.

◆ Status()

PortStatus hf::can::PipePort::Status ( ) const
overridevirtual

Error counters and state.

Implements hf::can::ICanPort.

◆ Wake()

void hf::can::PipePort::Wake ( ) const
private

Member Data Documentation

◆ connected_

std::atomic<bool> hf::can::PipePort::connected_ {false}
private

◆ epoch_

uint32_t hf::can::PipePort::epoch_ {0}
private

◆ fd_

int hf::can::PipePort::fd_ {-1}
private

◆ hub_

std::unique_ptr<PipeHub> hf::can::PipePort::hub_
private

◆ io_

std::thread hf::can::PipePort::io_
private

◆ opt_

Options hf::can::PipePort::opt_
private

◆ run_

std::atomic<bool> hf::can::PipePort::run_ {false}
private

◆ rx_ctx_

void* hf::can::PipePort::rx_ctx_ {nullptr}
private

◆ rx_sink_

RxSink hf::can::PipePort::rx_sink_ {nullptr}
private

◆ seq_

uint16_t hf::can::PipePort::seq_ {0}
private

◆ sink_mu_

std::mutex hf::can::PipePort::sink_mu_
private

◆ tx_count_

std::size_t hf::can::PipePort::tx_count_ {0}
private

◆ tx_ctx_

void* hf::can::PipePort::tx_ctx_ {nullptr}
private

◆ tx_head_

std::size_t hf::can::PipePort::tx_head_ {0}
private

◆ tx_mu_

std::mutex hf::can::PipePort::tx_mu_
private

◆ tx_queue_full_

std::atomic<uint32_t> hf::can::PipePort::tx_queue_full_ {0}
private

◆ tx_ring_

std::vector<CanFrame> hf::can::PipePort::tx_ring_
private

◆ tx_sink_

TxDoneSink hf::can::PipePort::tx_sink_ {nullptr}
private

◆ tx_was_full_

bool hf::can::PipePort::tx_was_full_ {false}
private

◆ wake_

int hf::can::PipePort::wake_[2] {-1, -1}
private

The documentation for this class was generated from the following files: