Lely core libraries
2.3.4
|
Go to the documentation of this file.
22 #ifndef LELY_IO2_CAN_H_
23 #define LELY_IO2_CAN_H_
32 #ifndef LELY_IO_CAN_INLINE
33 #define LELY_IO_CAN_INLINE static inline
46 IO_CAN_BUS_FLAG_NONE = 0,
104 #define IO_CAN_CHAN_READ_INIT(msg, err, tp, exec, func) \
106 (msg), (err), (tp), EV_TASK_INIT(exec, func), { 0, 0 } \
130 #define IO_CAN_CHAN_WRITE_INIT(msg, exec, func) \
132 (msg), EV_TASK_INIT(exec, func), 0 \
145 int (*set_bitrate)(
io_can_ctrl_t *ctrl,
int nominal,
int data);
153 struct can_err *err,
struct timespec *tp,
int timeout);
157 void (*submit_write)(
411 return (*ctrl)->stop(ctrl);
417 return (*ctrl)->stopped(ctrl);
423 return (*ctrl)->restart(ctrl);
429 return (*ctrl)->get_bitrate(ctrl, pnominal, pdata);
435 return (*ctrl)->set_bitrate(ctrl, nominal, data);
441 return (*ctrl)->get_state(ctrl);
471 return (*chan)->get_dev(chan);
477 return (*chan)->get_flags(chan);
482 struct timespec *tp,
int timeout)
484 return (*chan)->read(chan,
msg, err, tp, timeout);
490 (*chan)->submit_read(chan, read);
508 return (*chan)->write(chan,
msg, timeout);
514 (*chan)->submit_write(chan, write);
533 #endif // !LELY_IO2_CAN_H_
static size_t io_can_chan_abort_read(io_can_chan_t *chan, struct io_can_chan_read *read)
Aborts the specified CAN channel read operation if it is pending.
The result of a CAN channel read operation.
int io_can_ctrl_restart(io_can_ctrl_t *ctrl)
(Re)starts a CAN contoller.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
ev_exec_t * io_dev_get_exec(const io_dev_t *dev)
Returns a pointer to the executor used by the I/O device to execute asynchronous tasks.
struct io_can_chan_read * io_can_chan_read_from_task(struct ev_task *task)
Obtains a pointer to a CAN channel read operation from a pointer to its completion task.
@ IO_CAN_BUS_FLAG_ERR
Reception of error frames is enabled.
int io_can_chan_get_flags(const io_can_chan_t *chan)
Returns the flafs of the CAN bus: any combination of IO_CAN_BUS_FLAG_ERR, IO_CAN_BUS_FLAG_FDF and IO_...
A CAN or CAN FD format frame.
static size_t io_can_chan_cancel(io_can_chan_t *chan, struct ev_task *task)
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the write operation.
int errc
The error number, obtained as if by get_errc(), if an error occurred or the operation was canceled.
io_ctx_t * io_dev_get_ctx(const io_dev_t *dev)
Returns a pointer to the I/O context with which the I/O device is registered.
int io_can_chan_read(io_can_chan_t *chan, struct can_msg *msg, struct can_err *err, struct timespec *tp, int timeout)
Reads a CAN frame or CAN error frame from a CAN channel.
ev_future_t * io_can_chan_async_write(io_can_chan_t *chan, ev_exec_t *exec, const struct can_msg *msg, struct io_can_chan_write **pwrite)
Submits an asynchronous write operation to a CAN channel and creates a future which becomes ready onc...
size_t io_dev_cancel(io_dev_t *dev, struct ev_task *task)
Cancels the asynchronous operation submitted to *dev, if its task has not yet been submitted to its e...
A CAN channel read operation.
int errc
The error number, obtained as if by get_errc(), if result is -1.
io_can_bus_flag
The CAN bus flags.
void io_can_chan_submit_write(io_can_chan_t *chan, struct io_can_chan_write *write)
Submits a write operation to a CAN channel.
struct can_msg * msg
The address at which to store the CAN frame.
@ IO_CAN_BUS_FLAG_FDF
FD Format (formerly Extended Data Length) support is enabled.
A CAN channel write operation.
const struct io_can_chan_vtbl *const io_can_chan_t
An abstract CAN channel.
int io_can_ctrl_get_bitrate(const io_can_ctrl_t *ctrl, int *pnominal, int *pdata)
Obtains the bitrate(s) of a CAN controller.
int result
The result of the read operation: 1 if a CAN frame is received, 0 if an error frame is received,...
const struct can_msg * msg
A pointer to the CAN frame to be written.
static size_t io_can_chan_cancel_write(io_can_chan_t *chan, struct io_can_chan_write *write)
Cancels the specified CAN channel write operation if it is pending.
io_dev_t * io_can_chan_get_dev(const io_can_chan_t *chan)
Returns a pointer to the abstract I/O device representing the CAN channel.
ev_future_t * io_can_chan_async_read(io_can_chan_t *chan, ev_exec_t *exec, struct can_msg *msg, struct can_err *err, struct timespec *tp, struct io_can_chan_read **pread)
Submits an asynchronous read operation to a CAN channel and creates a future which becomes ready once...
struct timespec * tp
The address at which to store the system time at which the CAN frame or CAN error frame was received.
static ev_exec_t * io_can_chan_get_exec(const io_can_chan_t *chan)
static size_t io_can_chan_cancel_read(io_can_chan_t *chan, struct io_can_chan_read *read)
Cancels the specified CAN channel read operation if it is pending.
static size_t io_can_chan_abort(io_can_chan_t *chan, struct ev_task *task)
@ IO_CAN_BUS_FLAG_BRS
Bit Rate Switch support is enabled.
struct can_err * err
The address at which to store the CAN error frame.
struct io_can_chan_write * io_can_chan_write_from_task(struct ev_task *task)
Obtains a pointer to a CAN channel write operation from a pointer to its completion task.
int io_can_chan_write(io_can_chan_t *chan, const struct can_msg *msg, int timeout)
Writes a CAN frame to a CAN channel.
const struct io_dev_vtbl *const io_dev_t
An abstract I/O device.
int io_can_ctrl_stop(io_can_ctrl_t *ctrl)
Stops a CAN controller.
static io_ctx_t * io_can_chan_get_ctx(const io_can_chan_t *chan)
int io_can_ctrl_stopped(const io_can_ctrl_t *ctrl)
Returns 1 in the CAN controller is stopped, 0 if not, and -1 on error.
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the read operation.
static size_t io_can_chan_abort_write(io_can_chan_t *chan, struct io_can_chan_write *write)
Aborts the specified CAN channel write operation if it is pending.
int io_can_ctrl_set_bitrate(io_can_ctrl_t *ctrl, int nominal, int data)
Configures the bitrate(s) of a CAN controller.
size_t io_dev_abort(io_dev_t *dev, struct ev_task *task)
Aborts the asynchronous operation submitted to *dev, if its task has not yet been submitted to its ex...
struct io_can_chan_read_result r
The result of the read operation.
int io_can_ctrl_get_state(const io_can_ctrl_t *ctrl)
Returns the state of the CAN controller: one of CAN_STATE_ACTIVE, CAN_STATE_PASSIVE,...
void io_can_chan_submit_read(io_can_chan_t *chan, struct io_can_chan_read *read)
Submits a read operation to a CAN channel.
const struct io_can_ctrl_vtbl *const io_can_ctrl_t
An abstract CAN controller.