A protocol that handles the NMEA 2000 fast packet protocol.
More...
#include <nmea2000_fast_packet_protocol.hpp>
|
| FastPacketProtocol (const CANMessageFrameCallback &sendCANFrameCallback) |
| The constructor for the FastPacketProtocol, for advanced use only. In most cases, you should use the CANNetworkManager::get_fast_packet_protocol().send_message() function to transmit messages.
|
|
void | register_multipacket_message_callback (std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent, std::shared_ptr< InternalControlFunction > internalControlFunction=nullptr) |
| Add a callback to be called when a message is received by the Fast Packet protocol.
|
|
void | remove_multipacket_message_callback (std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent, std::shared_ptr< InternalControlFunction > internalControlFunction=nullptr) |
|
bool | send_multipacket_message (std::uint32_t parameterGroupNumber, const std::uint8_t *data, std::uint8_t messageLength, std::shared_ptr< InternalControlFunction > source, std::shared_ptr< ControlFunction > destination, CANIdentifier::CANPriority priority=CANIdentifier::CANPriority::PriorityDefault6, TransmitCompleteCallback txCompleteCallback=nullptr, void *parentPointer=nullptr, DataChunkCallback frameChunkCallback=nullptr) |
| Used to send CAN messages using fast packet.
|
|
void | allow_any_control_function (bool allow) |
| Set whether or not to allow messages for non-internal control functions to be parsed by this protocol.
|
|
void | update () |
| Updates all sessions managed by this protocol manager instance.
|
|
void | process_message (const CANMessage &message) |
| A generic way for a protocol to process a received message.
|
|
A protocol that handles the NMEA 2000 fast packet protocol.
Definition at line 37 of file nmea2000_fast_packet_protocol.hpp.
◆ FastPacketProtocol()
◆ add_session_history()
Adds a session's info to the history so that we can continue the sequence number later.
- Parameters
-
[in] | session | The session to add to the history |
Definition at line 211 of file nmea2000_fast_packet_protocol.cpp.
◆ allow_any_control_function()
void isobus::FastPacketProtocol::allow_any_control_function |
( |
bool | allow | ) |
|
Set whether or not to allow messages for non-internal control functions to be parsed by this protocol.
- Parameters
-
[in] | allow | Denotes if messages for non-internal control functions should be parsed by this protocol |
Definition at line 125 of file nmea2000_fast_packet_protocol.cpp.
◆ calculate_number_of_frames()
std::uint8_t isobus::FastPacketProtocol::calculate_number_of_frames |
( |
std::uint8_t | messageLength | ) |
|
|
static |
Calculates the number of frames needed for a message.
- Parameters
-
[in] | messageLength | The length of the message in bytes |
- Returns
- The number of frames needed for the message
Definition at line 88 of file nmea2000_fast_packet_protocol.cpp.
◆ close_session()
Gracefully closes a session to prepare for a new session.
- Parameters
-
[in] | session | The session to close |
[in] | successful | Denotes if the session was successful |
Definition at line 240 of file nmea2000_fast_packet_protocol.cpp.
◆ get_new_sequence_number()
std::uint8_t isobus::FastPacketProtocol::get_new_sequence_number |
( |
NAME | name, |
|
|
std::uint32_t | parameterGroupNumber ) const |
|
private |
Get the sequence number to use for a new session based on the history of past sessions.
- Parameters
-
[in] | name | The ISO name of the internal control function used in a session |
[in] | parameterGroupNumber | The PGN of the session being started |
- Returns
- The sequence number to use for the new session
Definition at line 255 of file nmea2000_fast_packet_protocol.cpp.
◆ get_session()
Gets a FP session from the passed in source and destination and PGN combination.
- Parameters
-
[in] | parameterGroupNumber | The PGN of the session |
[in] | source | The source control function for the session |
[in] | destination | The destination control function for the session |
- Returns
- a matching session, or nullptr if no session matched the supplied parameters
Definition at line 502 of file nmea2000_fast_packet_protocol.cpp.
◆ has_session()
bool isobus::FastPacketProtocol::has_session |
( |
std::uint32_t | parameterGroupNumber, |
|
|
std::shared_ptr< ControlFunction > | source, |
|
|
std::shared_ptr< ControlFunction > | destination ) |
|
private |
Checks if a session by the passed in source and destination and PGN combination exists.
- Parameters
-
[in] | parameterGroupNumber | The PGN of the session |
[in] | source | The source control function for the session |
[in] | destination | The destination control function for the session |
- Returns
- true if a matching session exists, false if not
Definition at line 494 of file nmea2000_fast_packet_protocol.cpp.
◆ process_message()
void isobus::FastPacketProtocol::process_message |
( |
const CANMessage & | message | ) |
|
◆ register_multipacket_message_callback()
void isobus::FastPacketProtocol::register_multipacket_message_callback |
( |
std::uint32_t | parameterGroupNumber, |
|
|
CANLibCallback | callback, |
|
|
void * | parent, |
|
|
std::shared_ptr< InternalControlFunction > | internalControlFunction = nullptr ) |
Add a callback to be called when a message is received by the Fast Packet protocol.
- Parameters
-
[in] | parameterGroupNumber | The PGN to parse as fast packet |
[in] | callback | The callback that the stack will call when a matching message is received |
[in] | parent | Generic context variable for the callback |
[in] | internalControlFunction | An internal control function to use as an additional filter for the callback. Only messages destined for the specified ICF will generate a callback. Use nullptr to receive messages for destined for any ICF and broadcast messages. |
- Note
- You can also sniff all messages by allowing messages for messages destined to non-internal control functions to be parsed by this protocol, use the "allow_any_control_function()" function to enable this.
Definition at line 110 of file nmea2000_fast_packet_protocol.cpp.
◆ remove_multipacket_message_callback()
void isobus::FastPacketProtocol::remove_multipacket_message_callback |
( |
std::uint32_t | parameterGroupNumber, |
|
|
CANLibCallback | callback, |
|
|
void * | parent, |
|
|
std::shared_ptr< InternalControlFunction > | internalControlFunction = nullptr ) |
- Parameters
-
[in] | parameterGroupNumber | The PGN to parse as fast packet |
[in] | callback | The callback that the stack will call when a matching message is received |
[in] | parent | Generic context variable |
[in] | internalControlFunction | An internal control function used as an additional filter for the callback |
Definition at line 115 of file nmea2000_fast_packet_protocol.cpp.
◆ send_multipacket_message()
Used to send CAN messages using fast packet.
You have to use this function instead of the network manager because otherwise the CAN stack has no way of knowing to send your message with FP instead of TP.
- Parameters
-
[in] | parameterGroupNumber | The PGN of the message |
[in] | data | The data to be sent |
[in] | messageLength | The length of the data to be sent |
[in] | source | The source control function |
[in] | destination | The destination control function |
[in] | priority | The priority to encode in the IDs of the component CAN messages |
[in] | txCompleteCallback | A callback for when the protocol completes its work |
[in] | parentPointer | A generic context object for the tx complete and chunk callbacks |
[in] | frameChunkCallback | A callback to get some data to send |
- Returns
- true if the message was accepted by the protocol for processing
Definition at line 130 of file nmea2000_fast_packet_protocol.cpp.
◆ update()
void isobus::FastPacketProtocol::update |
( |
| ) |
|
◆ update_session()
◆ activeSessions
◆ allowAnyControlFunction
bool isobus::FastPacketProtocol::allowAnyControlFunction = false |
|
private |
◆ FP_MAX_PARAMETER_GROUP_NUMBER
constexpr std::uint32_t isobus::FastPacketProtocol::FP_MAX_PARAMETER_GROUP_NUMBER = 0x1FFFF |
|
staticconstexprprivate |
◆ FP_MIN_PARAMETER_GROUP_NUMBER
constexpr std::uint32_t isobus::FastPacketProtocol::FP_MIN_PARAMETER_GROUP_NUMBER = 0x1F000 |
|
staticconstexprprivate |
◆ FP_TIMEOUT_MS
constexpr std::uint32_t isobus::FastPacketProtocol::FP_TIMEOUT_MS = 750 |
|
staticconstexprprivate |
◆ FRAME_COUNTER_BIT_MASK
constexpr std::uint8_t isobus::FastPacketProtocol::FRAME_COUNTER_BIT_MASK = 0x1F |
|
staticconstexprprivate |
◆ MAX_PROTOCOL_MESSAGE_LENGTH
constexpr std::uint8_t isobus::FastPacketProtocol::MAX_PROTOCOL_MESSAGE_LENGTH = 223 |
|
staticconstexprprivate |
◆ parameterGroupNumberCallbacks
◆ PROTOCOL_BYTES_PER_FRAME
constexpr std::uint8_t isobus::FastPacketProtocol::PROTOCOL_BYTES_PER_FRAME = 7 |
|
staticconstexprprivate |
◆ sendCANFrameCallback
◆ SEQUENCE_NUMBER_BIT_MASK
constexpr std::uint8_t isobus::FastPacketProtocol::SEQUENCE_NUMBER_BIT_MASK = 0x07 |
|
staticconstexprprivate |
◆ SEQUENCE_NUMBER_BIT_OFFSET
constexpr std::uint8_t isobus::FastPacketProtocol::SEQUENCE_NUMBER_BIT_OFFSET = 5 |
|
staticconstexprprivate |
◆ sessionHistory
◆ sessionMutex
Mutex isobus::FastPacketProtocol::sessionMutex |
|
private |
The documentation for this class was generated from the following files: