sbgEComBinaryLogs.c
Go to the documentation of this file.
1 #include "sbgEComBinaryLogs.h"
3 
4 //----------------------------------------------------------------------//
5 //- Communication protocol operations -//
6 //----------------------------------------------------------------------//
7 
16 SbgErrorCode sbgEComBinaryLogParse(SbgEComClass msgClass, SbgEComMsgId msg, const void *pPayload, size_t payloadSize, SbgBinaryLogData *pOutputData)
17 {
18  SbgErrorCode errorCode = SBG_NO_ERROR;
19  SbgStreamBuffer inputStream;
20 
21  assert(pPayload);
22  assert(payloadSize > 0);
23  assert(pOutputData);
24 
25  //
26  // Handle the different classes of messages differently
27  //
28  if (msgClass == SBG_ECOM_CLASS_LOG_ECOM_0)
29  {
30  //
31  // Create an input stream buffer that points to the frame payload so we can easily parse it's content
32  //
33  sbgStreamBufferInitForRead(&inputStream, pPayload, payloadSize);
34 
35  //
36  // Parse the incoming log according to its type
37  //
38  switch (msg)
39  {
41  errorCode = sbgEComBinaryLogParseStatusData(&inputStream, &pOutputData->statusData);
42  break;
44  errorCode = sbgEComBinaryLogParseImuData(&inputStream, &pOutputData->imuData);
45  break;
47  errorCode = sbgEComBinaryLogParseImuShort(&inputStream, &pOutputData->imuShort);
48  break;
50  errorCode = sbgEComBinaryLogParseEkfEulerData(&inputStream, &pOutputData->ekfEulerData);
51  break;
53  errorCode = sbgEComBinaryLogParseEkfQuatData(&inputStream, &pOutputData->ekfQuatData);
54  break;
56  errorCode = sbgEComBinaryLogParseEkfNavData(&inputStream, &pOutputData->ekfNavData);
57  break;
60  errorCode = sbgEComBinaryLogParseShipMotionData(&inputStream, &pOutputData->shipMotionData);
61  break;
63  errorCode = sbgEComBinaryLogParseOdometerData(&inputStream, &pOutputData->odometerData);
64  break;
66  errorCode = sbgEComBinaryLogParseUtcData(&inputStream, &pOutputData->utcData);
67  break;
70  errorCode = sbgEComBinaryLogParseGpsVelData(&inputStream, &pOutputData->gpsVelData);
71  break;
74  errorCode = sbgEComBinaryLogParseGpsPosData(&inputStream, &pOutputData->gpsPosData);
75  break;
78  errorCode = sbgEComBinaryLogParseGpsHdtData(&inputStream, &pOutputData->gpsHdtData);
79  break;
82  errorCode = sbgEComBinaryLogParseGpsRawData(&inputStream, &pOutputData->gpsRawData);
83  break;
84  case SBG_ECOM_LOG_MAG:
85  errorCode = sbgEComBinaryLogParseMagData(&inputStream, &pOutputData->magData);
86  break;
88  errorCode = sbgEComBinaryLogParseMagCalibData(&inputStream, &pOutputData->magCalibData);
89  break;
91  errorCode = sbgEComBinaryLogParseDvlData(&inputStream, &pOutputData->dvlData);
92  break;
94  errorCode = sbgEComBinaryLogParseDvlData(&inputStream, &pOutputData->dvlData);
95  break;
97  errorCode = sbgEComBinaryLogParseAirData(&inputStream, &pOutputData->airData);
98  break;
99  case SBG_ECOM_LOG_USBL:
100  errorCode = sbgEComBinaryLogParseUsblData(&inputStream, &pOutputData->usblData);
101  break;
102  case SBG_ECOM_LOG_DEPTH:
103  errorCode = sbgEComBinaryLogParseDepth(&inputStream, &pOutputData->depthData);
104  break;
112  errorCode = sbgEComBinaryLogParseEvent(&inputStream, &pOutputData->eventMarker);
113  break;
118  errorCode = sbgEComBinaryLogParseDebugData(&inputStream, &pOutputData->debugData);
119  break;
121  errorCode = sbgEComBinaryLogParseImuRawData(&inputStream, &pOutputData->imuRawData);
122  break;
123  case SBG_ECOM_LOG_DIAG:
124  errorCode = sbgEComBinaryLogParseDiagData(&inputStream, &pOutputData->diagData);
125  break;
126  default:
127  //
128  // This log isn't handled
129  //
130  errorCode = SBG_ERROR;
131  }
132  }
133  else if (msgClass == SBG_ECOM_CLASS_LOG_ECOM_1)
134  {
135  //
136  // Create an input stream buffer that points to the frame payload so we can easily parse it's content
137  //
138  sbgStreamBufferInitForRead(&inputStream, pPayload, payloadSize);
139 
140  //
141  // Parse the message depending on the message ID
142  //
143  switch ((SbgEComLog1)msg)
144  {
146  //
147  // Parse this binary log
148  //
149  errorCode = sbgEComBinaryLogParseFastImuData(&inputStream, &pOutputData->fastImuData);
150  break;
151  default:
152  //
153  // This log isn't handled
154  //
155  errorCode = SBG_ERROR;
156  }
157  }
158  else
159  {
160  //
161  // Un-handled message class
162  //
163  errorCode = SBG_ERROR;
164  }
165 
166  return errorCode;
167 }
SBG_ECOM_LOG_EVENT_OUT_A
@ SBG_ECOM_LOG_EVENT_OUT_A
Definition: sbgEComIds.h:121
_SbgBinaryLogData::gpsHdtData
SbgLogGpsHdt gpsHdtData
Definition: sbgEComBinaryLogs.h:62
_SbgBinaryLogData::shipMotionData
SbgLogShipMotionData shipMotionData
Definition: sbgEComBinaryLogs.h:57
SBG_ECOM_LOG_UTC_TIME
@ SBG_ECOM_LOG_UTC_TIME
Definition: sbgEComIds.h:73
SBG_ECOM_LOG_GPS1_RAW
@ SBG_ECOM_LOG_GPS1_RAW
Definition: sbgEComIds.h:89
SBG_ECOM_LOG_GPS1_POS
@ SBG_ECOM_LOG_GPS1_POS
Definition: sbgEComIds.h:87
SBG_ECOM_LOG_DEPTH
@ SBG_ECOM_LOG_DEPTH
Definition: sbgEComIds.h:124
sbgEComBinaryLogParseMagCalibData
SbgErrorCode sbgEComBinaryLogParseMagCalibData(SbgStreamBuffer *pInputStream, SbgLogMagCalib *pOutputData)
Definition: sbgEComBinaryLogMag.c:75
sbgEComBinaryLogParseAirData
SbgErrorCode sbgEComBinaryLogParseAirData(SbgStreamBuffer *pInputStream, SbgLogAirData *pOutputData)
Definition: sbgEComBinaryLogAirData.c:7
sbgEComBinaryLogParseEvent
SbgErrorCode sbgEComBinaryLogParseEvent(SbgStreamBuffer *pInputStream, SbgLogEvent *pOutputData)
Definition: sbgEComBinaryLogEvent.c:13
sbgEComBinaryLogParseGpsHdtData
SbgErrorCode sbgEComBinaryLogParseGpsHdtData(SbgStreamBuffer *pInputStream, SbgLogGpsHdt *pOutputData)
Definition: sbgEComBinaryLogGps.c:170
SBG_ECOM_LOG_EVENT_C
@ SBG_ECOM_LOG_EVENT_C
Definition: sbgEComIds.h:100
SBG_ECOM_LOG_GPS1_HDT
@ SBG_ECOM_LOG_GPS1_HDT
Definition: sbgEComIds.h:88
sbgEComBinaryLogParseImuRawData
SbgErrorCode sbgEComBinaryLogParseImuRawData(SbgStreamBuffer *pInputStream, SbgLogImuRawData *pOutputData)
Definition: sbgEComBinaryLogImuRaw.c:13
_SbgBinaryLogData::depthData
SbgLogDepth depthData
Definition: sbgEComBinaryLogs.h:69
sbgEComBinaryLogParseMagData
SbgErrorCode sbgEComBinaryLogParseMagData(SbgStreamBuffer *pInputStream, SbgLogMag *pOutputData)
Definition: sbgEComBinaryLogMag.c:13
sbgEComBinaryLogParseOdometerData
SbgErrorCode sbgEComBinaryLogParseOdometerData(SbgStreamBuffer *pInputStream, SbgLogOdometerData *pOutputData)
Definition: sbgEComBinaryLogOdometer.c:13
sbgEComBinaryLogParseImuData
SbgErrorCode sbgEComBinaryLogParseImuData(SbgStreamBuffer *pInputStream, SbgLogImuData *pOutputData)
Definition: sbgEComBinaryLogImu.c:57
SBG_ECOM_LOG_DEBUG_3
@ SBG_ECOM_LOG_DEBUG_3
Definition: sbgEComIds.h:117
SBG_ECOM_LOG_DEBUG_0
@ SBG_ECOM_LOG_DEBUG_0
Definition: sbgEComIds.h:113
SBG_ECOM_LOG_GPS1_VEL
@ SBG_ECOM_LOG_GPS1_VEL
Definition: sbgEComIds.h:86
SBG_ECOM_LOG_EKF_NAV
@ SBG_ECOM_LOG_EKF_NAV
Definition: sbgEComIds.h:82
sbgEComBinaryLogParseFastImuData
SbgErrorCode sbgEComBinaryLogParseFastImuData(SbgStreamBuffer *pInputStream, SbgLogFastImuData *pOutputData)
Definition: sbgEComBinaryLogImu.c:205
SBG_ECOM_LOG_AIR_DATA
@ SBG_ECOM_LOG_AIR_DATA
Definition: sbgEComIds.h:109
_SbgBinaryLogData::ekfEulerData
SbgLogEkfEulerData ekfEulerData
Definition: sbgEComBinaryLogs.h:54
sbgEComBinaryLogParseShipMotionData
SbgErrorCode sbgEComBinaryLogParseShipMotionData(SbgStreamBuffer *pInputStream, SbgLogShipMotionData *pOutputData)
Definition: sbgEComBinaryLogShipMotion.c:13
sbgEComBinaryLogParseDvlData
SbgErrorCode sbgEComBinaryLogParseDvlData(SbgStreamBuffer *pInputStream, SbgLogDvlData *pOutputData)
Definition: sbgEComBinaryLogDvl.c:13
SBG_ECOM_LOG_EVENT_E
@ SBG_ECOM_LOG_EVENT_E
Definition: sbgEComIds.h:102
sbgEComBinaryLogParseEkfNavData
SbgErrorCode sbgEComBinaryLogParseEkfNavData(SbgStreamBuffer *pInputStream, SbgLogEkfNavData *pOutputData)
Definition: sbgEComBinaryLogEkf.c:143
SBG_ECOM_CLASS_LOG_ECOM_1
@ SBG_ECOM_CLASS_LOG_ECOM_1
Definition: sbgEComIds.h:50
sbgEComBinaryLogParseDebugData
SbgErrorCode sbgEComBinaryLogParseDebugData(SbgStreamBuffer *pInputStream, SbgLogDebugData *pOutputData)
Definition: sbgEComBinaryLogDebug.c:13
sbgEComBinaryLogs.h
_SbgBinaryLogData::odometerData
SbgLogOdometerData odometerData
Definition: sbgEComBinaryLogs.h:58
_SbgBinaryLogData::magCalibData
SbgLogMagCalib magCalibData
Definition: sbgEComBinaryLogs.h:65
sbgEComBinaryLogParse
SbgErrorCode sbgEComBinaryLogParse(SbgEComClass msgClass, SbgEComMsgId msg, const void *pPayload, size_t payloadSize, SbgBinaryLogData *pOutputData)
Definition: sbgEComBinaryLogs.c:16
_SbgBinaryLogData::magData
SbgLogMag magData
Definition: sbgEComBinaryLogs.h:64
_SbgBinaryLogData::diagData
SbgLogDiagData diagData
Definition: sbgEComBinaryLogs.h:74
SBG_ECOM_LOG_SHIP_MOTION
@ SBG_ECOM_LOG_SHIP_MOTION
Definition: sbgEComIds.h:84
SBG_ECOM_LOG_EKF_EULER
@ SBG_ECOM_LOG_EKF_EULER
Definition: sbgEComIds.h:80
SBG_ECOM_LOG_DVL_WATER_TRACK
@ SBG_ECOM_LOG_DVL_WATER_TRACK
Definition: sbgEComIds.h:105
sbgEComBinaryLogParseUtcData
SbgErrorCode sbgEComBinaryLogParseUtcData(SbgStreamBuffer *pInputStream, SbgLogUtcData *pOutputData)
Definition: sbgEComBinaryLogUtc.c:13
SbgEComClass
enum _SbgEComClass SbgEComClass
sbgEComBinaryLogParseUsblData
SbgErrorCode sbgEComBinaryLogParseUsblData(SbgStreamBuffer *pInputStream, SbgLogUsblData *pOutputData)
Definition: sbgEComBinaryLogUsbl.c:13
_SbgBinaryLogData::ekfQuatData
SbgLogEkfQuatData ekfQuatData
Definition: sbgEComBinaryLogs.h:55
_SbgBinaryLogData::imuShort
SbgLogImuShort imuShort
Definition: sbgEComBinaryLogs.h:53
SBG_ECOM_CLASS_LOG_ECOM_0
@ SBG_ECOM_CLASS_LOG_ECOM_0
Definition: sbgEComIds.h:48
sbgEComBinaryLogParseGpsRawData
SbgErrorCode sbgEComBinaryLogParseGpsRawData(SbgStreamBuffer *pInputStream, SbgLogGpsRaw *pOutputData)
Definition: sbgEComBinaryLogGps.c:239
SBG_ECOM_LOG_FAST_IMU_DATA
@ SBG_ECOM_LOG_FAST_IMU_DATA
Definition: sbgEComIds.h:135
SBG_ERROR
@ SBG_ERROR
Definition: sbgErrorCodes.h:36
_SbgBinaryLogData
This file is used to parse received binary logs.
Definition: sbgEComBinaryLogs.h:49
_SbgBinaryLogData::ekfNavData
SbgLogEkfNavData ekfNavData
Definition: sbgEComBinaryLogs.h:56
SBG_ECOM_LOG_DEBUG_2
@ SBG_ECOM_LOG_DEBUG_2
Definition: sbgEComIds.h:116
SBG_ECOM_LOG_EVENT_OUT_B
@ SBG_ECOM_LOG_EVENT_OUT_B
Definition: sbgEComIds.h:122
SBG_ECOM_LOG_IMU_RAW_DATA
@ SBG_ECOM_LOG_IMU_RAW_DATA
Definition: sbgEComIds.h:114
_SbgBinaryLogData::usblData
SbgLogUsblData usblData
Definition: sbgEComBinaryLogs.h:68
_SbgBinaryLogData::gpsVelData
SbgLogGpsVel gpsVelData
Definition: sbgEComBinaryLogs.h:61
SBG_ECOM_LOG_SHIP_MOTION_HP
@ SBG_ECOM_LOG_SHIP_MOTION_HP
Definition: sbgEComIds.h:107
sbgEComBinaryLogParseStatusData
SbgErrorCode sbgEComBinaryLogParseStatusData(SbgStreamBuffer *pInputStream, SbgLogStatusData *pOutputData)
Definition: sbgEComBinaryLogStatus.c:13
SBG_ECOM_LOG_EVENT_A
@ SBG_ECOM_LOG_EVENT_A
Definition: sbgEComIds.h:98
sbgEComBinaryLogParseEkfQuatData
SbgErrorCode sbgEComBinaryLogParseEkfQuatData(SbgStreamBuffer *pInputStream, SbgLogEkfQuatData *pOutputData)
Definition: sbgEComBinaryLogEkf.c:77
SBG_ECOM_LOG_MAG
@ SBG_ECOM_LOG_MAG
Definition: sbgEComIds.h:77
_SbgBinaryLogData::fastImuData
SbgLogFastImuData fastImuData
Definition: sbgEComBinaryLogs.h:73
SBG_ECOM_LOG_DIAG
@ SBG_ECOM_LOG_DIAG
Definition: sbgEComIds.h:125
SBG_ECOM_LOG_GPS2_HDT
@ SBG_ECOM_LOG_GPS2_HDT
Definition: sbgEComIds.h:93
_SbgBinaryLogData::utcData
SbgLogUtcData utcData
Definition: sbgEComBinaryLogs.h:59
_SbgBinaryLogData::imuData
SbgLogImuData imuData
Definition: sbgEComBinaryLogs.h:52
_SbgBinaryLogData::dvlData
SbgLogDvlData dvlData
Definition: sbgEComBinaryLogs.h:66
SBG_ECOM_LOG_EVENT_D
@ SBG_ECOM_LOG_EVENT_D
Definition: sbgEComIds.h:101
SBG_ECOM_LOG_EVENT_B
@ SBG_ECOM_LOG_EVENT_B
Definition: sbgEComIds.h:99
sbgEComBinaryLogParseEkfEulerData
SbgErrorCode sbgEComBinaryLogParseEkfEulerData(SbgStreamBuffer *pInputStream, SbgLogEkfEulerData *pOutputData)
Definition: sbgEComBinaryLogEkf.c:13
_SbgBinaryLogData::imuRawData
SbgLogImuRawData imuRawData
Definition: sbgEComBinaryLogs.h:72
SBG_ECOM_LOG_MAG_CALIB
@ SBG_ECOM_LOG_MAG_CALIB
Definition: sbgEComIds.h:78
_SbgBinaryLogData::airData
SbgLogAirData airData
Definition: sbgEComBinaryLogs.h:67
SBG_ECOM_LOG_IMU_DATA
@ SBG_ECOM_LOG_IMU_DATA
Definition: sbgEComIds.h:75
SBG_ECOM_LOG_GPS2_RAW
@ SBG_ECOM_LOG_GPS2_RAW
Definition: sbgEComIds.h:94
_SbgStreamBuffer
Definition: sbgStreamBufferCommon.h:188
_SbgBinaryLogData::gpsRawData
SbgLogGpsRaw gpsRawData
Definition: sbgEComBinaryLogs.h:63
SBG_NO_ERROR
@ SBG_NO_ERROR
Definition: sbgErrorCodes.h:35
SBG_ECOM_LOG_EKF_QUAT
@ SBG_ECOM_LOG_EKF_QUAT
Definition: sbgEComIds.h:81
SBG_ECOM_LOG_STATUS
@ SBG_ECOM_LOG_STATUS
Definition: sbgEComIds.h:71
SBG_ECOM_LOG_USBL
@ SBG_ECOM_LOG_USBL
Definition: sbgEComIds.h:111
sbgStreamBuffer.h
SBG_ECOM_LOG_GPS2_POS
@ SBG_ECOM_LOG_GPS2_POS
Definition: sbgEComIds.h:92
SBG_ECOM_LOG_ODO_VEL
@ SBG_ECOM_LOG_ODO_VEL
Definition: sbgEComIds.h:96
_SbgBinaryLogData::statusData
SbgLogStatusData statusData
Definition: sbgEComBinaryLogs.h:51
SbgEComMsgId
uint8_t SbgEComMsgId
Definition: sbgEComIds.h:289
sbgEComBinaryLogParseGpsVelData
SbgErrorCode sbgEComBinaryLogParseGpsVelData(SbgStreamBuffer *pInputStream, SbgLogGpsVel *pOutputData)
Definition: sbgEComBinaryLogGps.c:13
sbgEComBinaryLogParseGpsPosData
SbgErrorCode sbgEComBinaryLogParseGpsPosData(SbgStreamBuffer *pInputStream, SbgLogGpsPos *pOutputData)
Definition: sbgEComBinaryLogGps.c:76
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
_SbgBinaryLogData::eventMarker
SbgLogEvent eventMarker
Definition: sbgEComBinaryLogs.h:70
_SbgBinaryLogData::gpsPosData
SbgLogGpsPos gpsPosData
Definition: sbgEComBinaryLogs.h:60
SBG_ECOM_LOG_GPS2_VEL
@ SBG_ECOM_LOG_GPS2_VEL
Definition: sbgEComIds.h:91
_SbgBinaryLogData::debugData
SbgLogDebugData debugData
Definition: sbgEComBinaryLogs.h:71
sbgEComBinaryLogParseDiagData
SbgErrorCode sbgEComBinaryLogParseDiagData(SbgStreamBuffer *pInputStream, SbgLogDiagData *pOutputData)
Definition: sbgEComBinaryLogDiag.c:12
sbgStreamBufferInitForRead
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
Definition: sbgStreamBufferCommon.h:242
SbgEComLog1
enum _SbgEComLog1MsgId SbgEComLog1
SBG_ECOM_LOG_DVL_BOTTOM_TRACK
@ SBG_ECOM_LOG_DVL_BOTTOM_TRACK
Definition: sbgEComIds.h:104
sbgEComBinaryLogParseImuShort
SbgErrorCode sbgEComBinaryLogParseImuShort(SbgStreamBuffer *pInputStream, SbgLogImuShort *pOutputData)
Definition: sbgEComBinaryLogImu.c:139
SBG_ECOM_LOG_DEBUG_1
@ SBG_ECOM_LOG_DEBUG_1
Definition: sbgEComIds.h:115
sbgEComBinaryLogParseDepth
SbgErrorCode sbgEComBinaryLogParseDepth(SbgStreamBuffer *pInputStream, SbgLogDepth *pOutputData)
Definition: sbgEComBinaryLogDepth.c:7
SBG_ECOM_LOG_IMU_SHORT
@ SBG_ECOM_LOG_IMU_SHORT
Definition: sbgEComIds.h:119


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