|
Internal Interface Wrap
API reference
|
Platform-agnostic CAN / CAN FD message (BaseCan v2). More...
#include <BaseCan.h>
Public Member Functions | |
| hf_can_message_t () noexcept | |
| constexpr hf_u8_t | GetMaxDataLength () const noexcept |
| Largest payload for the current frame kind (8 classic, 64 FD). | |
| constexpr hf_u8_t | GetLength () const noexcept |
| Payload length in bytes. | |
| constexpr bool | IsValidLength (hf_u8_t len) const noexcept |
Is len a valid payload length for the current frame kind? | |
| bool | SetLength (hf_u8_t len) noexcept |
| Set the payload length in bytes. | |
| constexpr bool | IsValidDLC (hf_u8_t len) const noexcept |
| Same as IsValidLength(); kept for source compatibility. | |
| constexpr hf_u8_t | GetEffectiveDLC () const noexcept |
| Same as GetLength(); kept for source compatibility. | |
| bool | SetDLC (hf_u8_t len) noexcept |
| Same as SetLength(); kept for source compatibility. | |
| constexpr hf_u8_t | GetDlcCode () const noexcept |
| 4-bit DLC code for the current length (HF_CAN_DLC_INVALID if invalid). | |
| bool | SetDlcCode (hf_u8_t code) noexcept |
| Set the length from a 4-bit DLC code (as read from a controller). | |
| bool | SetData (const hf_u8_t *src, hf_u8_t len) noexcept |
Copy len bytes into the payload and set the length. | |
| void | SetStandardFrame () noexcept |
| Set standard frame format (11-bit ID). | |
| void | SetExtendedFrame () noexcept |
| Set extended frame format (29-bit ID). | |
| void | SetDataFrame () noexcept |
| Set data frame (not remote). | |
| void | SetRemoteFrame () noexcept |
| Set remote frame. | |
| void | SetSingleShot () noexcept |
| Set single shot transmission. | |
| void | SetSelfReception () noexcept |
| Set self reception request. | |
| void | SetFdFrame (bool brs=false) noexcept |
| Make this an FD frame. | |
| bool | SetClassicFrame () noexcept |
| Make this a classic frame (clears BRS / ESI). | |
| constexpr hf_u8_t | GetFlags () const noexcept |
| Flags packed as hf_can_flag bits. | |
| bool | SetFlags (hf_u8_t flags) noexcept |
| Set the flags from hf_can_flag bits. | |
| constexpr bool | IsValidId () const noexcept |
| Validate message ID for current frame format. | |
| constexpr hf_can_frame_error_t | Validate () const noexcept |
| Structural check drivers apply before transmit and after receive. | |
| constexpr bool | IsValid () const noexcept |
| Validate() == NONE. | |
| template<typename Frame > | |
| void | ToFrame (Frame &out) const noexcept |
Copy into a frame with members id, len, flags, data[64], ts_us. | |
Static Public Member Functions | |
| template<typename Frame > | |
| static hf_can_message_t | FromFrame (const Frame &in) noexcept |
Build a message from a frame with members id, len, flags, data[64], ts_us. | |
Public Attributes | |
| hf_u32_t | id |
| Message ID (11 or 29-bit) | |
| hf_u8_t | dlc |
| Payload length in BYTES (0..8 classic, 0..64 FD) | |
| hf_u8_t | data [HF_CAN_FD_MAX_LEN] |
| Payload (64 bytes, FD-sized) | |
| bool | is_extended |
| Extended ID flag (29-bit vs 11-bit) | |
| bool | is_rtr |
| Remote transmission request flag. | |
| bool | is_ss |
| Single shot flag (no retransmission) | |
| bool | is_self |
| Self reception request flag. | |
| bool | dlc_non_comp |
| Received classic DLC code was 9..15 (length is 8) | |
| hf_u64_t | timestamp_us |
| RX timestamp in microseconds (driver clock) | |
| hf_u32_t | sequence_number |
| Message sequence number. | |
| hf_u8_t | controller_id |
| Originating controller ID. | |
| hf_u8_t | retry_count |
| Number of transmission retries. | |
| hf_u8_t | error_count |
| Associated error count. | |
| bool | is_canfd |
| FD frame format (FDF) | |
| bool | is_brs |
| Bit Rate Switching (FD only) | |
| bool | is_esi |
| Error State Indicator (FD only) | |
Platform-agnostic CAN / CAN FD message (BaseCan v2).
The payload buffer is FD-sized (64 bytes) and the length is a byte count, never a DLC code:
dlc holds the payload length in bytes: 0..8 for classic frames, 0..8, 12, 16, 20, 24, 32, 48 or 64 for FD frames. The name is kept for source compatibility (for classic frames the byte count and the DLC code are the same number). Use GetLength() / SetLength() in new code, and GetDlcCode() / SetDlcCode() when a controller needs the 4-bit wire code.data can never be over-read or over-written through them.is_extended, is_rtr, is_canfd, is_brs, is_esi, also available packed as hf_can_flag bits via GetFlags() / SetFlags().timestamp_us is the RX timestamp captured by the driver (ISR side). It is ignored on transmit.Code that writes dlc directly must keep it valid for the frame kind; drivers check it with Validate() before touching data.
ToFrame() / FromFrame() convert to and from any frame struct with the members id, len, flags, data[64] and ts_us (the layout of vortex::contracts::CanFrame). A frame round trip (frame -> message -> frame) is lossless.
|
inlinenoexcept |
|
inlinestaticnoexcept |
Build a message from a frame with members id, len, flags, data[64], ts_us.
Copies the fields as they are; call Validate() to check the result. Flag bits outside hf_can_flag::ALL are ignored.
4-bit DLC code for the current length (HF_CAN_DLC_INVALID if invalid).
Same as GetLength(); kept for source compatibility.
Flags packed as hf_can_flag bits.
Payload length in bytes.
Largest payload for the current frame kind (8 classic, 64 FD).
Validate() == NONE.
Same as IsValidLength(); kept for source compatibility.
Validate message ID for current frame format.
Is len a valid payload length for the current frame kind?
| len | Length in bytes (not a DLC code) |
|
inlinenoexcept |
Make this a classic frame (clears BRS / ESI).
Copy len bytes into the payload and set the length.
len is invalid for the frame kind, or src is null with a non-zero length.
|
inlinenoexcept |
Set data frame (not remote).
Same as SetLength(); kept for source compatibility.
Set the length from a 4-bit DLC code (as read from a controller).
Classic codes 9..15 give 8 bytes and set dlc_non_comp.
code is above 15.
|
inlinenoexcept |
Set extended frame format (29-bit ID).
Make this an FD frame.
| brs | Bit-rate switch for the data phase |
Set the flags from hf_can_flag bits.
flags has a bit outside hf_can_flag::ALL. Set the payload length in bytes.
len is above 8 on a classic frame, above 64, or an FD length without a DLC code.
|
inlinenoexcept |
Set remote frame.
|
inlinenoexcept |
Set self reception request.
|
inlinenoexcept |
Set single shot transmission.
|
inlinenoexcept |
Set standard frame format (11-bit ID).
Copy into a frame with members id, len, flags, data[64], ts_us.
ts_us receives the low 32 bits of timestamp_us. The whole 64-byte buffer is copied. is_ss, is_self, sequence_number and the other metadata have no place in the frame and are dropped.
|
inlineconstexprnoexcept |
Structural check drivers apply before transmit and after receive.
Same rules, in the same order, as vortex::contracts::CheckFrame.
| hf_u8_t hf_can_message_t::controller_id |
Originating controller ID.
| hf_u8_t hf_can_message_t::data[HF_CAN_FD_MAX_LEN] |
Payload (64 bytes, FD-sized)
| hf_u8_t hf_can_message_t::dlc |
Payload length in BYTES (0..8 classic, 0..64 FD)
| bool hf_can_message_t::dlc_non_comp |
Received classic DLC code was 9..15 (length is 8)
| hf_u8_t hf_can_message_t::error_count |
Associated error count.
| hf_u32_t hf_can_message_t::id |
Message ID (11 or 29-bit)
| bool hf_can_message_t::is_brs |
Bit Rate Switching (FD only)
| bool hf_can_message_t::is_canfd |
FD frame format (FDF)
| bool hf_can_message_t::is_esi |
Error State Indicator (FD only)
| bool hf_can_message_t::is_extended |
Extended ID flag (29-bit vs 11-bit)
| bool hf_can_message_t::is_rtr |
Remote transmission request flag.
| bool hf_can_message_t::is_self |
Self reception request flag.
| bool hf_can_message_t::is_ss |
Single shot flag (no retransmission)
| hf_u8_t hf_can_message_t::retry_count |
Number of transmission retries.
| hf_u32_t hf_can_message_t::sequence_number |
Message sequence number.
| hf_u64_t hf_can_message_t::timestamp_us |
RX timestamp in microseconds (driver clock)