AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
A utility class that allows easy interpretation of a 32 bit CAN identifier. More...
#include <can_identifier.hpp>
Public Types | |
enum class | CANPriority { PriorityHighest0 = 0 , Priority1 = 1 , Priority2 = 2 , Priority3 = 3 , Priority4 = 4 , Priority5 = 5 , PriorityDefault6 = 6 , PriorityLowest7 = 7 } |
Defines all the CAN frame priorities that can be encoded in a frame ID. More... | |
enum class | Type { Standard = 0 , Extended = 1 } |
Defines if a frame is a standard (11 bit) or extended (29 bit) ID frame. More... | |
Public Member Functions | |
CANIdentifier (std::uint32_t rawIdentifierData) | |
Constructor for a CAN Identifier class based on a raw 32 bit ID. | |
CANIdentifier (Type identifierType, std::uint32_t pgn, CANPriority priority, std::uint8_t destinationAddress, std::uint8_t sourceAddress) | |
Constructor for a CAN Identifier class based on all discrete components. | |
~CANIdentifier ()=default | |
Destructor for the CANIdentifier. | |
std::uint32_t | get_identifier () const |
Returns the raw encoded ID of the CAN identifier. | |
Type | get_identifier_type () const |
Returns the identifier type (standard vs extended) | |
std::uint32_t | get_parameter_group_number () const |
Returns the PGN encoded in the identifier. | |
CANPriority | get_priority () const |
Returns the priority of the frame encoded in the identifier. | |
std::uint8_t | get_destination_address () const |
Returns the destination address of the frame encoded in the identifier. | |
std::uint8_t | get_source_address () const |
Returns the source address of the frame encoded in the identifier. | |
bool | get_is_valid () const |
Returns if the ID is valid based on some range checking. | |
Static Public Attributes | |
static constexpr std::uint32_t | IDENTIFIER_TYPE_BIT_MASK = 0x80000000 |
This bit denotes if the frame is standard or extended format. | |
static constexpr std::uint32_t | UNDEFINED_PARAMETER_GROUP_NUMBER = 0xFFFFFFFF |
A fake PGN used internally to denote a NULL PGN. | |
static constexpr std::uint8_t | GLOBAL_ADDRESS = 0xFF |
The broadcast CAN address. | |
static constexpr std::uint8_t | NULL_ADDRESS = 0xFE |
The NULL CAN address as defined by ISO11783. | |
Private Attributes | |
std::uint32_t | m_RawIdentifier |
The raw encoded 29 bit ID. | |
Static Private Attributes | |
static constexpr std::uint32_t | BROADCAST_PGN_MASK = 0x0003FFFF |
Broadcast PGNs don't mask off the bits used for destination in the PGN. | |
static constexpr std::uint32_t | DESTINATION_SPECIFIC_PGN_MASK = 0x0003FF00 |
Destination specific PGNs mask the destination out of the PGN itself. | |
static constexpr std::uint32_t | PDU2_FORMAT_MASK = 0x00F00000 |
Mask that denotes the ID as being PDU2 format. | |
static constexpr std::uint8_t | PARAMTER_GROUP_NUMBER_OFFSET = 8 |
PGN is offset 8 bits into the ID. | |
static constexpr std::uint8_t | PRIORITY_DATA_BIT_OFFSET = 26 |
Priority is offset 26 bits into the ID. | |
A utility class that allows easy interpretation of a 32 bit CAN identifier.
Definition at line 23 of file can_identifier.hpp.
|
strong |
Defines all the CAN frame priorities that can be encoded in a frame ID.
Definition at line 27 of file can_identifier.hpp.
|
strong |
Defines if a frame is a standard (11 bit) or extended (29 bit) ID frame.
Enumerator | |
---|---|
Standard | Frame is an 11bit ID standard (legacy) message with no PGN and highest priority. |
Extended | Frame is a modern 29 bit ID CAN frame. |
Definition at line 40 of file can_identifier.hpp.
|
explicit |
Constructor for a CAN Identifier class based on a raw 32 bit ID.
[in] | rawIdentifierData | The raw 32 bit ID to interpret |
Definition at line 14 of file can_identifier.cpp.
isobus::CANIdentifier::CANIdentifier | ( | Type | identifierType, |
std::uint32_t | pgn, | ||
CANPriority | priority, | ||
std::uint8_t | destinationAddress, | ||
std::uint8_t | sourceAddress ) |
Constructor for a CAN Identifier class based on all discrete components.
[in] | identifierType | Type of frame, either standard 11 bit ID, or extended 29 bit ID |
[in] | pgn | The parameter group number encoded in the frame (extended only) |
[in] | priority | The priority of the frame (extended only) |
[in] | destinationAddress | The destination address of the frame |
[in] | sourceAddress | The source address of the frame |
Definition at line 19 of file can_identifier.cpp.
std::uint8_t isobus::CANIdentifier::get_destination_address | ( | ) | const |
Returns the destination address of the frame encoded in the identifier.
Definition at line 101 of file can_identifier.cpp.
std::uint32_t isobus::CANIdentifier::get_identifier | ( | ) | const |
Returns the raw encoded ID of the CAN identifier.
Definition at line 62 of file can_identifier.cpp.
CANIdentifier::Type isobus::CANIdentifier::get_identifier_type | ( | ) | const |
Returns the identifier type (standard vs extended)
Definition at line 67 of file can_identifier.cpp.
bool isobus::CANIdentifier::get_is_valid | ( | ) | const |
Returns if the ID is valid based on some range checking.
Definition at line 128 of file can_identifier.cpp.
std::uint32_t isobus::CANIdentifier::get_parameter_group_number | ( | ) | const |
Returns the PGN encoded in the identifier.
Definition at line 83 of file can_identifier.cpp.
CANIdentifier::CANPriority isobus::CANIdentifier::get_priority | ( | ) | const |
Returns the priority of the frame encoded in the identifier.
Definition at line 45 of file can_identifier.cpp.
std::uint8_t isobus::CANIdentifier::get_source_address | ( | ) | const |
Returns the source address of the frame encoded in the identifier.
Definition at line 116 of file can_identifier.cpp.
|
staticconstexprprivate |
Broadcast PGNs don't mask off the bits used for destination in the PGN.
Definition at line 99 of file can_identifier.hpp.
|
staticconstexprprivate |
Destination specific PGNs mask the destination out of the PGN itself.
Definition at line 100 of file can_identifier.hpp.
|
staticconstexpr |
The broadcast CAN address.
Definition at line 95 of file can_identifier.hpp.
|
staticconstexpr |
This bit denotes if the frame is standard or extended format.
Definition at line 93 of file can_identifier.hpp.
|
private |
The raw encoded 29 bit ID.
Definition at line 105 of file can_identifier.hpp.
|
staticconstexpr |
The NULL CAN address as defined by ISO11783.
Definition at line 96 of file can_identifier.hpp.
|
staticconstexprprivate |
PGN is offset 8 bits into the ID.
Definition at line 102 of file can_identifier.hpp.
|
staticconstexprprivate |
Mask that denotes the ID as being PDU2 format.
Definition at line 101 of file can_identifier.hpp.
|
staticconstexprprivate |
Priority is offset 26 bits into the ID.
Definition at line 103 of file can_identifier.hpp.
|
staticconstexpr |
A fake PGN used internally to denote a NULL PGN.
Definition at line 94 of file can_identifier.hpp.