22 #ifndef LELY_CAN_BUF_HPP_
23 #define LELY_CAN_BUF_HPP_
26 #error "include <lely/can/buf.h> for the C interface"
44 init(
pointer p, ::std::size_t size) noexcept {
59 explicit CANBuf(::std::size_t size = 0) :
c_base(size) {}
69 size()
const noexcept {
74 capacity()
const noexcept {
79 reserve(::std::size_t n) noexcept {
84 peek(
can_msg* ptr, ::std::size_t n) noexcept {
90 return !!peek(&msg, 1);
94 read(
can_msg* ptr, ::std::size_t n) noexcept {
100 return !!read(&msg, 1);
104 write(
const can_msg* ptr, ::std::size_t n) noexcept {
109 write(
const can_msg& msg) noexcept {
110 return !!write(&msg, 1);
115 ::std::size_t m_size;
116 #ifdef LELY_NO_ATOMICS
117 ::std::size_t m_begin;
119 atomic_size_t m_begin;
121 #ifdef LELY_NO_ATOMICS
This header file is part of the CAN library; it contains the CAN frame buffer declarations.
void can_buf_clear(struct can_buf *buf)
Clears a CAN frame buffer.
size_t can_buf_size(const struct can_buf *buf)
Returns the number of frames available for reading in a CAN buffer.
size_t can_buf_capacity(const struct can_buf *buf)
Returns the number of frames available for writing in a CAN buffer.
size_t can_buf_reserve(struct can_buf *buf, size_t n)
Resizes a CAN frame buffer, if necessary, to make room for at least n additional frames.
size_t can_buf_read(struct can_buf *buf, struct can_msg *ptr, size_t n)
Reads, and removes, frames from a CAN frame buffer.
int can_buf_init(struct can_buf *buf, size_t size)
Initializes a CAN frame buffer.
size_t can_buf_peek(struct can_buf *buf, struct can_msg *ptr, size_t n)
Reads, but does not remove, frames from a CAN frame buffer.
void can_buf_fini(struct can_buf *buf)
Finalizes a CAN frame buffer.
size_t can_buf_write(struct can_buf *buf, const struct can_msg *ptr, size_t n)
Writes frames to a CAN frame buffer.
This header file is part of the utilities library; it contains the C to C++ interface declarations.
The base class for a C++ interface to a standard layout C type.
A CAN or CAN FD format frame.
A class template supplying a uniform interface to certain attributes of C types.