sbgEComBinaryLogMag.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogMag.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 = sbgStreamBufferReadUint16LE(pInputStream);
26 
27  pOutputData->magnetometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
28  pOutputData->magnetometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
29  pOutputData->magnetometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
30 
31  pOutputData->accelerometers[0] = sbgStreamBufferReadFloatLE(pInputStream);
32  pOutputData->accelerometers[1] = sbgStreamBufferReadFloatLE(pInputStream);
33  pOutputData->accelerometers[2] = sbgStreamBufferReadFloatLE(pInputStream);
34 
35  //
36  // Return if any error has occurred while parsing the frame
37  //
38  return sbgStreamBufferGetLastError(pInputStream);
39 }
40 
48 {
49  //
50  // Check input arguments
51  //
52  SBG_ASSERT(pOutputStream);
53  SBG_ASSERT(pInputData);
54 
55  //
56  // Write the frame payload
57  //
58  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
59  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->status);
60 
61  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[0]);
62  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[1]);
63  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->magnetometers[2]);
64 
65  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[0]);
66  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[1]);
67  sbgStreamBufferWriteFloatLE(pOutputStream, pInputData->accelerometers[2]);
68 
69  //
70  // Return if any error has occurred while writing the frame
71  //
72  return sbgStreamBufferGetLastError(pOutputStream);
73 }
74 
82 {
83  //
84  // Check input arguments
85  //
86  SBG_ASSERT(pInputStream);
87  SBG_ASSERT(pOutputData);
88 
89  //
90  // Read the frame payload
91  //
92  pOutputData->timeStamp = sbgStreamBufferReadUint32LE(pInputStream);
93  pOutputData->reserved = sbgStreamBufferReadUint16LE(pInputStream);
94 
95  //
96  // Read the raw magnetic calibration data buffer
97  //
98  return sbgStreamBufferReadBuffer(pInputStream, pOutputData->magData, sizeof(pOutputData->magData));
99 }
100 
108 {
109  //
110  // Check input arguments
111  //
112  SBG_ASSERT(pOutputStream);
113  SBG_ASSERT(pInputData);
114 
115  //
116  // Write the frame payload
117  //
118  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->timeStamp);
119  sbgStreamBufferWriteUint16LE(pOutputStream, pInputData->reserved);
120 
121  //
122  // Write the raw magnetic calibration data buffer
123  //
124  return sbgStreamBufferWriteBuffer(pOutputStream, pInputData->magData, sizeof(pInputData->magData));
125 }
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)
SBG_INLINE uint16 sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
This file is used to parse received magnetometer binary logs.
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)
SBG_INLINE uint32 sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16 value)
SbgErrorCode sbgEComBinaryLogParseMagData(SbgStreamBuffer *pInputStream, SbgLogMag *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32 value)
#define SBG_ASSERT(expression)
Definition: sbgDebug.h:52
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


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