sbgEComBinaryLogMag.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogMag.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 = sbgStreamBufferReadUint16LE(pInputStream);
23 
24  pOutputData->magnetometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
25  pOutputData->magnetometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
26  pOutputData->magnetometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
27 
28  pOutputData->accelerometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
29  pOutputData->accelerometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
30  pOutputData->accelerometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
31 
32  //
33  // Return if any error has occurred while parsing the frame
34  //
35  return sbgStreamBufferGetLastError(pInputStream);
36 }
37 
45 {
46  assert(pOutputStream);
47  assert(pInputData);
48 
49  //
50  // Write the frame payload
51  //
52  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
53  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
54 
55  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[0]);
56  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[1]);
57  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[2]);
58 
59  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[0]);
60  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[1]);
61  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[2]);
62 
63  //
64  // Return if any error has occurred while writing the frame
65  //
66  return sbgStreamBufferGetLastError(pOutputStream);
67 }
68 
76 {
77  assert(pInputStream);
78  assert(pOutputData);
79 
80  //
81  // Read the frame payload
82  //
83  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
84  pOutputData->reserved = sbgStreamBufferReadUint16LE(pInputStream);
85 
86  //
87  // Read the raw magnetic calibration data buffer
88  //
89  return sbgStreamBufferReadBuffer(pInputStream, pOutputData->magData, sizeof(pOutputData->magData));
90 }
91 
99 {
100  assert(pOutputStream);
101  assert(pInputData);
102 
103  //
104  // Write the frame payload
105  //
106  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
107  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->reserved);
108 
109  //
110  // Write the raw magnetic calibration data buffer
111  //
112  return sbgStreamBufferWriteBuffer(pOutputStream, pInputData->magData, sizeof(pInputData->magData));
113 }
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComBinaryLogWriteMagCalibData(SbgStreamBuffer *pOutputStream, const SbgLogMagCalib *pInputData)
SbgErrorCode sbgEComBinaryLogWriteMagData(SbgStreamBuffer *pOutputStream, const SbgLogMag *pInputData)
SbgErrorCode sbgEComBinaryLogParseMagCalibData(SbgStreamBuffer *pInputStream, SbgLogMagCalib *pOutputData)
This file is used to parse received magnetometer binary logs.
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
float accelerometers[3]
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
float magnetometers[3]
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
SbgErrorCode sbgEComBinaryLogParseMagData(SbgStreamBuffer *pInputStream, SbgLogMag *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
uint32_t timeStamp
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35