namespace canary
{
class frame_header;
}
class frame_header
{
public:
frame_header() = default;
void id(std::uint32_t value);
std::uint32_t id() const noexcept;
void error(bool value);
bool error() const noexcept;
void remote_transmission(bool value);
bool remote_transmission() const noexcept;
void extended_format(bool value);
bool extended_format() const noexcept;
void payload_length(std::size_t n);
std::size_t payload_length() const noexcept;
};
A CAN frame header, used for transmission of both standard and flexible data rate frames.
frame_header() = default;
Default constructor, performs zero-initialization.
void id(std::uint32_t value);
Sets the CAN ID of this frame. CAN IDs are 29-bit integers for extended-format frames and 11-bit for standard-format frames.
value
- the integral value of the ID.
std::uint32_t id() const noexcept;
Gets the CAN ID of this frame. CAN IDs are 29-bit integers for extended-format frames and 11-bit for standard-format frames.
Returns: The CAN ID of this frame.
void error(bool value);
Sets the error flag of this frame.
Notes: Transmitting an error frame over SocketCAN may not be meaningful.
value
- The value of the flag. True indicates this frame will be an error frame.
bool error() const noexcept;
Gets the error flag of this frame.
Notes: Transmitting an error frame over SocketCAN may not be meaningful.
Returns: The value of the flag. True indicates this frame is an error frame.
void remote_transmission(bool value);
Sets the remote transmission flag of this frame.
Notes: Frames with this flag enabled must not contain a payload.
value
- The value of the flag. True indicates this frame will be a remote transmission request.
bool remote_transmission() const noexcept;
Gets the remote transmission flag of this frame.
Notes: Frames with this flag enabled must not contain a payload.
Returns: The value of the flag. True indicates this frame is a remote transmission request.
void extended_format(bool value);
Sets the extended format flag. The flag determines whether this frame uses 29-bit CAN IDs.
value
- The value of the flag. True indicates this frame will use the extended format.
bool extended_format() const noexcept;
Gets the extended format flag. The flag determines whether this frame uses 29-bit CAN IDs.
Returns: The value of the flag. True indicates this frame uses the extended format.
void payload_length(std::size_t n);
Sets the payload length of this frame.
Notes: payload length must not exceed 8 bytes for standard data rate frames and 64 bytes for flexible data rate frames.
n
- The length of the payload.
std::size_t payload_length() const noexcept;
Gets the payload length of this frame.
Notes: payload length must not exceed 8 bytes for standard data rate frames and 64 bytes for flexible data rate frames.
Returns: The length of the payload.