25#ifndef LELY_IO2_CO_CAN_HPP_
26#define LELY_IO2_CO_CAN_HPP_
42 ::std::chrono::nanoseconds* dp =
nullptr,
45 msg,
err, dp ? &ts_ :
nullptr, exec,
48 auto result = read->r.result;
52 if (self->dp_) *self->dp_ = util::from_timespec(self->ts_);
57 virtual ~CoCanChannelRead() =
default;
75 virtual void operator()(
int result, ::std::error_code ec)
noexcept = 0;
79 ::std::chrono::nanoseconds* dp_{
nullptr};
98 virtual ~CoCanChannelWrite() =
default;
An abstract task executor. This class is a wrapper around #ev_exec_t*.
A CAN channel read operation with a stackless coroutine as the completion task.
virtual void operator()(int result, ::std::error_code ec) noexcept=0
The coroutine to be executed once the read operation completes (or is canceled).
ev::Executor get_executor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
CoCanChannelRead(can_msg *msg, can_err *err=nullptr, ::std::chrono::nanoseconds *dp=nullptr, ev_exec_t *exec=nullptr) noexcept
Constructs a read operation.
A CAN channel write operation with a stackless coroutine as the completion task.
ev::Executor get_executor() const noexcept
Returns the executor to which the completion task is (to be) submitted.
CoCanChannelWrite(const can_msg *msg, ev_exec_t *exec=nullptr) noexcept
Constructs a write operation.
virtual void operator()(::std::error_code ec) noexcept=0
The coroutine to be executed once the write operation completes (or is canceled).
The parent class for function objects used as stackless coroutines.
This header file is part of the utilities library; it contains the C++ implementation of stackless co...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
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.
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.
#define IO_CAN_CHAN_WRITE_INIT(msg, exec, func)
The static initializer for io_can_chan_write.
#define IO_CAN_CHAN_READ_INIT(msg, err, tp, exec, func)
The static initializer for io_can_chan_read.
This header file is part of the I/O library; it contains the C++ interface for the abstract CAN bus.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
A CAN or CAN FD format frame.
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
A CAN channel read operation.
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the read operation.
struct can_msg * msg
The address at which to store the CAN frame.
struct can_err * err
The address at which to store the CAN error frame.
A CAN channel write operation.
const struct can_msg * msg
A pointer to the CAN frame to be written.
struct ev_task task
The task (to be) submitted upon completion (or cancellation) of the write operation.