sbgEComBinaryLogDebug.c
Go to the documentation of this file.
2 
3 //----------------------------------------------------------------------//
4 //- Operations -//
5 //----------------------------------------------------------------------//
6 
14 {
15  SbgErrorCode errorCode;
16 
17  assert(pInputStream);
18  assert(pOutputData);
19 
20  //
21  // Read the frame payload and return
22  //
23  pOutputData->id = sbgStreamBufferReadUint32LE(pInputStream);
24  pOutputData->offset = sbgStreamBufferReadUint32LE(pInputStream);
25  pOutputData->size = sbgStreamBufferReadUint32LE(pInputStream);
26  pOutputData->totalSize = sbgStreamBufferReadUint32LE(pInputStream);
27 
28  errorCode = sbgStreamBufferGetLastError(pInputStream);
29 
30  if (errorCode == SBG_NO_ERROR)
31  {
32  if (pOutputData->size <= SBG_ARRAY_SIZE(pOutputData->data))
33  {
34  sbgStreamBufferReadBuffer(pInputStream, pOutputData->data, pOutputData->size);
35  errorCode = sbgStreamBufferGetLastError(pInputStream);
36  }
37  else
38  {
39  errorCode = SBG_BUFFER_OVERFLOW;
40  }
41  }
42 
43  return errorCode;
44 }
45 
53 {
54  SbgErrorCode errorCode;
55 
56  assert(pOutputStream);
57  assert(pInputData);
58 
59  //
60  // Write the frame payload
61  //
62  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->id);
63  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->offset);
64  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->size);
65  sbgStreamBufferWriteUint32LE(pOutputStream, pInputData->totalSize);
66 
67  if (pInputData->size <= SBG_ARRAY_SIZE(pInputData->data))
68  {
69  sbgStreamBufferWriteBuffer(pOutputStream, pInputData->data, pInputData->size);
70  errorCode = sbgStreamBufferGetLastError(pOutputStream);
71  }
72  else
73  {
74  errorCode = SBG_BUFFER_OVERFLOW;
75  }
76 
77  return errorCode;
78 }
This file is used to parse received debug frames.
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
uint8_t data[SBG_ECOM_MAX_PAYLOAD_SIZE - 16]
SbgErrorCode sbgEComBinaryLogParseDebugData(SbgStreamBuffer *pInputStream, SbgLogDebugData *pOutputData)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
#define SBG_ARRAY_SIZE(a)
Definition: sbgDefines.h:97
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32LE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComBinaryLogWriteDebugData(SbgStreamBuffer *pOutputStream, const SbgLogDebugData *pInputData)
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)


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