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;
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*.
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.
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...
inline ::std::error_code make_error_code(int errc=get_errc()) noexcept
Creates an error code value corresponding to the specified or current (thread-specific) native error ...
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.
A CAN or CAN FD format frame.
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.
A time type with nanosecond resolution.
inline ::std::chrono::nanoseconds from_timespec(const timespec &ts) noexcept
Converts a C11 time interval to a C++11 duration.