C++ class representing a MIP parser.
More...
#include <mip_parser.hpp>
|
| Parser (C::mip_packet_callback callback, void *callbackObject, Timeout timeout) |
| Initializes the MIP parser. More...
|
|
| Parser (void(*callback)(void *, const PacketView *, Timestamp), void *callbackObject, Timeout timeout) |
| Initializes the MIP parser. More...
|
|
| Parser (Timeout timeout) |
|
template<class T , bool(T::*)(const PacketView &, Timestamp) Callback> |
void | setCallback (T &object) |
| Initializes the MIP Parser. More...
|
|
void | reset () |
| Resets the MIP parser. More...
|
|
void | parse (const uint8_t *inputBuffer, size_t inputCount, Timestamp timestamp) |
| Parse packets from a buffer. More...
|
|
void | parse (microstrain::Span< const uint8_t > data, Timestamp timestamp) |
| Parse packets from a buffer (span version). More...
|
|
Timeout | timeout () const |
| Returns the packet timeout of the parser. More...
|
|
void | setTimeout (Timeout timeout) |
| Changes the timeout of the MIP parser. More...
|
|
C++ class representing a MIP parser.
See Mip Parser
◆ Parser() [1/3]
Initializes the MIP parser.
- Parameters
-
parser | |
callback | A function to be called when a valid packet is identified. It will be passed an optional user-supplied parameter, a pointer to the packet, and the time the first byte was parsed. |
callback_object | An optional user-specified pointer which is directly passed to the callback as the first parameter. |
timeout | The timeout for receiving one packet. Depends on the serial baud rate and is typically 100 milliseconds. |
◆ Parser() [2/3]
Initializes the MIP parser.
- Parameters
-
parser | |
callback | A function to be called when a valid packet is identified. It will be passed an optional user-supplied parameter, a pointer to the packet, and the time the first byte was parsed. |
callback_object | An optional user-specified pointer which is directly passed to the callback as the first parameter. |
timeout | The timeout for receiving one packet. Depends on the serial baud rate and is typically 100 milliseconds. |
◆ Parser() [3/3]
mip::Parser::Parser |
( |
Timeout |
timeout | ) |
|
|
inline |
◆ parse() [1/2]
void mip::Parser::parse |
( |
const uint8_t * |
inputBuffer, |
|
|
size_t |
inputCount, |
|
|
Timestamp |
timestamp |
|
) |
| |
|
inline |
Parse packets from a buffer.
The buffer may contain non-mip data (e.g. NMEA 0183) which will be ignored.
- Parameters
-
parser | |
input_buffer | Buffer from which to parse packets. If NULL, parses from the internal buffer instead (see mip_parser_get_write_ptr). |
input_length | Length of data in the buffer. |
timestamp | Time of arrival of the data to be parsed. This is used to set packets' timestamp and to time out incomplete packets. |
- Note
- The timestamp of a packet is based on the time the packet was parsed. Packets received during an earlier parse call may be timestamped with the time from a later parse call, but will never be timestamped before they were actually received.
-
The parser will do its best to ignore non-MIP data. However, it is possible for some binary data to appear to be a MIP packet if it contains the two-byte sequence 0x75, 0x65. This may cause temporary stalls in parsed data if the following bytes suggest that more data is needed to complete the "packet". Once the fake packet times out or enough data is received, real MIP packets received in the meantime will be properly parsed. Note that the 16-bit checksum has a 1 in 65,536 chance of appearing to be valid at random.
◆ parse() [2/2]
Parse packets from a buffer (span version).
The buffer may contain non-mip data (e.g. NMEA 0183) which will be ignored.
- Parameters
-
parser | |
input_buffer | Buffer from which to parse packets. If NULL, parses from the internal buffer instead (see mip_parser_get_write_ptr). |
input_length | Length of data in the buffer. |
timestamp | Time of arrival of the data to be parsed. This is used to set packets' timestamp and to time out incomplete packets. |
- Note
- The timestamp of a packet is based on the time the packet was parsed. Packets received during an earlier parse call may be timestamped with the time from a later parse call, but will never be timestamped before they were actually received.
-
The parser will do its best to ignore non-MIP data. However, it is possible for some binary data to appear to be a MIP packet if it contains the two-byte sequence 0x75, 0x65. This may cause temporary stalls in parsed data if the following bytes suggest that more data is needed to complete the "packet". Once the fake packet times out or enough data is received, real MIP packets received in the meantime will be properly parsed. Note that the 16-bit checksum has a 1 in 65,536 chance of appearing to be valid at random.
◆ reset()
void mip::Parser::reset |
( |
| ) |
|
|
inline |
Resets the MIP parser.
Clears the current packet and internal buffer. The parser will be restored as if mip_parser_init had just been called.
- Parameters
-
◆ setTimeout()
void mip::Parser::setTimeout |
( |
Timeout |
timeout | ) |
|
|
inline |
Changes the timeout of the MIP parser.
- Parameters
-
◆ timeout()
Timeout mip::Parser::timeout |
( |
| ) |
const |
|
inline |
Returns the packet timeout of the parser.
The documentation for this class was generated from the following file: