Lely core libraries  2.2.5
can_net.h
Go to the documentation of this file.
1 
28 #ifndef LELY_IO2_CAN_NET_H_
29 #define LELY_IO2_CAN_NET_H_
30 
31 #include <lely/io2/can.h>
32 #include <lely/io2/tqueue.h>
33 
35 typedef struct io_can_net io_can_net_t;
36 
37 // Avoid including <lely/can/net.h>.
38 #ifdef __cplusplus
39 // clang-format off
40 namespace lely {
41 class CANNet;
42 } // namespace lely
43 // clang-format on
44 #else
45 struct __can_net;
46 #endif
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
62 typedef void io_can_net_on_error_func_t(int errc, size_t errcnt, void *arg);
63 
81  int new_state, int old_state, void *arg);
82 
95 typedef void io_can_net_on_can_error_func_t(int error, void *arg);
96 
97 void *io_can_net_alloc(void);
98 void io_can_net_free(void *ptr);
99 io_can_net_t *io_can_net_init(io_can_net_t *net, ev_exec_t *exec,
100  io_timer_t *timer, io_can_chan_t *chan, size_t txlen,
101  int txtimeo);
102 void io_can_net_fini(io_can_net_t *net);
103 
125  io_can_chan_t *chan, size_t txlen, int txtimeo);
126 
129 
135 void io_can_net_start(io_can_net_t *net);
136 
142 
148 
151 
154 
168  io_can_net_on_error_func_t **pfunc, void **parg);
169 
183  io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg);
184 
199  io_can_net_on_error_func_t **pfunc, void **parg);
200 
215  io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg);
216 
230  io_can_net_on_error_func_t **pfunc, void **parg);
231 
245  io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg);
246 
259  io_can_net_on_can_state_func_t **pfunc, void **parg);
260 
273  io_can_net_on_can_state_func_t *func, void *arg);
274 
287  io_can_net_on_can_error_func_t **pfunc, void **parg);
288 
301  io_can_net_on_can_error_func_t *func, void *arg);
302 
311 int io_can_net_lock(io_can_net_t *net);
312 
322 
331 #ifdef __cplusplus
333 #else
334 struct __can_net *io_can_net_get_net(const io_can_net_t *net);
335 #endif
336 
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif // !LELY_IO2_CAN_NET_H_
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 ...
Definition: can_net.c:490
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.
Definition: can_net.c:592
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.
Definition: can_net.c:440
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.
Definition: can_net.c:377
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...
Definition: can_net.c:472
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.
Definition: can_net.c:464
void io_can_net_start(io_can_net_t *net)
Starts a CAN network interface and begins processing CAN frames.
Definition: can_net.c:415
int io_can_net_unlock(io_can_net_t *net)
Unlocks the mutex protecting the CAN network interface.
Definition: can_net.c:656
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,...
Definition: can_net.c:524
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...
Definition: can_net.c:540
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,...
Definition: can_net.c:506
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.
Definition: can_net.c:574
int io_can_net_set_time(io_can_net_t *net)
Updates the CAN network time.
Definition: can_net.c:679
void io_can_net_destroy(io_can_net_t *net)
Destroys a CAN network interface.
Definition: can_net.c:406
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.
Definition: can_net.c:626
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.
Definition: can_net.c:608
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.
Definition: can_net.h:80
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.
Definition: can_net.c:456
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,...
Definition: can_net.h:62
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.
Definition: can_net.c:671
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.
Definition: can_net.c:448
int io_can_net_lock(io_can_net_t *net)
Locks the mutex protecting the CAN network interface.
Definition: can_net.c:642
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.
Definition: can_net.h:95
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...
Definition: can_net.c:558
An opaque CAN network interface type.
Definition: net.hpp:85
const struct io_clock_vtbl *const io_clock_t
An abstract clock.
Definition: clock.h:36
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
This header file is part of the I/O library; it contains the abstract CAN bus interface.
const struct io_can_chan_vtbl *const io_can_chan_t
An abstract CAN channel.
Definition: can.h:59
const struct io_timer_vtbl *const io_timer_t
An abstract timer.
Definition: timer.h:38
A CAN network interface.
Definition: net.c:37
The implementation of a CAN network interface.
Definition: can_net.c:65
Definition: ctx.c:35
This header file is part of the I/O library; it contains the timer queue declarations.