sbgECom  1.11.920-stable
sbgEComProtocol.h
Go to the documentation of this file.
1 
25 #ifndef __SBG_ECOM_PROTOCOL_H__
26 #define __SBG_ECOM_PROTOCOL_H__
27 
28 #include <sbgCommon.h>
29 #include <interfaces/sbgInterface.h>
30 #include <streamBuffer/sbgStreamBuffer.h>
31 
32 //----------------------------------------------------------------------//
33 //- Global definitions -//
34 //----------------------------------------------------------------------//
35 #define SBG_ECOM_MAX_BUFFER_SIZE (4096)
36 #define SBG_ECOM_MAX_PAYLOAD_SIZE (4086)
37 #define SBG_ECOM_SYNC_1 (0xFF)
38 #define SBG_ECOM_SYNC_2 (0x5A)
39 #define SBG_ECOM_ETX (0x33)
41 #define SBG_ECOM_RX_TIME_OUT (450)
43 //----------------------------------------------------------------------//
44 //- Communication protocol structs and definitions -//
45 //----------------------------------------------------------------------//
46 
50 typedef struct _SbgEComProtocol
51 {
52  SbgInterface *pLinkedInterface;
54  size_t rxBufferSize;
56 
57 //----------------------------------------------------------------------//
58 //- Communication protocol operations -//
59 //----------------------------------------------------------------------//
60 
67 SbgErrorCode sbgEComProtocolInit(SbgEComProtocol *pHandle, SbgInterface *pInterface);
68 
74 SbgErrorCode sbgEComProtocolClose(SbgEComProtocol *pHandle);
75 
85 SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size);
86 
101 SbgErrorCode sbgEComProtocolReceive(SbgEComProtocol *pHandle, uint8_t *pMsgClass, uint8_t *pMsg, void *pData, size_t *pSize, size_t maxSize);
102 
103 //----------------------------------------------------------------------//
104 //- Frame generation to stream buffer -//
105 //----------------------------------------------------------------------//
106 
118 SbgErrorCode sbgEComStartFrameGeneration(SbgStreamBuffer *pOutputStream, uint8_t msgClass, uint8_t msg, size_t *pStreamCursor);
119 
130 SbgErrorCode sbgEComFinalizeFrameGeneration(SbgStreamBuffer *pOutputStream, size_t streamCursor);
131 
132 #endif
Definition: sbgEComProtocol.h:50
#define SBG_ECOM_MAX_BUFFER_SIZE
Definition: sbgEComProtocol.h:35
SbgErrorCode sbgEComStartFrameGeneration(SbgStreamBuffer *pOutputStream, uint8_t msgClass, uint8_t msg, size_t *pStreamCursor)
uint8_t rxBuffer[SBG_ECOM_MAX_BUFFER_SIZE]
Definition: sbgEComProtocol.h:53
SbgErrorCode sbgEComProtocolClose(SbgEComProtocol *pHandle)
SbgErrorCode sbgEComFinalizeFrameGeneration(SbgStreamBuffer *pOutputStream, size_t streamCursor)
SbgErrorCode sbgEComProtocolReceive(SbgEComProtocol *pHandle, uint8_t *pMsgClass, uint8_t *pMsg, void *pData, size_t *pSize, size_t maxSize)
size_t rxBufferSize
Definition: sbgEComProtocol.h:54
SbgErrorCode sbgEComProtocolInit(SbgEComProtocol *pHandle, SbgInterface *pInterface)
SbgInterface * pLinkedInterface
Definition: sbgEComProtocol.h:52
struct _SbgEComProtocol SbgEComProtocol
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)