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 }
_SbgLogGpsPos::longitudeAccuracy
float longitudeAccuracy
Definition: sbgEComBinaryLogGps.h:292
sbgStreamBufferReadUint8LE
#define sbgStreamBufferReadUint8LE
Definition: sbgStreamBufferCommon.h:141
sbgStreamBufferWriteDoubleLE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteDoubleLE(SbgStreamBuffer *pHandle, double value)
Definition: sbgStreamBufferLE.h:1787
sbgEComBinaryLogWriteGpsPosData
SbgErrorCode sbgEComBinaryLogWriteGpsPosData(SbgStreamBuffer *pOutputStream, const SbgLogGpsPos *pInputData)
Definition: sbgEComBinaryLogGps.c:129
_SbgLogGpsVel::course
float course
Definition: sbgEComBinaryLogGps.h:275
sbgStreamBufferWriteFloatLE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
Definition: sbgStreamBufferLE.h:1753
sbgStreamBufferGetLastError
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferCommon.h:274
sbgEComBinaryLogParseGpsHdtData
SbgErrorCode sbgEComBinaryLogParseGpsHdtData(SbgStreamBuffer *pInputStream, SbgLogGpsHdt *pOutputData)
Definition: sbgEComBinaryLogGps.c:170
_SbgLogGpsHdt::headingAccuracy
float headingAccuracy
Definition: sbgEComBinaryLogGps.h:308
sbgEComBinaryLogWriteGpsHdtData
SbgErrorCode sbgEComBinaryLogWriteGpsHdtData(SbgStreamBuffer *pOutputStream, const SbgLogGpsHdt *pInputData)
Definition: sbgEComBinaryLogGps.c:210
_SbgLogGpsRaw::rawBuffer
uint8_t rawBuffer[SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE]
Definition: sbgEComBinaryLogGps.h:319
sbgStreamBufferReadUint16LE
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferLE.h:106
_SbgLogGpsVel::velocity
float velocity[3]
Definition: sbgEComBinaryLogGps.h:273
_SbgLogGpsHdt::timeStamp
uint32_t timeStamp
Definition: sbgEComBinaryLogGps.h:304
_SbgLogGpsHdt::status
uint16_t status
Definition: sbgEComBinaryLogGps.h:305
_SbgLogGpsHdt
Definition: sbgEComBinaryLogGps.h:302
_SbgLogGpsVel::timeOfWeek
uint32_t timeOfWeek
Definition: sbgEComBinaryLogGps.h:272
_SbgLogGpsVel::status
uint32_t status
Definition: sbgEComBinaryLogGps.h:271
sbgStreamBufferReadDoubleLE
SBG_INLINE double sbgStreamBufferReadDoubleLE(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferLE.h:1135
sbgStreamBufferWriteBuffer
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
Definition: sbgStreamBufferCommon.h:814
_SbgLogGpsPos::undulation
float undulation
Definition: sbgEComBinaryLogGps.h:290
_SbgLogGpsPos::baseStationId
uint16_t baseStationId
Definition: sbgEComBinaryLogGps.h:295
sbgStreamBufferWriteUint16LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
Definition: sbgStreamBufferLE.h:1250
_SbgLogGpsPos::differentialAge
uint16_t differentialAge
Definition: sbgEComBinaryLogGps.h:296
_SbgLogGpsPos::altitudeAccuracy
float altitudeAccuracy
Definition: sbgEComBinaryLogGps.h:293
_SbgLogGpsHdt::timeOfWeek
uint32_t timeOfWeek
Definition: sbgEComBinaryLogGps.h:306
sbgEComBinaryLogParseGpsRawData
SbgErrorCode sbgEComBinaryLogParseGpsRawData(SbgStreamBuffer *pInputStream, SbgLogGpsRaw *pOutputData)
Definition: sbgEComBinaryLogGps.c:239
sbgStreamBufferGetSpace
SBG_INLINE size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferCommon.h:353
sbgEComBinaryLogWriteGpsVelData
SbgErrorCode sbgEComBinaryLogWriteGpsVelData(SbgStreamBuffer *pOutputStream, const SbgLogGpsVel *pInputData)
Definition: sbgEComBinaryLogGps.c:45
sbgStreamBufferReadUint32LE
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferLE.h:386
sbgEComBinaryLogWriteGpsRawData
SbgErrorCode sbgEComBinaryLogWriteGpsRawData(SbgStreamBuffer *pOutputStream, const SbgLogGpsRaw *pInputData)
Definition: sbgEComBinaryLogGps.c:283
_SbgLogGpsPos::longitude
double longitude
Definition: sbgEComBinaryLogGps.h:288
_SbgLogGpsPos
Definition: sbgEComBinaryLogGps.h:282
_SbgLogGpsPos::latitudeAccuracy
float latitudeAccuracy
Definition: sbgEComBinaryLogGps.h:291
sbgStreamBufferGetSize
SBG_INLINE size_t sbgStreamBufferGetSize(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferCommon.h:312
_SbgLogGpsHdt::heading
float heading
Definition: sbgEComBinaryLogGps.h:307
_SbgLogGpsVel
Definition: sbgEComBinaryLogGps.h:268
sbgStreamBufferReadBuffer
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
Definition: sbgStreamBufferCommon.h:636
sbgEComBinaryLogGps.h
_SbgStreamBuffer
Definition: sbgStreamBufferCommon.h:188
_SbgLogGpsPos::latitude
double latitude
Definition: sbgEComBinaryLogGps.h:287
sbgStreamBufferWriteUint8LE
#define sbgStreamBufferWriteUint8LE
Definition: sbgStreamBufferCommon.h:146
SBG_NO_ERROR
@ SBG_NO_ERROR
Definition: sbgErrorCodes.h:35
SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE
#define SBG_ECOM_GPS_RAW_MAX_BUFFER_SIZE
Definition: sbgEComBinaryLogGps.h:78
_SbgLogGpsPos::status
uint32_t status
Definition: sbgEComBinaryLogGps.h:285
sbgEComBinaryLogParseGpsVelData
SbgErrorCode sbgEComBinaryLogParseGpsVelData(SbgStreamBuffer *pInputStream, SbgLogGpsVel *pOutputData)
Definition: sbgEComBinaryLogGps.c:13
sbgEComBinaryLogParseGpsPosData
SbgErrorCode sbgEComBinaryLogParseGpsPosData(SbgStreamBuffer *pInputStream, SbgLogGpsPos *pOutputData)
Definition: sbgEComBinaryLogGps.c:76
_SbgLogGpsVel::timeStamp
uint32_t timeStamp
Definition: sbgEComBinaryLogGps.h:270
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
_SbgLogGpsPos::timeOfWeek
uint32_t timeOfWeek
Definition: sbgEComBinaryLogGps.h:286
_SbgLogGpsPos::altitude
double altitude
Definition: sbgEComBinaryLogGps.h:289
SBG_BUFFER_OVERFLOW
@ SBG_BUFFER_OVERFLOW
Definition: sbgErrorCodes.h:46
sbgStreamBufferReadFloatLE
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferLE.h:1086
_SbgLogGpsPos::timeStamp
uint32_t timeStamp
Definition: sbgEComBinaryLogGps.h:284
_SbgLogGpsHdt::pitch
float pitch
Definition: sbgEComBinaryLogGps.h:309
sbgStreamBufferWriteUint32LE
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
Definition: sbgStreamBufferLE.h:1499
_SbgLogGpsRaw::bufferSize
size_t bufferSize
Definition: sbgEComBinaryLogGps.h:320
_SbgLogGpsHdt::baseline
float baseline
Definition: sbgEComBinaryLogGps.h:311
_SbgLogGpsVel::velocityAcc
float velocityAcc[3]
Definition: sbgEComBinaryLogGps.h:274
_SbgLogGpsHdt::pitchAccuracy
float pitchAccuracy
Definition: sbgEComBinaryLogGps.h:310
_SbgLogGpsVel::courseAcc
float courseAcc
Definition: sbgEComBinaryLogGps.h:276
_SbgLogGpsPos::numSvUsed
uint8_t numSvUsed
Definition: sbgEComBinaryLogGps.h:294
_SbgLogGpsRaw
Definition: sbgEComBinaryLogGps.h:317


sbg_driver
Author(s): SBG Systems
autogenerated on Fri Oct 11 2024 02:13:40