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");
200 #endif // !LELY_IO2_LINUX_CAN_HPP_ int get_handle() const noexcept
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
int io_can_chan_close(io_can_chan_t *chan)
Closes the SocketCAN file descriptor associated with a CAN channel.
int io_can_ctrl_get_flags(const io_can_ctrl_t *ctrl)
Returns the flags specifying which CAN bus features are enabled.
void assign(int fd, ::std::error_code &ec) noexcept
An I/O polling interface.
unsigned int io_can_ctrl_get_index(const io_can_ctrl_t *ctrl)
Returns the interface index of a CAN controller.
void close(::std::error_code &ec) noexcept
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_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_chan_is_open(const io_can_chan_t *chan)
Returns 1 if the CAN channel is open and 0 if not.
CanBusFlag
The CAN bus flags.
void io_can_ctrl_destroy(io_can_ctrl_t *ctrl)
Destroys a CAN controller.
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.
CanController(unsigned int index, ::std::size_t txlen=0)
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
CanChannel(io_poll_t *poll, ev_exec_t *exec, ::std::size_t rxlen=0)
int io_can_chan_release(io_can_chan_t *chan)
Dissociates and returns the SocketCAN file descriptor from 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.
void open(const io_can_ctrl_t *ctrl, CanBusFlag flags, ::std::error_code &ec) noexcept
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.
void open(const io_can_ctrl_t *ctrl, CanBusFlag flags=CanBusFlag::NONE)
bool is_open() const noexcept
int io_can_chan_assign(io_can_chan_t *chan, int fd)
Assigns an existing SocketCAN file descriptor to a CAN channel.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
This header file is part of the I/O library; it contains the CAN bus declarations for Linux...
CanController(const char *name, ::std::size_t txlen=0)
void io_can_chan_destroy(io_can_chan_t *chan)
Destroys a CAN channel.
::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.
This header file is part of the I/O library; it contains the C++ interface for the abstract CAN bus...
int io_can_chan_open(io_can_chan_t *chan, const io_can_ctrl_t *ctrl, int flags)
Opens a CAN channel.
A reference to an abstract CAN channel.