Helps with management of communication with a sensor using the UART protocol.
More...
#include <packetfinder.h>
Helps with management of communication with a sensor using the UART protocol.
Internally, the PacketFinder keeps track of a running data index which keeps a running count of the bytes that are processed by the class. This is useful for users who wish to keep track of where packets where found in the incoming raw data stream. When the PacketFinder receives its first byte from the user, this is given the index of 0 for the running index and incremented for each byte received.
- Examples:
- uart_protocol/main.cpp.
typedef void(* vn::protocol::uart::PacketFinder::ValidPacketFoundHandler) (void *userData, Packet &packet, size_t runningIndexOfPacketStart, xplat::TimeStamp timestamp) |
Defines the signature for a method that can receive notifications of new valid packets found.
- Parameters
-
[in] | userData | Pointer to user data that was initially supplied when the callback was registered via registerPossiblePacketFoundHandler. |
[in] | possiblePacket | The possible packet that was found. |
[in] | packetStartRunningIndex | The running index of the start of the packet. |
[in] | timestamp | The timestamp the packet was found. |
- Examples:
- uart_protocol/main.cpp.
vn::protocol::uart::PacketFinder::PacketFinder |
( |
size_t |
internalReceiveBufferSize | ) |
|
|
explicit |
Creates a new /ref PacketFinder with an internal buffer the size specified.
- Parameters
-
[in] | internalReceiveBufferSize | The number of bytes to make the internal buffer. |
void vn::protocol::uart::PacketFinder::processReceivedData |
( |
char |
data[], |
|
|
size_t |
length |
|
) |
| |
Adds new data to the internal buffers and processes the received data to determine if any new received packets are available.
- Parameters
-
[in] | data | The data buffer containing the received data. |
[in] | length | The number of bytes of data in the buffer. |
- Examples:
- uart_protocol/main.cpp.
void vn::protocol::uart::PacketFinder::processReceivedData |
( |
char |
data[], |
|
|
size_t |
length, |
|
|
xplat::TimeStamp |
timestamp |
|
) |
| |
Adds new data to the internal buffers and processes the received data to determine if any new received packets are available.
- Parameters
-
[in] | data | The data buffer containing the received data. |
[in] | length | The number of bytes of data in the buffer. |
[in] | timestamp | The time when the data was received. |
void vn::protocol::uart::PacketFinder::registerPossiblePacketFoundHandler |
( |
void * |
userData, |
|
|
ValidPacketFoundHandler |
handler |
|
) |
| |
Registers a callback method for notification when a new possible packet is found.
- Parameters
-
[in] | userData | Pointer to user data, which will be provided to the callback method. |
[in] | handler | The callback method. |
- Examples:
- uart_protocol/main.cpp.
The documentation for this class was generated from the following file: