sbgEComBinaryLogGps.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogGps.h"
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
14 {
15  assert(pInputStream);
16  assert(pOutputData);
17 
18  //
19  // Read the frame payload
20  //
21  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
22  pOutputData->status = sbgStreamBufferReadUint32LE(pInputStream);
23  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
24  pOutputData->velocity[0] = sbgStreamBufferReadFloatLE(pInputStream);
25  pOutputData->velocity[1] = sbgStreamBufferReadFloatLE(pInputStream);
26  pOutputData->velocity[2] = sbgStreamBufferReadFloatLE(pInputStream);
27  pOutputData->velocityAcc[0] = sbgStreamBufferReadFloatLE(pInputStream);
28  pOutputData->velocityAcc[1] = sbgStreamBufferReadFloatLE(pInputStream);
29  pOutputData->velocityAcc[2] = sbgStreamBufferReadFloatLE(pInputStream);
30  pOutputData->course = sbgStreamBufferReadFloatLE(pInputStream);
31  pOutputData->courseAcc = sbgStreamBufferReadFloatLE(pInputStream);
32 
33  //
34  // Return if any error has occurred while parsing the frame
35  //
36  return sbgStreamBufferGetLastError(pInputStream);
37 }
38 
46 {
47  assert(pOutputStream);
48  assert(pInputData);
49 
50  //
51  // Write the frame payload
52  //
53  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
54  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->status);
55  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
56  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[0]);
57  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[1]);
58  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocity[2]);
59  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[0]);
60  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[1]);
61  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->velocityAcc[2]);
62  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->course);
63  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->courseAcc);
64 
65  //
66  // Return if any error has occurred while writing the frame
67  //
68  return sbgStreamBufferGetLastError(pOutputStream);
69 }
70 
77 {
78  assert(pInputStream);
79  assert(pOutputData);
80 
81  //
82  // Read the frame payload
83  //
84  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
85  pOutputData->status = sbgStreamBufferReadUint32LE(pInputStream);
86  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
87  pOutputData->latitude = sbgStreamBufferReadDoubleLE(pInputStream);
88  pOutputData->longitude = sbgStreamBufferReadDoubleLE(pInputStream);
89  pOutputData->altitude = sbgStreamBufferReadDoubleLE(pInputStream);
90  pOutputData->undulation = sbgStreamBufferReadFloatLE(pInputStream);
91  pOutputData->latitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
92  pOutputData->longitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
93  pOutputData->altitudeAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
94 
95  //
96  // Test if we have a additional information such as base station id (since version 1.4)
97  //
98  if (sbgStreamBufferGetSpace(pInputStream) >= 5)
99  {
100  //
101  // Read the additional information
102  //
103  pOutputData->numSvUsed = sbgStreamBufferReadUint8LE(pInputStream);
104  pOutputData->baseStationId = sbgStreamBufferReadUint16LE(pInputStream);
105  pOutputData->differentialAge = sbgStreamBufferReadUint16LE(pInputStream);
106  }
107  else
108  {
109  //
110  // Default the additional information
111  //
112  pOutputData->numSvUsed = 0;
113  pOutputData->baseStationId = 0xFFFF;
114  pOutputData->differentialAge = 0xFFFF;
115  }
116 
117  //
118  // Return if any error has occurred while parsing the frame
119  //
120  return sbgStreamBufferGetLastError(pInputStream);
121 }
122 
130 {
131  assert(pOutputStream);
132  assert(pInputData);
133 
134  //
135  // Write the frame payload
136  //
137  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
138  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->status);
139  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
140 
141  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->latitude);
142  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->longitude);
143  sbgStreamBufferWriteDoubleLE(pOutputStream, pInputData->altitude);
144 
145  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->undulation);
146 
147  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->latitudeAccuracy);
148  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->longitudeAccuracy);
149  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->altitudeAccuracy);
150 
151  //
152  // Write the additional information added in version 1.4
153  //
154  sbgStreamBufferWriteUint8LE(pOutputStream, pInputData->numSvUsed);
155  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->baseStationId);
156  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->differentialAge);
157 
158  //
159  // Return if any error has occurred while writing the frame
160  //
161  return sbgStreamBufferGetLastError(pOutputStream);
162 }
163 
171 {
172  assert(pInputStream);
173  assert(pOutputData);
174 
175  //
176  // Read the frame payload
177  //
178  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
179  pOutputData->status = sbgStreamBufferReadUint16LE(pInputStream);
180  pOutputData->timeOfWeek = sbgStreamBufferReadUint32LE(pInputStream);
181  pOutputData->heading = sbgStreamBufferReadFloatLE(pInputStream);
182  pOutputData->headingAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
183  pOutputData->pitch = sbgStreamBufferReadFloatLE(pInputStream);
184  pOutputData->pitchAccuracy = sbgStreamBufferReadFloatLE(pInputStream);
185 
186  //
187  // The baseline field have been added in version 2.0
188  //
189  if (sbgStreamBufferGetSpace(pInputStream) > 0)
190  {
191  pOutputData->baseline = sbgStreamBufferReadFloatLE(pInputStream);
192  }
193  else
194  {
195  pOutputData->baseline = 0.0f;
196  }
197 
198  //
199  // Return if any error has occurred while parsing the frame
200  //
201  return sbgStreamBufferGetLastError(pInputStream);
202 }
203 
211 {
212  assert(pOutputStream);
213  assert(pInputData);
214 
215  //
216  // Write the frame payload
217  //
218  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
219  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
220  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeOfWeek);
221  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->heading);
222  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->headingAccuracy);
223  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->pitch);
224  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->pitchAccuracy);
225  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->baseline);
226 
227  //
228  // Return if any error has occurred while writing the frame
229  //
230  return sbgStreamBufferGetLastError(pOutputStream);
231 }
232 
240 {
241  SbgErrorCode errorCode = SBG_NO_ERROR;
242  size_t payloadSize;
243 
244  assert(pInputStream);
245  assert(pOutputData);
246 
247  //
248  // This buffer is different from other because only a variable size raw buffer is stored
249  // We use the payload size (read from the low level protocol) to know the buffer size
250  //
251  // Please note that the provided stream buffer points to the payload part only so it's size is the payload size
252  //
253  payloadSize = sbgStreamBufferGetSize(pInputStream);
254 
255  //
256  // Check that the received buffer can be stored in the RAW message log
257  //
258  if (payloadSize <= SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE)
259  {
260  //
261  // Copy the buffer
262  //
263  errorCode = sbgStreamBufferReadBuffer(pInputStream, pOutputData->rawBuffer, payloadSize);
264  pOutputData->bufferSize = payloadSize;
265  }
266  else
267  {
268  //
269  // Unable to store the received buffer due to buffer overflow
270  //
271  errorCode = SBG_BUFFER_OVERFLOW;
272  }
273 
274  return errorCode;
275 }
276 
284 {
285  assert(pOutputStream);
286  assert(pInputData);
287 
288  //
289  // Write the buffer and return if any error has occurred
290  //
291  return sbgStreamBufferWriteBuffer(pOutputStream, pInputData->rawBuffer, pInputData->bufferSize);
292 }
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)
uint8_t rawBuffer[SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE]
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
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)
#define SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE
#define sbgStreamBufferReadUint8LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SbgErrorCode sbgEComBinaryLogWriteGpsPosData(SbgStreamBuffer *pOutputStream, const SbgLogGpsPos *pInputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
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): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35