Classes | Macros | Typedefs | Functions
sbgEComProtocol.h File Reference

Implementation of the Ekinox binary communication protocol.
You can access low-level communication with the device.
Copyright 2007-20011 SBG Systems. All rights reserved. More...

#include <sbgCommon.h>
#include <interfaces/sbgInterface.h>
#include <streamBuffer/sbgStreamBuffer.h>
Include dependency graph for sbgEComProtocol.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SbgEComProtocol
 

Macros

#define SBG_ECOM_ETX   (0x33)
 
#define SBG_ECOM_MAX_BUFFER_SIZE   (4096)
 
#define SBG_ECOM_MAX_PAYLOAD_SIZE   (4086)
 
#define SBG_ECOM_RX_TIME_OUT   (450)
 
#define SBG_ECOM_SYNC_1   (0xFF)
 
#define SBG_ECOM_SYNC_2   (0x5A)
 

Typedefs

typedef struct _SbgEComProtocol SbgEComProtocol
 

Functions

SbgErrorCode sbgEComFinalizeFrameGeneration (SbgStreamBuffer *pOutputStream, size_t streamCursor)
 
SbgErrorCode sbgEComProtocolClose (SbgEComProtocol *pHandle)
 
SbgErrorCode sbgEComProtocolInit (SbgEComProtocol *pHandle, SbgInterface *pInterface)
 
SbgErrorCode sbgEComProtocolReceive (SbgEComProtocol *pHandle, uint8_t *pMsgClass, uint8_t *pMsg, void *pData, size_t *pSize, size_t maxSize)
 
SbgErrorCode sbgEComProtocolSend (SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
 
SbgErrorCode sbgEComStartFrameGeneration (SbgStreamBuffer *pOutputStream, uint8_t msgClass, uint8_t msg, size_t *pStreamCursor)
 

Detailed Description

Implementation of the Ekinox binary communication protocol.
You can access low-level communication with the device.
Copyright 2007-20011 SBG Systems. All rights reserved.

Author
SBG-Systems (Raphael Siryani)
Date
06/02/13

You will find below, the frame definition used by Ekinox devices.

Frame structure
Fields SYNC 1 SYNC 2 CMD LEN DATA CRC ETX
Size in bytes 1 1 2 2 (0-4086) 2 1
Value 0xFF 0x5A ? ? ? ? 0x33


Size in bytes indicates the size of the data field.
The minimum frame size is 9 bytes and the maximum is 512 bytes.

The CRC is calculated on the whole frame without:
SYNC STX CRC and ETX fields.

Definition in file sbgEComProtocol.h.

Macro Definition Documentation

◆ SBG_ECOM_ETX

#define SBG_ECOM_ETX   (0x33)

End of frame byte.

Definition at line 39 of file sbgEComProtocol.h.

◆ SBG_ECOM_MAX_BUFFER_SIZE

#define SBG_ECOM_MAX_BUFFER_SIZE   (4096)

Maximum reception buffer size in bytes.

Definition at line 35 of file sbgEComProtocol.h.

◆ SBG_ECOM_MAX_PAYLOAD_SIZE

#define SBG_ECOM_MAX_PAYLOAD_SIZE   (4086)

Maximum payload size in bytes.

Definition at line 36 of file sbgEComProtocol.h.

◆ SBG_ECOM_RX_TIME_OUT

#define SBG_ECOM_RX_TIME_OUT   (450)

Default time out for new frame reception.

Definition at line 41 of file sbgEComProtocol.h.

◆ SBG_ECOM_SYNC_1

#define SBG_ECOM_SYNC_1   (0xFF)

First synchronization char of the frame.

Definition at line 37 of file sbgEComProtocol.h.

◆ SBG_ECOM_SYNC_2

#define SBG_ECOM_SYNC_2   (0x5A)

Second synchronization char of the frame.

Definition at line 38 of file sbgEComProtocol.h.

Typedef Documentation

◆ SbgEComProtocol

Struct containing all protocol related data.

Function Documentation

◆ sbgEComFinalizeFrameGeneration()

SbgErrorCode sbgEComFinalizeFrameGeneration ( SbgStreamBuffer pOutputStream,
size_t  streamCursor 
)

Finalize an output stream that has been initialized with sbgEComStartFrameGeneration. At return, the output stream buffer should point at the end of the generated message. You can thus easily create consecutive SBG_ECOM_LOGS with these methods.

Parameters
[in]pOutputStreamPointer to an allocated and initialized output stream.
[in]streamCursorPosition in the stream buffer of the generated message first byte. This value is returned by sbgEComStartFrameGeneration and is mandatory for correct operations.
Returns
SBG_NO_ERROR in case of good operation.

Definition at line 499 of file sbgEComProtocol.c.

◆ sbgEComProtocolClose()

SbgErrorCode sbgEComProtocolClose ( SbgEComProtocol pHandle)

Close the protocol system.

Parameters
[in]pHandleA valid protocol handle to close.
Returns
SBG_NO_ERROR if we have closed and released the protocol system.

Definition at line 35 of file sbgEComProtocol.c.

◆ sbgEComProtocolInit()

SbgErrorCode sbgEComProtocolInit ( SbgEComProtocol pHandle,
SbgInterface pInterface 
)

Initialize the protocol system used to communicate with the product and return the created handle.

Parameters
[in]pHandlePointer on an allocated protocol structure to initialize.
[in]pInterfaceInterface to use for read/write operations.
Returns
SBG_NO_ERROR if we have initialised the protocol system.

Definition at line 14 of file sbgEComProtocol.c.

◆ sbgEComProtocolReceive()

SbgErrorCode sbgEComProtocolReceive ( SbgEComProtocol pHandle,
uint8_t *  pMsgClass,
uint8_t *  pMsg,
void *  pData,
size_t *  pSize,
size_t  maxSize 
)

Try to receive a frame from the device and returns the cmd, data and size of data field.

Parameters
[in]pHandleA valid protocol handle.
[out]pMsgClassPointer to hold the returned message class
[out]pMsgPointer to hold the returned message id
[out]pDataAllocated buffer used to hold received data field.
[out]pSizePointer used to hold the received data field size.
[in]maxSizeMax number of bytes that can be stored in the pData buffer.
Returns
SBG_NO_ERROR if we have received a valid frame.
SBG_NOT_READY if we haven't received a valid frame or if the serial buffer is empty.
SBG_INVALID_CRC if the received frame has an invalid CRC.
SBG_NULL_POINTER if an input parameter is NULL.
SBG_BUFFER_OVERFLOW if the received frame payload couldn't fit into the pData buffer.

Definition at line 143 of file sbgEComProtocol.c.

◆ sbgEComProtocolSend()

SbgErrorCode sbgEComProtocolSend ( SbgEComProtocol pHandle,
uint8_t  msgClass,
uint8_t  msg,
const void *  pData,
size_t  size 
)

Send a frame to the device (size should be less than 4086 bytes).

Parameters
[in]pHandleA valid protocol handle.
[in]msgClassMessage class (0-255)
[in]msgMessage id (0-255)
[in]pDataPointer on the data payload to send or NULL if no payload.
[in]sizeSize in bytes of the data payload (less than 4086).
Returns
SBG_NO_ERROR if the frame has been sent.

Definition at line 60 of file sbgEComProtocol.c.

◆ sbgEComStartFrameGeneration()

SbgErrorCode sbgEComStartFrameGeneration ( SbgStreamBuffer pOutputStream,
uint8_t  msgClass,
uint8_t  msg,
size_t *  pStreamCursor 
)

Initialize an output stream for an sbgECom frame generation. This method is helpful to avoid memory copy compared to sbgEComProtocolSend one.

Parameters
[in]pOutputStreamPointer to an allocated and initialized output stream.
[in]msgClassMessage class (0-255)
[in]msgMessage id (0-255)
[out]pStreamCursorThe initial output stream cursor that thus points to the begining of the generated message. This value should be passed to sbgEComFinalizeFrameGeneration for correct operations.
Returns
SBG_NO_ERROR in case of good operation.

Definition at line 461 of file sbgEComProtocol.c.



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