Lely core libraries
2.3.4
|
Go to the documentation of this file.
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_
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,...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
void open(const io_can_ctrl_t *ctrl) noexcept
void write(const can_err &err, int timeout=-1)
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.
A CAN or CAN FD format frame.
A virtual CAN controller.
void io_vcan_chan_destroy(io_can_chan_t *chan)
Destroys a virtual CAN channel.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_state(CanState state)
A reference to an abstract CAN channel.
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.
CanBusFlag
The CAN bus flags.
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.
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,...
CanState
The states of a CAN node, depending on the TX/RX error count.
VirtualCanController(io_clock_t *clock, CanBusFlag flags=CanBusFlag::MASK, int nominal=0, int data=0, CanState state=CanState::ACTIVE)
void write(const can_err &err, int timeout, ::std::error_code &ec) noexcept
void io_vcan_chan_close(io_can_chan_t *chan)
Closes a virtual CAN channel.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
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.
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_ctrl_destroy(io_can_ctrl_t *ctrl)
Destroys a virtual CAN controller.
VirtualCanChannel(io_ctx_t *ctx, ev_exec_t *exec, size_t rxlen=0)
CanControllerBase get_ctrl() const noexcept
A reference to an abstract CAN controller.
void write(const can_msg &msg, int timeout=-1)
bool is_open() const noexcept
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
const struct io_clock_vtbl *const io_clock_t
An abstract clock.
void write(const can_msg &msg, int timeout, ::std::error_code &ec) noexcept
int io_vcan_chan_is_open(const io_can_chan_t *chan)
Returns 1 if the CAN channel is open and 0 if not.
const struct io_can_ctrl_vtbl *const io_can_ctrl_t
An abstract CAN controller.