Lely core libraries 2.3.4
lely::io::CanNet Class Reference

A CAN network interface. This class is a wrapper around io_can_net_t*. More...

#include <can_net.hpp>

Inheritance diagram for lely::io::CanNet:
Collaboration diagram for lely::io::CanNet:

Public Member Functions

 CanNet (ev_exec_t *exec, io_timer_t *timer, io_can_chan_t *chan, ::std::size_t txlen=0, int txtimeo=0)
 
 CanNet (io_timer_t *timer, io_can_chan_t *chan, ::std::size_t txlen=0, int txtimeo=0)
 
virtual ~CanNet ()
 
void start () noexcept
 
ContextBase get_ctx () const noexcept
 
ev::Executor get_executor () const noexcept
 
Clock get_clock () const noexcept
 

Protected Member Functions

void lock () final
 Blocks until a lock can be obtained for the current execution agent (thread, process, task).
 
void unlock () final
 Releases the lock held by the execution agent. Throws no exceptions.
 
void set_time ()
 Updates the CAN network time.
 
virtual void on_read_error (::std::error_code ec, ::std::size_t errcnt) noexcept
 The function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors.
 
virtual void on_queue_error (::std::error_code ec, ::std::size_t errcnt) noexcept
 The function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors.
 
virtual void on_write_error (::std::error_code ec, ::std::size_t errcnt) noexcept
 The function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors.
 
virtual void on_can_state (CanState new_state, CanState old_state) noexcept
 The function invoked when a CAN bus state change is detected.
 
virtual void on_can_error (CanError error) noexcept
 The function invoked when an error is detected on the CAN bus.
 

Detailed Description

A CAN network interface. This class is a wrapper around io_can_net_t*.

Definition at line 38 of file can_net.hpp.

Constructor & Destructor Documentation

◆ CanNet() [1/2]

lely::io::CanNet::CanNet ( ev_exec_t exec,
io_timer_t timer,
io_can_chan_t chan,
::std::size_t  txlen = 0,
int  txtimeo = 0 
)
inlineexplicit
See also
io_can_net_create()

Definition at line 41 of file can_net.hpp.

◆ CanNet() [2/2]

lely::io::CanNet::CanNet ( io_timer_t timer,
io_can_chan_t chan,
::std::size_t  txlen = 0,
int  txtimeo = 0 
)
inlineexplicit
See also
io_can_net_create()

Definition at line 62 of file can_net.hpp.

◆ ~CanNet()

virtual lely::io::CanNet::~CanNet ( )
inlinevirtual
See also
io_can_net_destroy()

Definition at line 70 of file can_net.hpp.

Member Function Documentation

◆ start()

void lely::io::CanNet::start ( )
inlinenoexcept
See also
io_can_net_start()

Definition at line 80 of file can_net.hpp.

◆ get_ctx()

ContextBase lely::io::CanNet::get_ctx ( ) const
inlinenoexcept
See also
io_can_net_get_ctx()

Definition at line 86 of file can_net.hpp.

◆ get_executor()

ev::Executor lely::io::CanNet::get_executor ( ) const
inlinenoexcept
See also
io_can_net_get_exec()

Definition at line 92 of file can_net.hpp.

◆ get_clock()

Clock lely::io::CanNet::get_clock ( ) const
inlinenoexcept
See also
io_can_net_get_clock()

Definition at line 98 of file can_net.hpp.

◆ lock()

void lely::io::CanNet::lock ( )
inlinefinalprotectedvirtual

Blocks until a lock can be obtained for the current execution agent (thread, process, task).

If an exception is thrown, no lock is obtained.

Implements lely::util::BasicLockable.

Definition at line 104 of file can_net.hpp.

◆ set_time()

void lely::io::CanNet::set_time ( )
inlineprotected

Updates the CAN network time.

The mutex protecting the CAN network interface MUST be locked for the duration of this call.

See also
io_can_net_set_time()

Definition at line 124 of file can_net.hpp.

◆ on_read_error()

virtual void lely::io::CanNet::on_read_error ( ::std::error_code  ec,
::std::size_t  errcnt 
)
inlineprotectedvirtualnoexcept

The function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors.

The mutex protecting the CAN network interface will be locked when this function is called.

Parameters
ecthe error code (0 on success).
errcntthe number of errors since the last successful read operation.

Definition at line 140 of file can_net.hpp.

◆ on_queue_error()

virtual void lely::io::CanNet::on_queue_error ( ::std::error_code  ec,
::std::size_t  errcnt 
)
inlineprotectedvirtualnoexcept

The function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors.

The mutex protecting the CAN network interface will be locked when this function is called.

Parameters
ecthe error code (0 on success).
errcntthe number of errors since the last frame was successfully queued.

Definition at line 157 of file can_net.hpp.

◆ on_write_error()

virtual void lely::io::CanNet::on_write_error ( ::std::error_code  ec,
::std::size_t  errcnt 
)
inlineprotectedvirtualnoexcept

The function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors.

The mutex protecting the CAN network interface will be locked when this function is called.

Parameters
ecthe error code (0 on success).
errcntthe number of errors since the last successful write operation.

Definition at line 174 of file can_net.hpp.

◆ on_can_state()

virtual void lely::io::CanNet::on_can_state ( CanState  new_state,
CanState  old_state 
)
inlineprotectedvirtualnoexcept

The function invoked when a CAN bus state change is detected.

The state is represented by one the CanState::ACTIVE, CanState::PASSIVE, CanState::BUSOFF, CanState::SLEEPING or CanState::STOPPED values.

The mutex protecting the CAN network interface will be locked when this function is called.

Parameters
new_statethe current state of the CAN bus.
old_statethe previous state of the CAN bus.

Definition at line 191 of file can_net.hpp.

◆ on_can_error()

virtual void lely::io::CanNet::on_can_error ( CanError  error)
inlineprotectedvirtualnoexcept

The function invoked when an error is detected on the CAN bus.

The mutex protecting the CAN network interface will be locked when this function is called.

Parameters
errorthe detected errors (any combination of CanError::BIT, CanError::STUFF, CanError::CRC, CanError::FORM, CanError::ACK and CanError::OTHER).

Definition at line 208 of file can_net.hpp.


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