VectorNav C Library
upackf.h
1 #ifndef VNUPACKF_H_INCLUDED
2 #define VNUPACKF_H_INCLUDED
3 
4 #include "vn/protocol/upack.h"
5 
6 /*#include "vnint.h"*/
7 /*#include "vnbool.h"*/
8 /*#include "vntypes.h"
9 #include "vnerror.h"*/
10 
11 
12 #ifndef VNUART_PROTOCOL_BUFFER_SIZE
13 
14  #define VNUART_PROTOCOL_BUFFER_SIZE 256
15 #endif
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
24 typedef void(*VnUartPacketFinder_PacketFoundHandler)(void *userData, VnUartPacket* packet, size_t runningIndexOfPacketStart);
25 
26 #ifdef _WIN32
27 #pragma warning(push)
28 #pragma warning(disable : 4820)
29 #endif
30 
38 typedef struct
39 {
41  VnUartPacketFinder_PacketFoundHandler packetFoundHandler;
42 
45 
49 
52 
55 
58 
61 
64 
67 
69  size_t bufferSize;
70 
73 
77 
80 
84 
87 
91 
93  uint8_t receiveBuffer[VNUART_PROTOCOL_BUFFER_SIZE];
94 
96 
97 #ifdef _WIN32
98 #pragma warning(pop)
99 #endif
100 
104 void VnUartPacketFinder_initialize(VnUartPacketFinder* pf);
105 
112 VnError VnUartPacketFinder_processData(VnUartPacketFinder* finder, uint8_t* data, size_t len);
113 
119 VnError VnUartPacketFinder_registerPacketFoundHandler(VnUartPacketFinder* finder, VnUartPacketFinder_PacketFoundHandler handler, void *userData);
120 
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif
size_t binaryPossibleStartIndex
Start index of a possible binary packet.
Definition: upackf.h:86
Data structure holding current parsing status of data received from a VectorNav sensor.
Definition: upackf.h:38
bool asciiEndChar1Found
Indicates if the first ending character has been found.
Definition: upackf.h:60
bool binaryGroupsPresentFound
Indicates if we have found the groups present data field for a binary packet we are building...
Definition: upackf.h:76
Structure representing a UART packet received from a VectorNav sensor.
Definition: upack.h:34
size_t runningDataIndex
Used for correlating the position in the received raw data stream where packets are found...
Definition: upackf.h:48
VnUartPacketFinder_PacketFoundHandler packetFoundHandler
Callback for when a packet has been found and validated.
Definition: upackf.h:41
size_t asciiRunningDataIndexOfStart
Index of start of ASCII packet in total running index.
Definition: upackf.h:57
size_t bufferSize
Holds the size of the receive buffer.
Definition: upackf.h:69
bool asciiCurrentlyBuildingPacket
Indicates if an ASCII packet is currently being built.
Definition: upackf.h:51
size_t binaryNumberOfBytesRemainingForCompletePacket
Keeps track of the number of bytes remaining for a complete binary packet.
Definition: upackf.h:90
size_t binaryRunningDataIndexOfStart
Index of start of binary packet in total running index.
Definition: upackf.h:66
size_t bufferAppendLocation
The current location to append data into the buffer.
Definition: upackf.h:72
void * packetFoundHandlerUserData
User data for callbacks on the packetFoundHandler.
Definition: upackf.h:44
bool binaryCurrentlyBuildingBinaryPacket
Indicates if we are currently building a binary packet.
Definition: upackf.h:63
size_t asciiPossibleStartOfPacketIndex
Indicates a suspected start of an ASCII packet.
Definition: upackf.h:54
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
uint8_t binaryGroupsPresent
The groups present found from a binary packet.
Definition: upackf.h:79