24#ifndef LELY_IO2_USER_CAN_HPP_
25#define LELY_IO2_USER_CAN_HPP_
46 if (!chan) util::throw_errc(
"UserCanChannel");
56 UserCanChannel& operator=(
const UserCanChannel&) =
delete;
59 operator=(UserCanChannel&&
other)
noexcept {
61 swap(chan,
other.chan);
72 ::std::error_code& ec)
noexcept {
73 auto ts = util::to_timespec(
d);
79 ec = util::make_error_code();
89 if (ec) throw ::std::system_error(ec,
"on_read");
100 ec = util::make_error_code();
107 ::std::error_code ec;
109 if (ec) throw ::std::system_error(ec,
"on_read");
115 ::std::error_code& ec)
noexcept {
116 auto ts = util::to_timespec(
d);
122 ec = util::make_error_code();
130 ::std::error_code ec;
132 if (ec) throw ::std::system_error(ec,
"on_read");
143 ec = util::make_error_code();
150 ::std::error_code ec;
152 if (ec) throw ::std::system_error(ec,
"on_read");
A reference to an abstract CAN channel.
A user-defined CAN channel.
void on_read(const can_msg *msg, const ::std::chrono::nanoseconds &d, int timeout=-1)
void on_read(const can_msg *msg, int timeout=-1)
void on_read(const can_err *err, int timeout=-1)
UserCanChannel(io_ctx_t *ctx, ev_exec_t *exec, CanBusFlag flags=CanBusFlag::NONE, size_t rxlen=0, int txtime=0, io_user_can_chan_write_t *func=nullptr, void *arg=nullptr)
void on_read(const can_err *err, const ::std::chrono::nanoseconds &d, int timeout=-1)
void on_read(const can_err *err, const ::std::chrono::nanoseconds &d, int timeout, ::std::error_code &ec) noexcept
void on_read(const can_msg *msg, int timeout, ::std::error_code &ec) noexcept
void on_read(const can_msg *msg, const ::std::chrono::nanoseconds &d, int timeout, ::std::error_code &ec) noexcept
void on_read(const can_err *err, int timeout, ::std::error_code &ec) noexcept
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
This header file is part of the I/O library; it contains the user-defined CAN channel declarations.
io_can_chan_t * io_user_can_chan_create(io_ctx_t *ctx, ev_exec_t *exec, int flags, size_t rxlen, int txtimeo, io_user_can_chan_write_t *func, void *arg)
Creates a new user-defined CAN channel.
void io_user_can_chan_destroy(io_can_chan_t *chan)
Destroys a user-defined CAN channel.
int io_user_can_chan_on_msg(io_can_chan_t *chan, const struct can_msg *msg, const struct timespec *tp, int timeout)
Processes an incoming CAN frame.
int io_user_can_chan_on_err(io_can_chan_t *chan, const struct can_err *err, const struct timespec *tp, int timeout)
Processes an incoming CAN error frame.
int io_user_can_chan_write_t(const struct can_msg *msg, int timeout, void *arg)
The type of function invoked by a user-defined CAN channel when a CAN frame needs to be written.
This header file is part of the I/O library; it contains the C++ interface for the abstract CAN bus.
CanBusFlag
The CAN bus flags.
A CAN or CAN FD format frame.
This header file is part of the utilities library; it contains the time function declarations.