AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
isobus::CANIdentifier Class Reference

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.
 

Detailed Description

A utility class that allows easy interpretation of a 32 bit CAN identifier.

Definition at line 23 of file can_identifier.hpp.

Member Enumeration Documentation

◆ CANPriority

Defines all the CAN frame priorities that can be encoded in a frame ID.

Enumerator
PriorityHighest0 

Highest CAN priority.

Priority1 

Priority highest - 1.

Priority2 

Priority highest - 2.

Priority3 

Priority highest - 3 (Control messages priority)

Priority4 

Priority highest - 4.

Priority5 

Priority highest - 5.

PriorityDefault6 

The default priority.

PriorityLowest7 

The lowest priority.

Definition at line 27 of file can_identifier.hpp.

◆ Type

enum class isobus::CANIdentifier::Type
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.

Constructor & Destructor Documentation

◆ CANIdentifier() [1/2]

isobus::CANIdentifier::CANIdentifier ( std::uint32_t rawIdentifierData)
explicit

Constructor for a CAN Identifier class based on a raw 32 bit ID.

Parameters
[in]rawIdentifierDataThe raw 32 bit ID to interpret

Definition at line 14 of file can_identifier.cpp.

◆ CANIdentifier() [2/2]

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.

Parameters
[in]identifierTypeType of frame, either standard 11 bit ID, or extended 29 bit ID
[in]pgnThe parameter group number encoded in the frame (extended only)
[in]priorityThe priority of the frame (extended only)
[in]destinationAddressThe destination address of the frame
[in]sourceAddressThe source address of the frame

Definition at line 19 of file can_identifier.cpp.

Member Function Documentation

◆ get_destination_address()

std::uint8_t isobus::CANIdentifier::get_destination_address ( ) const

Returns the destination address of the frame encoded in the identifier.

Returns
The destination address of the frame encoded in the identifier

Definition at line 101 of file can_identifier.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_identifier()

std::uint32_t isobus::CANIdentifier::get_identifier ( ) const

Returns the raw encoded ID of the CAN identifier.

Returns
The raw encoded ID of the CAN identifier

Definition at line 62 of file can_identifier.cpp.

◆ get_identifier_type()

CANIdentifier::Type isobus::CANIdentifier::get_identifier_type ( ) const

Returns the identifier type (standard vs extended)

Returns
The identifier type (standard vs extended)

Definition at line 67 of file can_identifier.cpp.

Here is the caller graph for this function:

◆ get_is_valid()

bool isobus::CANIdentifier::get_is_valid ( ) const

Returns if the ID is valid based on some range checking.

Returns
Frame valid status

Definition at line 128 of file can_identifier.cpp.

Here is the call graph for this function:

◆ get_parameter_group_number()

std::uint32_t isobus::CANIdentifier::get_parameter_group_number ( ) const

Returns the PGN encoded in the identifier.

Returns
The PGN encoded in the identifier

Definition at line 83 of file can_identifier.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_priority()

CANIdentifier::CANPriority isobus::CANIdentifier::get_priority ( ) const

Returns the priority of the frame encoded in the identifier.

Returns
The priority of the frame encoded in the identifier

Definition at line 45 of file can_identifier.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_source_address()

std::uint8_t isobus::CANIdentifier::get_source_address ( ) const

Returns the source address of the frame encoded in the identifier.

Returns
The source address of the frame encoded in the identifier

Definition at line 116 of file can_identifier.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ BROADCAST_PGN_MASK

constexpr std::uint32_t isobus::CANIdentifier::BROADCAST_PGN_MASK = 0x0003FFFF
staticconstexprprivate

Broadcast PGNs don't mask off the bits used for destination in the PGN.

Definition at line 99 of file can_identifier.hpp.

◆ DESTINATION_SPECIFIC_PGN_MASK

constexpr std::uint32_t isobus::CANIdentifier::DESTINATION_SPECIFIC_PGN_MASK = 0x0003FF00
staticconstexprprivate

Destination specific PGNs mask the destination out of the PGN itself.

Definition at line 100 of file can_identifier.hpp.

◆ GLOBAL_ADDRESS

constexpr std::uint8_t isobus::CANIdentifier::GLOBAL_ADDRESS = 0xFF
staticconstexpr

The broadcast CAN address.

Definition at line 95 of file can_identifier.hpp.

◆ IDENTIFIER_TYPE_BIT_MASK

constexpr std::uint32_t isobus::CANIdentifier::IDENTIFIER_TYPE_BIT_MASK = 0x80000000
staticconstexpr

This bit denotes if the frame is standard or extended format.

Definition at line 93 of file can_identifier.hpp.

◆ m_RawIdentifier

std::uint32_t isobus::CANIdentifier::m_RawIdentifier
private

The raw encoded 29 bit ID.

Definition at line 105 of file can_identifier.hpp.

◆ NULL_ADDRESS

constexpr std::uint8_t isobus::CANIdentifier::NULL_ADDRESS = 0xFE
staticconstexpr

The NULL CAN address as defined by ISO11783.

Definition at line 96 of file can_identifier.hpp.

◆ PARAMTER_GROUP_NUMBER_OFFSET

constexpr std::uint8_t isobus::CANIdentifier::PARAMTER_GROUP_NUMBER_OFFSET = 8
staticconstexprprivate

PGN is offset 8 bits into the ID.

Definition at line 102 of file can_identifier.hpp.

◆ PDU2_FORMAT_MASK

constexpr std::uint32_t isobus::CANIdentifier::PDU2_FORMAT_MASK = 0x00F00000
staticconstexprprivate

Mask that denotes the ID as being PDU2 format.

Definition at line 101 of file can_identifier.hpp.

◆ PRIORITY_DATA_BIT_OFFSET

constexpr std::uint8_t isobus::CANIdentifier::PRIORITY_DATA_BIT_OFFSET = 26
staticconstexprprivate

Priority is offset 26 bits into the ID.

Definition at line 103 of file can_identifier.hpp.

◆ UNDEFINED_PARAMETER_GROUP_NUMBER

constexpr std::uint32_t isobus::CANIdentifier::UNDEFINED_PARAMETER_GROUP_NUMBER = 0xFFFFFFFF
staticconstexpr

A fake PGN used internally to denote a NULL PGN.

Definition at line 94 of file can_identifier.hpp.


The documentation for this class was generated from the following files: