24 #ifndef LELY_IO2_LINUX_CAN_HPP_
25 #define LELY_IO2_LINUX_CAN_HPP_
41 if (!ctrl) util::throw_errc(
"CanController");
47 if (!ctrl) util::throw_errc(
"CanController");
62 swap(ctrl, other.ctrl);
71 get_name() const noexcept {
77 get_index() const noexcept {
83 get_flags() const noexcept {
94 if (!chan) util::throw_errc(
"CanChannel");
100 other.chan =
nullptr;
109 swap(chan, other.chan);
110 swap(dev, other.dev);
126 ::std::error_code& ec) noexcept {
139 ::std::error_code ec;
140 open(ctrl, flags, ec);
141 if (ec) throw ::std::system_error(ec,
"open");
146 assign(
int fd, ::std::error_code& ec) noexcept {
159 ::std::error_code ec;
161 if (ec) throw ::std::system_error(ec,
"assign");
178 close(::std::error_code& ec) noexcept {
191 ::std::error_code ec;
193 if (ec) throw ::std::system_error(ec,
"close");
A reference to an abstract CAN channel.
void assign(int fd, ::std::error_code &ec) noexcept
void open(const io_can_ctrl_t *ctrl, CanBusFlag flags=CanBusFlag::NONE)
CanChannel(io_poll_t *poll, ev_exec_t *exec, ::std::size_t rxlen=0)
int get_handle() const noexcept
void open(const io_can_ctrl_t *ctrl, CanBusFlag flags, ::std::error_code &ec) noexcept
bool is_open() const noexcept
void close(::std::error_code &ec) noexcept
A reference to an abstract CAN controller.
CanController(const char *name, ::std::size_t txlen=0)
CanController(unsigned int index, ::std::size_t txlen=0)
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.
const struct io_can_ctrl_vtbl *const io_can_ctrl_t
An abstract CAN controller.
This header file is part of the I/O library; it contains the CAN bus declarations for Linux.
void io_can_chan_destroy(io_can_chan_t *chan)
Destroys a CAN channel.
unsigned int io_can_ctrl_get_index(const io_can_ctrl_t *ctrl)
Returns the interface index of a CAN controller.
int io_can_chan_get_handle(const io_can_chan_t *chan)
Returns the SocketCAN file descriptor associated with a CAN channel, or -1 if the channel is closed.
int io_can_ctrl_get_flags(const io_can_ctrl_t *ctrl)
Returns the flags specifying which CAN bus features are enabled.
int io_can_chan_close(io_can_chan_t *chan)
Closes the SocketCAN file descriptor associated with a CAN channel.
io_can_ctrl_t * io_can_ctrl_create_from_index(unsigned int index, size_t txlen)
Creates a new CAN controller from an interface index.
int io_can_chan_open(io_can_chan_t *chan, const io_can_ctrl_t *ctrl, int flags)
Opens a CAN channel.
int io_can_chan_release(io_can_chan_t *chan)
Dissociates and returns the SocketCAN file descriptor from a CAN channel.
int io_can_chan_assign(io_can_chan_t *chan, int fd)
Assigns an existing SocketCAN file descriptor to a CAN channel.
io_can_chan_t * io_can_chan_create(io_poll_t *poll, ev_exec_t *exec, size_t rxlen)
Creates a new CAN channel.
const char * io_can_ctrl_get_name(const io_can_ctrl_t *ctrl)
Returns the interface name of a CAN controller.
int io_can_chan_is_open(const io_can_chan_t *chan)
Returns 1 if the CAN channel is open and 0 if not.
io_can_ctrl_t * io_can_ctrl_create_from_name(const char *name, size_t txlen)
Creates a new CAN controller from an interface name.
void io_can_ctrl_destroy(io_can_ctrl_t *ctrl)
Destroys a CAN controller.
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.
::std::error_code make_error_code(SdoErrc e) noexcept
Creates an error code corresponding to an SDO abort code.
An I/O polling interface.