AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
A protocol that handles PGN requests. More...
#include <can_parameter_group_number_request_protocol.hpp>
Classes | |
class | PGNRequestCallbackInfo |
A storage class for holding PGN callbacks and their associated PGN. More... | |
class | PGNRequestForRepetitionRateCallbackInfo |
A storage class for holding PGN callbacks and their associated PGN. More... | |
Public Member Functions | |
ParameterGroupNumberRequestProtocol (std::shared_ptr< InternalControlFunction > internalControlFunction, CANLibBadge< InternalControlFunction >) | |
The constructor for this protocol. | |
~ParameterGroupNumberRequestProtocol () | |
The destructor for this protocol. | |
ParameterGroupNumberRequestProtocol (const ParameterGroupNumberRequestProtocol &)=delete | |
Remove the copy constructor. | |
ParameterGroupNumberRequestProtocol & | operator= (const ParameterGroupNumberRequestProtocol &)=delete |
Remove the copy assignment operator. | |
bool | register_pgn_request_callback (std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer) |
Registers for a callback on receipt of a PGN request. | |
bool | register_request_for_repetition_rate_callback (std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer) |
Registers for a callback on receipt of a request for repetition rate. | |
bool | remove_pgn_request_callback (std::uint32_t pgn, PGNRequestCallback callback, void *parentPointer) |
Removes a previously registered PGN request callback. | |
bool | remove_request_for_repetition_rate_callback (std::uint32_t pgn, PGNRequestForRepetitionRateCallback callback, void *parentPointer) |
Removes a callback for repetition rate requests. | |
std::size_t | get_number_registered_pgn_request_callbacks () const |
Returns the number of PGN request callbacks that have been registered with this protocol instance. | |
std::size_t | get_number_registered_request_for_repetition_rate_callbacks () const |
Returns the number of PGN request for repetition rate callbacks that have been registered with this protocol instance. | |
Static Public Member Functions | |
static bool | request_parameter_group_number (std::uint32_t pgn, std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination) |
Sends a PGN request to the specified control function. | |
static bool | request_repetition_rate (std::uint32_t pgn, std::uint16_t repetitionRate_ms, std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination) |
Sends a PGN request for repetition rate. | |
Private Member Functions | |
void | process_message (const CANMessage &message) |
A generic way for a protocol to process a received message. | |
bool | send_acknowledgement (AcknowledgementType type, std::uint32_t parameterGroupNumber, std::shared_ptr< ControlFunction > destination) const |
Sends a message using the acknowledgement PGN. | |
Static Private Member Functions | |
static void | process_message (const CANMessage &message, void *parent) |
A generic way for a protocol to process a received message. | |
Private Attributes | |
std::shared_ptr< InternalControlFunction > | myControlFunction |
The internal control function that this protocol will send from. | |
std::vector< PGNRequestCallbackInfo > | pgnRequestCallbacks |
A list of all registered PGN callbacks and the PGN associated with each callback. | |
std::vector< PGNRequestForRepetitionRateCallbackInfo > | repetitionRateCallbacks |
A list of all registered request for repetition rate callbacks and the PGN associated with the callback. | |
Mutex | pgnRequestMutex |
A mutex to protect the callback lists. | |
Static Private Attributes | |
static constexpr std::uint8_t | PGN_REQUEST_LENGTH = 3 |
The CAN data length of a PGN request. | |
A protocol that handles PGN requests.
The purpose of this protocol is to simplify and standardize how PGN requests are made and responded to. It provides a way to easily send a PGN request or a request for repetition rate, as well as methods to receive PGN requests.
Definition at line 30 of file can_parameter_group_number_request_protocol.hpp.
isobus::ParameterGroupNumberRequestProtocol::ParameterGroupNumberRequestProtocol | ( | std::shared_ptr< InternalControlFunction > | internalControlFunction, |
CANLibBadge< InternalControlFunction > | ) |
The constructor for this protocol.
[in] | internalControlFunction | The internal control function that owns this protocol and will be used to send messages |
Definition at line 22 of file can_parameter_group_number_request_protocol.cpp.
isobus::ParameterGroupNumberRequestProtocol::~ParameterGroupNumberRequestProtocol | ( | ) |
The destructor for this protocol.
Definition at line 30 of file can_parameter_group_number_request_protocol.cpp.
std::size_t isobus::ParameterGroupNumberRequestProtocol::get_number_registered_pgn_request_callbacks | ( | ) | const |
Returns the number of PGN request callbacks that have been registered with this protocol instance.
Definition at line 131 of file can_parameter_group_number_request_protocol.cpp.
std::size_t isobus::ParameterGroupNumberRequestProtocol::get_number_registered_request_for_repetition_rate_callbacks | ( | ) | const |
Returns the number of PGN request for repetition rate callbacks that have been registered with this protocol instance.
Definition at line 136 of file can_parameter_group_number_request_protocol.cpp.
|
private |
A generic way for a protocol to process a received message.
[in] | message | A received CAN message |
Definition at line 165 of file can_parameter_group_number_request_protocol.cpp.
|
staticprivate |
A generic way for a protocol to process a received message.
[in] | message | A received CAN message |
[in] | parent | Provides the context to the actual TP manager object |
Definition at line 261 of file can_parameter_group_number_request_protocol.cpp.
bool isobus::ParameterGroupNumberRequestProtocol::register_pgn_request_callback | ( | std::uint32_t | pgn, |
PGNRequestCallback | callback, | ||
void * | parentPointer ) |
Registers for a callback on receipt of a PGN request.
[in] | pgn | The PGN you want to handle in the callback |
[in] | callback | The callback function to register |
[in] | parentPointer | Generic context variable, usually the this pointer of the class registering the callback |
Definition at line 71 of file can_parameter_group_number_request_protocol.cpp.
bool isobus::ParameterGroupNumberRequestProtocol::register_request_for_repetition_rate_callback | ( | std::uint32_t | pgn, |
PGNRequestForRepetitionRateCallback | callback, | ||
void * | parentPointer ) |
Registers for a callback on receipt of a request for repetition rate.
[in] | pgn | The PGN you want to handle in the callback |
[in] | callback | The callback function to register |
[in] | parentPointer | Generic context variable, usually the this pointer of the class registering the callback |
Definition at line 85 of file can_parameter_group_number_request_protocol.cpp.
bool isobus::ParameterGroupNumberRequestProtocol::remove_pgn_request_callback | ( | std::uint32_t | pgn, |
PGNRequestCallback | callback, | ||
void * | parentPointer ) |
Removes a previously registered PGN request callback.
[in] | pgn | The PGN associated with the callback |
[in] | callback | The callback function to remove |
[in] | parentPointer | Generic context variable, usually the this pointer of the class that registered the callback |
Definition at line 99 of file can_parameter_group_number_request_protocol.cpp.
bool isobus::ParameterGroupNumberRequestProtocol::remove_request_for_repetition_rate_callback | ( | std::uint32_t | pgn, |
PGNRequestForRepetitionRateCallback | callback, | ||
void * | parentPointer ) |
Removes a callback for repetition rate requests.
[in] | pgn | The PGN associated with the callback |
[in] | callback | The callback function to remove |
[in] | parentPointer | Generic context variable, usually the this pointer of the class that registered the callback |
Definition at line 115 of file can_parameter_group_number_request_protocol.cpp.
|
static |
Sends a PGN request to the specified control function.
[in] | pgn | The PGN to request |
[in] | source | The internal control function to send from |
[in] | destination | The control function to request pgn from |
true
if the request was successfully sent Definition at line 36 of file can_parameter_group_number_request_protocol.cpp.
|
static |
Sends a PGN request for repetition rate.
Use this if you want the destination CF to send you the specified PGN at some fixed interval
[in] | pgn | The PGN to request |
[in] | repetitionRate_ms | The repetition rate to request in milliseconds |
[in] | source | The internal control function to send from |
[in] | destination | The control function to send the request to |
true
if the request was sent Definition at line 51 of file can_parameter_group_number_request_protocol.cpp.
|
private |
Sends a message using the acknowledgement PGN.
[in] | type | The type of acknowledgement to send (Ack, vs Nack, etc) |
[in] | parameterGroupNumber | The PGN to acknowledge |
[in] | destination | The destination control function to send the acknowledgement to |
Definition at line 269 of file can_parameter_group_number_request_protocol.cpp.
|
private |
The internal control function that this protocol will send from.
Definition at line 159 of file can_parameter_group_number_request_protocol.hpp.
|
staticconstexprprivate |
The CAN data length of a PGN request.
Definition at line 141 of file can_parameter_group_number_request_protocol.hpp.
|
private |
A list of all registered PGN callbacks and the PGN associated with each callback.
Definition at line 160 of file can_parameter_group_number_request_protocol.hpp.
|
private |
A mutex to protect the callback lists.
Definition at line 162 of file can_parameter_group_number_request_protocol.hpp.
|
private |
A list of all registered request for repetition rate callbacks and the PGN associated with the callback.
Definition at line 161 of file can_parameter_group_number_request_protocol.hpp.