24 #ifndef LELY_IO2_VCAN_HPP_ 25 #define LELY_IO2_VCAN_HPP_ 41 int nominal = 0,
int data = 0,
45 static_cast<int>(state))) {
46 if (!ctrl) util::throw_errc(
"VirtualCanController");
61 swap(ctrl, other.ctrl);
76 write(
const can_msg& msg,
int timeout, ::std::error_code& ec) noexcept {
90 write(msg, timeout, ec);
91 if (ec) throw ::std::system_error(ec,
"write");
96 write(
const can_err& err,
int timeout, ::std::error_code& ec) noexcept {
109 ::std::error_code ec;
110 write(err, timeout, ec);
111 if (ec) throw ::std::system_error(ec,
"write");
121 if (!chan) util::throw_errc(
"VirtualCanChannel");
128 other.chan =
nullptr;
137 swap(chan, other.chan);
138 swap(dev, other.dev);
173 #endif // !LELY_IO2_VCAN_HPP_ A CAN or CAN FD format frame.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
void io_vcan_chan_open(io_can_chan_t *chan, io_can_ctrl_t *ctrl)
Opens a virtual CAN channel by registering it with the specified virtual CAN controller.
void io_vcan_chan_close(io_can_chan_t *chan)
Closes a virtual CAN channel.
void io_vcan_ctrl_set_state(io_can_ctrl_t *ctrl, int state)
Sets the state of a virtual CAN bus: one of CAN_STATE_ACTIVE, CAN_STATE_PASSIVE, CAN_STATE_BUSOFF, CAN_STATE_SLEEPING or CAN_STATE_STOPPED.
io_can_chan_t * io_vcan_chan_create(io_ctx_t *ctx, ev_exec_t *exec, size_t rxlen)
Creates a new virtual CAN channel.
CanControllerBase get_ctrl() const noexcept
void write(const can_msg &msg, int timeout, ::std::error_code &ec) noexcept
void set_state(CanState state)
int io_vcan_chan_is_open(const io_can_chan_t *chan)
Returns 1 if the CAN channel is open and 0 if not.
CanState
The states of a CAN node, depending on the TX/RX error count.
CanBusFlag
The CAN bus flags.
const struct io_clock_vtbl *const io_clock_t
An abstract clock.
int io_vcan_ctrl_write_err(io_can_ctrl_t *ctrl, const struct can_err *err, int timeout)
Writes a CAN error frame to a all virtual CAN channels registered with a virtual CAN controller...
VirtualCanChannel(io_ctx_t *ctx, ev_exec_t *exec, size_t rxlen=0)
void write(const can_err &err, int timeout, ::std::error_code &ec) noexcept
This header file is part of the I/O library; it contains the virtual CAN bus declarations.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
io_can_ctrl_t * io_vcan_chan_get_ctrl(const io_can_chan_t *chan)
Returns a pointer to the virtual CAN controller with which a virtual CAN channel is registered...
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
io_can_ctrl_t * io_vcan_ctrl_create(io_clock_t *clock, int flags, int nominal, int data, int state)
Creates a new virtual CAN controller.
VirtualCanController(io_clock_t *clock, CanBusFlag flags=CanBusFlag::MASK, int nominal=0, int data=0, CanState state=CanState::ACTIVE)
void open(const io_can_ctrl_t *ctrl) noexcept
This header file is part of the I/O library; it contains the C++ interface for the abstract clock...
int io_vcan_ctrl_write_msg(io_can_ctrl_t *ctrl, const struct can_msg *msg, int timeout)
Writes a CAN frame to a all virtual CAN channels registered with a virtual CAN controller.
bool is_open() const noexcept
A virtual CAN controller.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
const struct io_can_ctrl_vtbl *const io_can_ctrl_t
An abstract CAN controller.
A reference to an abstract CAN controller.
void write(const can_msg &msg, int timeout=-1)
void io_vcan_chan_destroy(io_can_chan_t *chan)
Destroys a virtual CAN channel.
This header file is part of the I/O library; it contains the C++ interface for the abstract CAN bus...
void write(const can_err &err, int timeout=-1)
void io_vcan_ctrl_destroy(io_can_ctrl_t *ctrl)
Destroys a virtual CAN controller.
A reference to an abstract CAN channel.