Lely core libraries  2.2.5
can_rt.h
Go to the documentation of this file.
1 
29 #ifndef LELY_IO2_CAN_RT_H_
30 #define LELY_IO2_CAN_RT_H_
31 
32 #include <lely/io2/can.h>
33 #include <lely/util/rbtree.h>
34 
36 typedef struct io_can_rt io_can_rt_t;
37 
46  const struct can_msg *msg;
48  int errc;
49 };
50 
57  uint_least32_t id;
64  uint_least8_t flags;
69  struct ev_task task;
72  struct rbnode _node;
73  struct sllist _queue;
74 };
75 
77 #define IO_CAN_RT_READ_MSG_INIT(id, flags, func) \
78  { \
79  (id), (flags), EV_TASK_INIT(NULL, func), { NULL, 0 }, \
80  RBNODE_INIT, \
81  { \
82  NULL, NULL \
83  } \
84  }
85 
94  const struct can_err *err;
96  int errc;
97 };
98 
105  struct ev_task task;
108 };
109 
111 #define IO_CAN_RT_READ_ERR_INIT(func) \
112  { \
113  EV_TASK_INIT(NULL, func), { NULL, 0 } \
114  }
115 
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119 
120 void *io_can_rt_alloc(void);
121 void io_can_rt_free(void *ptr);
122 io_can_rt_t *io_can_rt_init(
123  io_can_rt_t *rt, io_can_chan_t *chan, ev_exec_t *exec);
124 void io_can_rt_fini(io_can_rt_t *rt);
125 
138 
148 
154 
157 
164  io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg);
165 
176  io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg);
177 
187  io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg);
188 
205 ev_future_t *io_can_rt_async_read_msg(io_can_rt_t *rt, uint_least32_t id,
206  uint_least8_t flags, struct io_can_rt_read_msg **pread_msg);
207 
214  io_can_rt_t *rt, struct io_can_rt_read_err *read_err);
215 
226  io_can_rt_t *rt, struct io_can_rt_read_err *read_err);
227 
237  io_can_rt_t *rt, struct io_can_rt_read_err *read_err);
238 
253  io_can_rt_t *rt, struct io_can_rt_read_err **pread_err);
254 
265 
271 
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif // !LELY_IO2_CAN_RT_H_
size_t io_can_rt_cancel_read_err(io_can_rt_t *rt, struct io_can_rt_read_err *read_err)
Cancels the specified CAN error frame read operation if it is pending.
Definition: can_rt.c:417
io_can_rt_t * io_can_rt_create(io_can_chan_t *chan, ev_exec_t *exec)
Creates a new CAN frame router.
Definition: can_rt.c:220
void io_can_rt_submit_read_err(io_can_rt_t *rt, struct io_can_rt_read_err *read_err)
Submits a CAN error frame read operation to a CAN frame router.
Definition: can_rt.c:384
io_dev_t * io_can_rt_get_dev(const io_can_rt_t *rt)
Returns a pointer to the abstract I/O device representing the CAN frame router.
Definition: can_rt.c:256
size_t io_can_rt_abort_read_err(io_can_rt_t *rt, struct io_can_rt_read_err *read_err)
Aborts the specified CAN error frame read operation if it is pending.
Definition: can_rt.c:440
ev_future_t * io_can_rt_async_read_err(io_can_rt_t *rt, struct io_can_rt_read_err **pread_err)
Submits an asynchronous CAN error frame read operation to a CAN frame router and creates a future whi...
Definition: can_rt.c:462
size_t io_can_rt_abort_read_msg(io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg)
Aborts the specified CAN frame read operation if it is pending.
Definition: can_rt.c:337
void io_can_rt_destroy(io_can_rt_t *rt)
Destroys a CAN frame router.
Definition: can_rt.c:247
struct io_can_rt_read_err * io_can_rt_read_err_from_task(struct ev_task *task)
Obtains a pointer to a CAN error frame read operation from a pointer to its completion task.
Definition: can_rt.c:512
ev_future_t * io_can_rt_async_read_msg(io_can_rt_t *rt, uint_least32_t id, uint_least8_t flags, struct io_can_rt_read_msg **pread_msg)
Submits an asynchronous CAN frame read operation to a CAN frame router and creates a future which bec...
Definition: can_rt.c:359
void io_can_rt_submit_read_msg(io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg)
Submits a CAN frame read operation to a CAN frame router.
Definition: can_rt.c:272
struct io_can_rt_read_msg * io_can_rt_read_msg_from_task(struct ev_task *task)
Obtains a pointer to a CAN frame read operation from a pointer to its completion task.
Definition: can_rt.c:506
size_t io_can_rt_cancel_read_msg(io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg)
Cancels the specified CAN frame read operation if it is pending.
Definition: can_rt.c:314
io_can_chan_t * io_can_rt_get_chan(const io_can_rt_t *rt)
Returns a pointer to the CAN channel used by the CAN frame router.
Definition: can_rt.c:264
ev_future_t * io_can_rt_async_shutdown(io_can_rt_t *rt)
Shuts down a CAN frame router, cancels all pending operations and creates a (void) future which becom...
Definition: can_rt.c:486
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_dev_vtbl *const io_dev_t
An abstract I/O device.
Definition: dev.h:35
This header file is part of the utilities library; it contains the red-black tree declarations.
A CAN error frame.
Definition: err.h:28
A CAN or CAN FD format frame.
Definition: msg.h:87
A future.
Definition: future.c:63
An executable task.
Definition: task.h:41
The result of a CAN error frame read operation.
Definition: can_rt.h:87
const struct can_err * err
A pointer to the received CAN error frame, or NULL on error (or if the operation is canceled).
Definition: can_rt.h:94
int errc
The error number, obtained as if by get_errc(), if err is NULL.
Definition: can_rt.h:96
A CAN error frame read operation suitable for use with a CAN frame router.
Definition: can_rt.h:100
struct io_can_rt_read_err_result r
The result of the read operation.
Definition: can_rt.h:107
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the read operation.
Definition: can_rt.h:105
The result of a CAN frame read operation.
Definition: can_rt.h:39
int errc
The error number, obtained as if by get_errc(), if msg is NULL.
Definition: can_rt.h:48
const struct can_msg * msg
A pointer to the received CAN frame, or NULL on error (or if the operation is canceled).
Definition: can_rt.h:46
A CAN frame read operation suitable for use with a CAN frame router.
Definition: can_rt.h:52
uint_least32_t id
The identifier of the CAN frame to be received.
Definition: can_rt.h:57
struct io_can_rt_read_msg_result r
The result of the read operation.
Definition: can_rt.h:71
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the read operation.
Definition: can_rt.h:69
uint_least8_t flags
The flags of the CAN frame to be received (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR,...
Definition: can_rt.h:64
A node in a red-black tree.
Definition: rbtree.h:52
A singly-linked list.
Definition: sllist.h:51