VectorNav C++ Library
Public Types | Public Member Functions | List of all members
vn::protocol::uart::PacketFinder Class Reference

Helps with management of communication with a sensor using the UART protocol. More...

#include <packetfinder.h>

Inheritance diagram for vn::protocol::uart::PacketFinder:
vn::util::NoCopy

Public Types

typedef void(* 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. More...
 

Public Member Functions

 PacketFinder ()
 Creates a new /ref PacketFinder with internal buffers to store incoming bytes and alert when valid packets are received.
 
 PacketFinder (size_t internalReceiveBufferSize)
 Creates a new /ref PacketFinder with an internal buffer the size specified. More...
 
void 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. More...
 
void 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. More...
 
void registerPossiblePacketFoundHandler (void *userData, ValidPacketFoundHandler handler)
 Registers a callback method for notification when a new possible packet is found. More...
 
void unregisterPossiblePacketFoundHandler ()
 Unregisters the registered callback method.
 

Detailed Description

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.

Member Typedef Documentation

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]userDataPointer to user data that was initially supplied when the callback was registered via registerPossiblePacketFoundHandler.
[in]possiblePacketThe possible packet that was found.
[in]packetStartRunningIndexThe running index of the start of the packet.
[in]timestampThe timestamp the packet was found.
Examples:
uart_protocol/main.cpp.

Constructor & Destructor Documentation

vn::protocol::uart::PacketFinder::PacketFinder ( size_t  internalReceiveBufferSize)
explicit

Creates a new /ref PacketFinder with an internal buffer the size specified.

Parameters
[in]internalReceiveBufferSizeThe number of bytes to make the internal buffer.

Member Function Documentation

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]dataThe data buffer containing the received data.
[in]lengthThe 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]dataThe data buffer containing the received data.
[in]lengthThe number of bytes of data in the buffer.
[in]timestampThe 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]userDataPointer to user data, which will be provided to the callback method.
[in]handlerThe callback method.
Examples:
uart_protocol/main.cpp.

The documentation for this class was generated from the following file: