sbgEComBinaryLogGps.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogGps.h"
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
14 {
15  //
16  // Check input arguments
17  //
18  SBG_ASSERT(pInputStream);
19  SBG_ASSERT(pOutputData);
20 
21  //
22  // Read the frame payload
23  //
24  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
25  pOutputData->status = sbgStreamBufferReadUint32LE(pInputStream);
26  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
27  pOutputData->velocity[0] = sbgStreamBufferReadFloatLE(pInputStream);
28  pOutputData->velocity[1] = sbgStreamBufferReadFloatLE(pInputStream);
29  pOutputData->velocity[2] = sbgStreamBufferReadFloatLE(pInputStream);
30  pOutputData->velocityAcc[0] = sbgStreamBufferReadFloatLE(pInputStream);
31  pOutputData->velocityAcc[1] = sbgStreamBufferReadFloatLE(pInputStream);
32  pOutputData->velocityAcc[2] = sbgStreamBufferReadFloatLE(pInputStream);
33  pOutputData->course = sbgStreamBufferReadFloatLE(pInputStream);
34  pOutputData->courseAcc = sbgStreamBufferReadFloatLE(pInputStream);
35 
36  //
37  // Return if any error has occurred while parsing the frame
38  //
39  return sbgStreamBufferGetLastError(pInputStream);
40 }
41 
49 {
50  //
51  // Check input arguments
52  //
53  SBG_ASSERT(pOutputStream);
54  SBG_ASSERT(pInputData);
55 
56  //
57  // Write the frame payload
58  //
59  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
60  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->status);
61  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
62  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[0]);
63  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[1]);
64  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[2]);
65  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[0]);
66  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[1]);
67  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[2]);
68  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->course);
69  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->courseAcc);
70 
71  //
72  // Return if any error has occurred while writing the frame
73  //
74  return sbgStreamBufferGetLastError(pOutputStream);
75 }
76 
83 {
84  //
85  // Check input arguments
86  //
87  SBG_ASSERT(pInputStream);
88  SBG_ASSERT(pOutputData);
89 
90  //
91  // Read the frame payload
92  //
93  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
94  pOutputData->status = sbgStreamBufferReadUint32LE(pInputStream);
95  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
96  pOutputData->latitude = sbgStreamBufferReadDoubleLE(pInputStream);
97  pOutputData->longitude = sbgStreamBufferReadDoubleLE(pInputStream);
98  pOutputData->altitude = sbgStreamBufferReadDoubleLE(pInputStream);
99  pOutputData->undulation = sbgStreamBufferReadFloatLE(pInputStream);
100  pOutputData->latitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
101  pOutputData->longitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
102  pOutputData->altitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
103 
104  //
105  // Test if we have a additional information such as base station id (since version 1.4)
106  //
107  if (sbgStreamBufferGetSpace(pInputStream) >= 5)
108  {
109  //
110  // Read the additional information
111  //
112  pOutputData->numSvUsed = sbgStreamBufferReadUint8LE(pInputStream);
113  pOutputData->baseStationId = sbgStreamBufferReadUint16LE(pInputStream);
114  pOutputData->differentialAge = sbgStreamBufferReadUint16LE(pInputStream);
115  }
116  else
117  {
118  //
119  // Default the additional information
120  //
121  pOutputData->numSvUsed = 0;
122  pOutputData->baseStationId = 0xFFFF;
123  pOutputData->differentialAge = 0xFFFF;
124  }
125 
126  //
127  // Return if any error has occurred while parsing the frame
128  //
129  return sbgStreamBufferGetLastError(pInputStream);
130 }
131 
139 {
140  //
141  // Check input arguments
142  //
143  SBG_ASSERT(pOutputStream);
144  SBG_ASSERT(pInputData);
145 
146  //
147  // Write the frame payload
148  //
149  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
150  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->status);
151  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
152 
153  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->latitude);
154  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->longitude);
155  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->altitude);
156 
157  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->undulation);
158 
159  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->latitudeAccuracy);
160  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->longitudeAccuracy);
161  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->altitudeAccuracy);
162 
163  //
164  // Write the additional information added in version 1.4
165  //
166  sbgStreamBufferWriteUint8LE(pOutputStream, pInputData->numSvUsed);
167  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->baseStationId);
168  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->differentialAge);
169 
170  //
171  // Return if any error has occurred while writing the frame
172  //
173  return sbgStreamBufferGetLastError(pOutputStream);
174 }
175 
183 {
184  //
185  // Check input arguments
186  //
187  SBG_ASSERT(pInputStream);
188  SBG_ASSERT(pOutputData);
189 
190  //
191  // Read the frame payload
192  //
193  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
194  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
195  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
196  pOutputData->heading = sbgStreamBufferReadFloatLE(pInputStream);
197  pOutputData->headingAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
198  pOutputData->pitch = sbgStreamBufferReadFloatLE(pInputStream);
199  pOutputData->pitchAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
200 
201  //
202  // Return if any error has occurred while parsing the frame
203  //
204  return sbgStreamBufferGetLastError(pInputStream);
205 }
206 
214 {
215  //
216  // Check input arguments
217  //
218  SBG_ASSERT(pOutputStream);
219  SBG_ASSERT(pInputData);
220 
221  //
222  // Write the frame payload
223  //
224  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
225  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
226  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
227  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->heading);
228  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->headingAccuracy);
229  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->pitch);
230  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->pitchAccuracy);
231 
232  //
233  // Return if any error has occurred while writing the frame
234  //
235  return sbgStreamBufferGetLastError(pOutputStream);
236 }
237 
245 {
246  SbgErrorCode errorCode = SBG_NO_ERROR;
247  size_t payloadSize;
248 
249  //
250  // Check input arguments
251  //
252  SBG_ASSERT(pInputStream);
253  SBG_ASSERT(pOutputData);
254 
255  //
256  // This buffer is different from other because only a variable size raw buffer is stored
257  // We use the payload size (read from the low level protocol) to know the buffer size
258  //
259  // Please note that the provided stream buffer points to the payload part only so it's size is the payload size
260  //
261  payloadSize = sbgStreamBufferGetSize(pInputStream);
262 
263  //
264  // Check that the received buffer can be stored in the RAW message log
265  //
266  if (payloadSize <= SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE)
267  {
268  //
269  // Copy the buffer
270  //
271  errorCode = sbgStreamBufferReadBuffer(pInputStream, pOutputData->rawBuffer, payloadSize);
272  pOutputData->bufferSize = payloadSize;
273  }
274  else
275  {
276  //
277  // Unable to store the received buffer due to buffer overflow
278  //
279  errorCode = SBG_BUFFER_OVERFLOW;
280  }
281 
282  return errorCode;
283 }
284 
292 {
293  //
294  // Check input arguments
295  //
296  SBG_ASSERT(pOutputStream);
297  SBG_ASSERT(pInputData);
298 
299  //
300  // Write the buffer and return if any error has occurred
301  //
302  return sbgStreamBufferWriteBuffer(pOutputStream, pInputData->rawBuffer, pInputData->bufferSize);
303 }
This file is used to parse received GPS binary logs.
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteDoubleLE(SbgStreamBuffer *pHandle, double value)
SbgErrorCode sbgEComBinaryLogParseGpsRawData(SbgStreamBuffer *pInputStream, SbgLogGpsRaw *pOutputData)
SbgErrorCode sbgEComBinaryLogWriteGpsVelData(SbgStreamBuffer *pOutputStream, const SbgLogGpsVel *pInputData)
SBG_INLINE size_t sbgStreamBufferGetSize(SbgStreamBuffer *pHandle)
SBG_INLINE uint16 sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
uint8 rawBuffer[SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE]
SbgErrorCode sbgEComBinaryLogWriteGpsHdtData(SbgStreamBuffer *pOutputStream, const SbgLogGpsHdt *pInputData)
SbgErrorCode sbgEComBinaryLogParseGpsHdtData(SbgStreamBuffer *pInputStream, SbgLogGpsHdt *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
SBG_INLINE size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle)
#define sbgStreamBufferWriteUint8LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
SBG_INLINE uint32 sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
#define SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16 value)
#define sbgStreamBufferReadUint8LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32 value)
SbgErrorCode sbgEComBinaryLogWriteGpsPosData(SbgStreamBuffer *pOutputStream, const SbgLogGpsPos *pInputData)
#define SBG_ASSERT(expression)
Definition: sbgDebug.h:52
SBG_INLINE double sbgStreamBufferReadDoubleLE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComBinaryLogWriteGpsRawData(SbgStreamBuffer *pOutputStream, const SbgLogGpsRaw *pInputData)
enum _SbgErrorCode SbgErrorCode
SbgErrorCode sbgEComBinaryLogParseGpsVelData(SbgStreamBuffer *pInputStream, SbgLogGpsVel *pOutputData)
SbgErrorCode sbgEComBinaryLogParseGpsPosData(SbgStreamBuffer *pInputStream, SbgLogGpsPos *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20