148 size_t payloadSize = 0;
150 uint16_t computedCrc;
153 uint8_t receivedMsgClass;
155 size_t payloadOffset;
314 *pMsgClass = receivedMsgClass;
325 if (frameCrc == computedCrc)
335 if ( (pData) && (pSize) )
340 if (payloadSize <= maxSize)
345 *pSize = payloadSize;
463 assert(pOutputStream);
464 assert(pStreamCursor);
506 assert(pOutputStream);
569 SBG_LOG_ERROR(errorCode,
"Payload of %u bytes is too big for a valid sbgECom log", payloadSize);
577 SBG_LOG_ERROR(errorCode,
"Unable to finalize frame because of an error on Stream Buffer");
SbgInterface * pLinkedInterface
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
SbgErrorCode sbgEComProtocolReceive(SbgEComProtocol *pHandle, uint8_t *pMsgClass, uint8_t *pMsg, void *pData, size_t *pSize, size_t maxSize)
SBG_INLINE SbgErrorCode sbgStreamBufferSeek(SbgStreamBuffer *pHandle, size_t offset, SbgSBSeekOrigin origin)
SBG_INLINE uint8_t sbgStreamBufferReadUint8(SbgStreamBuffer *pHandle)
SBG_COMMON_LIB_API uint16_t sbgCrc16Compute(const void *pData, size_t dataSize)
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite(SbgStreamBuffer *pHandle, void *pLinkedBuffer, size_t bufferSize)
SbgErrorCode sbgEComProtocolInit(SbgEComProtocol *pHandle, SbgInterface *pInterface)
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComFinalizeFrameGeneration(SbgStreamBuffer *pOutputStream, size_t streamCursor)
uint8_t rxBuffer[SBG_ECOM_MAX_BUFFER_SIZE]
SBG_INLINE SbgErrorCode sbgInterfaceWrite(SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite)
#define sbgStreamBufferWriteUint8LE
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComStartFrameGeneration(SbgStreamBuffer *pOutputStream, uint8_t msgClass, uint8_t msg, size_t *pStreamCursor)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
SBG_INLINE size_t sbgStreamBufferTell(SbgStreamBuffer *pHandle)
#define sbgStreamBufferReadUint8LE
This file provides CRC-32 and CRC-16 methods.
#define SBG_LOG_ERROR(format,...)
SBG_INLINE SbgErrorCode sbgInterfaceRead(SbgInterface *pHandle, void *pBuffer, size_t *pReadBytes, size_t bytesToRead)
SBG_INLINE size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
SbgErrorCode sbgEComProtocolClose(SbgEComProtocol *pHandle)
Implementation of the Ekinox binary communication protocol. You can access low-level communication w...
SBG_INLINE void * sbgStreamBufferGetCursor(SbgStreamBuffer *pHandle)
#define SBG_ECOM_MAX_PAYLOAD_SIZE
enum _SbgErrorCode SbgErrorCode
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle)
#define SBG_ECOM_MAX_BUFFER_SIZE