FusionEngineFramer Class
Frame and validate incoming FusionEngine messages. More...
Declaration
Included Headers
Public Member Typedefs Index
| using | RawMessageCallback = void(*)(void *context, const messages::MessageHeader &header, const void *payload) |
Enumerations Index
| enum class | State { ... } |
Public Constructors Index
| P1_EXPORT | FusionEngineFramer ()=default |
|
Construct a framer instance with no buffer allocated. More... | |
| FusionEngineFramer (const FusionEngineFramer &)=delete | |
| FusionEngineFramer (FusionEngineFramer &&)=delete | |
| P1_EXPORT | FusionEngineFramer (size_t capacity_bytes) |
|
Construct a framer instance with an internally allocated buffer. More... | |
| P1_EXPORT | FusionEngineFramer (void *buffer, size_t capacity_bytes) |
|
Construct a framer instance with a user-specified buffer. More... | |
Public Destructor Index
| P1_EXPORT | ~FusionEngineFramer () |
Public Operators Index
| FusionEngineFramer & | operator= (const FusionEngineFramer &)=delete |
| FusionEngineFramer & | operator= (FusionEngineFramer &&)=delete |
Public Member Functions Index
| P1_EXPORT size_t | OnData (const uint8_t *buffer, size_t length_bytes) |
|
Process incoming data. More... | |
| P1_EXPORT void | Reset () |
|
Reset the framer and discard all pending data. More... | |
| P1_EXPORT void | SetBuffer (void *buffer, size_t capacity_bytes) |
|
Set the buffer to use for message framing. More... | |
| P1_EXPORT void | SetMessageCallback (RawMessageCallback callback, void *context) |
|
Specify a function to be called when a message is framed. More... | |
| P1_EXPORT void | WarnOnError (bool enabled) |
|
Enable/disable warnings for CRC and "message too large" failures. More... | |
Private Member Functions Index
| void | ClearManagedBuffer () |
| int32_t | OnByte (bool quiet) |
|
Process a single byte. More... | |
| uint32_t | Resync () |
|
Perform a resynchronization operation starting at buffer_[1]. More... | |
Private Member Attributes Index
Description
Frame and validate incoming FusionEngine messages.
This class locates and validates FusionEngine messages within a stream of binary data. Data may be stored in an internally allocated buffer, or in an external buffer supplied by the user.
The callback function provided to SetMessageCallback() will be called each time a complete message is received. Any messages that do not pass the CRC check, or that are too big to be stored in the data buffer, will be discarded.
Example usage:
Definition at line 48 of file fusion_engine_framer.h.
Public Member Typedefs
RawMessageCallback
|
Definition at line 54 of file fusion_engine_framer.h.
Public Constructors
FusionEngineFramer()
| default |
Construct a framer instance with no buffer allocated.
You must call SetBuffer() to assign a buffer, otherwise all incoming data will be discarded.
Definition at line 65 of file fusion_engine_framer.h.
FusionEngineFramer()
| delete |
Definition at line 90 of file fusion_engine_framer.h.
FusionEngineFramer()
| delete |
Definition at line 91 of file fusion_engine_framer.h.
FusionEngineFramer()
| inline explicit |
Construct a framer instance with an internally allocated buffer.
- Parameters
-
capacity_bytes The maximum framing buffer capacity (in bytes).
Definition at line 72 of file fusion_engine_framer.h.
FusionEngineFramer()
Construct a framer instance with a user-specified buffer.
- Postcondition
buffer must exist for the lifetime of this instance.
- Parameters
-
buffer The framing buffer to use. Set to nullptr to allocate a buffer internally.
capacity_bytes The maximum framing buffer capacity (in bytes).
Declaration at line 85 of file fusion_engine_framer.h, definition at line 95 of file fusion_engine_framer.cc.
Public Destructor
~FusionEngineFramer()
|
Declaration at line 87 of file fusion_engine_framer.h, definition at line 109 of file fusion_engine_framer.cc.
Public Operators
operator=()
| delete |
Definition at line 92 of file fusion_engine_framer.h.
operator=()
| delete |
Definition at line 94 of file fusion_engine_framer.h.
Public Member Functions
OnData()
Process incoming data.
- Parameters
-
buffer A buffer containing data to be framed.
length_bytes The number of bytes to be framed.
- Returns
The total size of all valid, complete messages, or 0 if no messages were completed.
Declaration at line 160 of file fusion_engine_framer.h, definition at line 155 of file fusion_engine_framer.cc.
Reset()
|
Reset the framer and discard all pending data.
Declaration at line 149 of file fusion_engine_framer.h, definition at line 148 of file fusion_engine_framer.cc.
SetBuffer()
Set the buffer to use for message framing.
- Postcondition
buffer must exist for the lifetime of this instance.
- Parameters
-
buffer The framing buffer to use. Set to nullptr to allocate a buffer internally.
capacity_bytes The maximum framing buffer capacity (in bytes).
Declaration at line 107 of file fusion_engine_framer.h, definition at line 112 of file fusion_engine_framer.cc.
SetMessageCallback()
| inline |
Specify a function to be called when a message is framed.
- Parameters
-
callback The function to be called with the supplied context variable, the message header, and a pointer to the message payload.
context A context value that will be passed to the callback.
Definition at line 140 of file fusion_engine_framer.h.
WarnOnError()
| inline |
Enable/disable warnings for CRC and "message too large" failures.
This is typically used when the incoming stream has multiple types of binary content (e.g., interleaved FusionEngine and RTCM messages), and the FusionEngine message preamble is expected to appear in the non-FusionEngine content occasionally.
- Parameters
-
enabled If true, issue warnings on errors.
Definition at line 119 of file fusion_engine_framer.h.
Private Member Functions
ClearManagedBuffer()
|
Free the buffer_ if it's being managed internally.
Declaration at line 209 of file fusion_engine_framer.h, definition at line 515 of file fusion_engine_framer.cc.
OnByte()
|
Process a single byte.
- Precondition
The byte must be located at buffer_[next_byte_index_ - 1].
- Parameters
-
quiet If true, suppress failure warning messages.
- Returns
The total size of all valid, complete messages, 0 if no messages were completed, or <0 CRC or "message too large" error.
Declaration at line 196 of file fusion_engine_framer.h, definition at line 195 of file fusion_engine_framer.cc.
Resync()
|
Perform a resynchronization operation starting at buffer_[1].
- Returns
The total size of all valid, complete messages, or 0 if no messages were completed.
Declaration at line 204 of file fusion_engine_framer.h, definition at line 418 of file fusion_engine_framer.cc.
Private Member Attributes
buffer_
|
Definition at line 178 of file fusion_engine_framer.h.
capacity_bytes_
|
Definition at line 179 of file fusion_engine_framer.h.
current_message_size_
|
Definition at line 183 of file fusion_engine_framer.h.
is_buffer_managed_
|
Definition at line 177 of file fusion_engine_framer.h.
next_byte_index_
|
Definition at line 182 of file fusion_engine_framer.h.
raw_callback_
|
Definition at line 173 of file fusion_engine_framer.h.
raw_callback_context_
|
Definition at line 174 of file fusion_engine_framer.h.
state_
|
Definition at line 181 of file fusion_engine_framer.h.
warn_on_error_
|
Definition at line 176 of file fusion_engine_framer.h.
The documentation for this class was generated from the following files:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.