Lely core libraries
2.3.4
|
Go to the documentation of this file.
24 #ifndef LELY_IO2_CAN_NET_HPP_
25 #define LELY_IO2_CAN_NET_HPP_
42 ::std::size_t txlen = 0,
int txtimeo = 0)
48 &on_queue_error_arg_);
51 &on_write_error_arg_);
63 ::std::size_t txlen = 0,
int txtimeo = 0)
64 :
CanNet(nullptr, timer, chan, txlen, txtimeo) {}
142 on_read_error_func_(ec.value(), errcnt, on_read_error_arg_);
159 on_queue_error_func_(ec.value(), errcnt, on_queue_error_arg_);
176 on_write_error_func_(ec.value(), errcnt, on_write_error_arg_);
193 on_can_state_func_(
static_cast<int>(new_state),
static_cast<int>(old_state),
210 on_can_error_func_(
static_cast<int>(
error), on_can_error_arg_);
215 on_read_error_(
int errc,
size_t errcnt,
void* arg) noexcept {
221 on_queue_error_(
int errc,
size_t errcnt,
void* arg) noexcept {
227 on_write_error_(
int errc,
size_t errcnt,
void* arg) noexcept {
233 on_can_state_(
int new_state,
int old_state,
void* arg) noexcept {
239 on_can_error_(
int error,
void* arg) noexcept {
245 void* on_read_error_arg_{
nullptr};
247 void* on_queue_error_arg_{
nullptr};
249 void* on_write_error_arg_{
nullptr};
251 void* on_can_state_arg_{
nullptr};
253 void* on_can_error_arg_{
nullptr};
259 #endif // !LELY_IO2_CAN_NET_HPP_
void io_can_net_set_on_queue_error_func(io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg)
Sets the function invoked when a CAN frame is dropped because the transmit queue is full,...
void io_can_net_get_on_read_error_func(const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg)
Retrieves the function invoked when a new CAN frame read error occurs, or when a read operation compl...
void io_can_net_start(io_can_net_t *net)
Starts a CAN network interface and begins processing CAN frames.
An abstract interface conforming to the BasicLockable concept.
ev_exec_t * io_can_net_get_exec(const io_can_net_t *net)
Returns a pointer to the executor used by the CAN network interface to execute asynchronous tasks.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
void set_time()
Updates the CAN network time.
int io_can_net_lock(io_can_net_t *net)
Locks the mutex protecting the CAN network interface.
void io_can_net_on_can_error_func_t(int error, void *arg)
The type of function invoked when a CAN bus error is detected by an CAN network interface.
void io_can_net_set_on_can_state_func(io_can_net_t *net, io_can_net_on_can_state_func_t *func, void *arg)
Sets the function to be invoked when a CAN bus state change is detected.
A refence to an I/O context. This class is a wrapper around #io_ctx_t*.
The type of objects thrown as exceptions to report a system error with an associated error code.
void io_can_net_get_on_can_error_func(const io_can_net_t *net, io_can_net_on_can_error_func_t **pfunc, void **parg)
Retrieves the function invoked when a CAN bus error is detected.
virtual void on_can_state(CanState new_state, CanState old_state) noexcept
The function invoked when a CAN bus state change is detected.
ev::Executor get_executor() const noexcept
CanError
The error flags of a CAN bus, which are not mutually exclusive.
CanState
The states of a CAN node, depending on the TX/RX error count.
void io_can_net_get_on_write_error_func(const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg)
Retrieves the function invoked when a new CAN frame write error occurs, or when a write operation com...
void io_can_net_get_on_can_state_func(const io_can_net_t *net, io_can_net_on_can_state_func_t **pfunc, void **parg)
Retrieves the function invoked when a CAN bus state change is detected.
Clock get_clock() const noexcept
const struct io_can_chan_vtbl *const io_can_chan_t
An abstract CAN channel.
void lock() final
Blocks until a lock can be obtained for the current execution agent (thread, process,...
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 succe...
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 suc...
void io_can_net_destroy(io_can_net_t *net)
Destroys a CAN network interface.
An abstract task executor. This class is a wrapper around #ev_exec_t*.
virtual void on_can_error(CanError error) noexcept
The function invoked when an error is detected on the CAN bus.
CanNet(ev_exec_t *exec, io_timer_t *timer, io_can_chan_t *chan, ::std::size_t txlen=0, int txtimeo=0)
ContextBase get_ctx() const noexcept
io_clock_t * io_can_net_get_clock(const io_can_net_t *net)
Returns a pointer to the clock used by the CAN network interface.
void io_can_net_set_on_can_error_func(io_can_net_t *net, io_can_net_on_can_error_func_t *func, void *arg)
Sets the function to be invoked when a CAN bus error is detected.
io_can_net_t * io_can_net_create(ev_exec_t *exec, io_timer_t *timer, io_can_chan_t *chan, size_t txlen, int txtimeo)
Creates a new CAN network interface.
void io_can_net_on_can_state_func_t(int new_state, int old_state, void *arg)
The type of function invoked when a CAN bus state change is detected by a CAN network interface.
An abstract clock. This class is a wrapper around #io_clock_t*.
void unlock() final
Releases the lock held by the execution agent. Throws no exceptions.
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,...
io_ctx_t * io_can_net_get_ctx(const io_can_net_t *net)
Returns a pointer to the I/O context with which the CAN network interface is registered.
struct __can_net * io_can_net_get_net(const io_can_net_t *net)
Returns a pointer to the internal interface of a CAN network interface.
The implementation of a CAN network interface.
int io_can_net_unlock(io_can_net_t *net)
Unlocks the mutex protecting the CAN network interface.
int io_can_net_set_time(io_can_net_t *net)
Updates the CAN network time.
const struct io_timer_vtbl *const io_timer_t
An abstract timer.
CanNet(io_timer_t *timer, io_can_chan_t *chan, ::std::size_t txlen=0, int txtimeo=0)
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
void io_can_net_set_on_read_error_func(io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg)
Sets the function invoked when a new CAN frame read error occurs, or when a read operation completes ...
io_tqueue_t * io_can_net_get_tqueue(const io_can_net_t *net)
Returns a pointer to the internal timer queue of a CAN network interface.
void io_can_net_on_error_func_t(int errc, size_t errcnt, void *arg)
The type of function invoked when an error occurs during a CAN network interface operations,...
A CAN network interface. This class is a wrapper around io_can_net_t*.
void io_can_net_set_on_write_error_func(io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg)
Sets the function invoked when a new CAN frame write error occurs, or when a write operation complete...
void io_can_net_get_on_queue_error_func(const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg)
Retrieves the function invoked when a CAN frame is dropped because the transmit queue is full,...