upackf.h
#ifndef VNUPACKF_H_INCLUDED
#define VNUPACKF_H_INCLUDED
#include "vn/protocol/upack.h"
/*#include "vnint.h"*/
/*#include "vnbool.h"*/
/*#include "vntypes.h"
#include "vnerror.h"*/
#ifndef VNUART_PROTOCOL_BUFFER_SIZE
#define VNUART_PROTOCOL_BUFFER_SIZE 256
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef void(*VnUartPacketFinder_PacketFoundHandler)(void *userData, VnUartPacket* packet, size_t runningIndexOfPacketStart);
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable : 4820)
#endif
typedef struct
{
VnUartPacketFinder_PacketFoundHandler packetFoundHandler;
void *packetFoundHandlerUserData;
size_t runningDataIndex;
bool asciiCurrentlyBuildingPacket;
size_t asciiPossibleStartOfPacketIndex;
size_t asciiRunningDataIndexOfStart;
bool asciiEndChar1Found;
bool binaryCurrentlyBuildingBinaryPacket;
size_t binaryRunningDataIndexOfStart;
size_t bufferSize;
size_t bufferAppendLocation;
bool binaryGroupsPresentFound;
uint8_t binaryGroupsPresent;
uint8_t binaryNumOfBytesRemainingToHaveAllGroupFields;
size_t binaryPossibleStartIndex;
size_t binaryNumberOfBytesRemainingForCompletePacket;
uint8_t receiveBuffer[VNUART_PROTOCOL_BUFFER_SIZE];
} VnUartPacketFinder;
#ifdef _WIN32
#pragma warning(pop)
#endif
void VnUartPacketFinder_initialize(VnUartPacketFinder* pf);
VnError VnUartPacketFinder_processData(VnUartPacketFinder* finder, uint8_t* data, size_t len);
VnError VnUartPacketFinder_registerPacketFoundHandler(VnUartPacketFinder* finder, VnUartPacketFinder_PacketFoundHandler handler, void *userData);
#ifdef __cplusplus
}
#endif
#endif
VnUartPacketFinder::binaryPossibleStartIndex
size_t binaryPossibleStartIndex
Start index of a possible binary packet.
Definition: upackf.h:86
VnUartPacketFinder
Data structure holding current parsing status of data received from a VectorNav sensor.
Definition: upackf.h:38
VnUartPacketFinder::asciiEndChar1Found
bool asciiEndChar1Found
Indicates if the first ending character has been found.
Definition: upackf.h:60
VnUartPacketFinder::binaryGroupsPresentFound
bool binaryGroupsPresentFound
Indicates if we have found the groups present data field for a binary packet we are building...
Definition: upackf.h:76
VnUartPacket
Structure representing a UART packet received from a VectorNav sensor.
Definition: upack.h:34
VnUartPacketFinder::runningDataIndex
size_t runningDataIndex
Used for correlating the position in the received raw data stream where packets are found...
Definition: upackf.h:48
VnUartPacketFinder::packetFoundHandler
VnUartPacketFinder_PacketFoundHandler packetFoundHandler
Callback for when a packet has been found and validated.
Definition: upackf.h:41
VnUartPacketFinder::asciiRunningDataIndexOfStart
size_t asciiRunningDataIndexOfStart
Index of start of ASCII packet in total running index.
Definition: upackf.h:57
VnUartPacketFinder::bufferSize
size_t bufferSize
Holds the size of the receive buffer.
Definition: upackf.h:69
VnUartPacketFinder::asciiCurrentlyBuildingPacket
bool asciiCurrentlyBuildingPacket
Indicates if an ASCII packet is currently being built.
Definition: upackf.h:51
VnUartPacketFinder::binaryNumberOfBytesRemainingForCompletePacket
size_t binaryNumberOfBytesRemainingForCompletePacket
Keeps track of the number of bytes remaining for a complete binary packet.
Definition: upackf.h:90
VnUartPacketFinder::binaryRunningDataIndexOfStart
size_t binaryRunningDataIndexOfStart
Index of start of binary packet in total running index.
Definition: upackf.h:66
VnUartPacketFinder::bufferAppendLocation
size_t bufferAppendLocation
The current location to append data into the buffer.
Definition: upackf.h:72
VnUartPacketFinder::packetFoundHandlerUserData
void * packetFoundHandlerUserData
User data for callbacks on the packetFoundHandler.
Definition: upackf.h:44
VnUartPacketFinder::binaryCurrentlyBuildingBinaryPacket
bool binaryCurrentlyBuildingBinaryPacket
Indicates if we are currently building a binary packet.
Definition: upackf.h:63
VnUartPacketFinder::asciiPossibleStartOfPacketIndex
size_t asciiPossibleStartOfPacketIndex
Indicates a suspected start of an ASCII packet.
Definition: upackf.h:54
VnUartPacketFinder::binaryNumOfBytesRemainingToHaveAllGroupFields
uint8_t binaryNumOfBytesRemainingToHaveAllGroupFields
Indicates the number of bytes remaining to have all group fields for a binary data packet we are proc...
Definition: upackf.h:83
VnUartPacketFinder::binaryGroupsPresent
uint8_t binaryGroupsPresent
The groups present found from a binary packet.
Definition: upackf.h:79