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>
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) |
SbgErrorCode | sbgEComProtocolClose (SbgEComProtocol *pHandle) |
SbgErrorCode | sbgEComProtocolInit (SbgEComProtocol *pHandle, SbgInterface *pInterface) |
SbgErrorCode | sbgEComProtocolReceive (SbgEComProtocol *pHandle, uint8 *pMsgClass, uint8 *pMsg, void *pData, size_t *pSize, size_t maxSize) |
SbgErrorCode | sbgEComProtocolSend (SbgEComProtocol *pHandle, uint8 msgClass, uint8 msg, const void *pData, size_t size) |
SbgErrorCode | sbgEComStartFrameGeneration (SbgStreamBuffer *pOutputStream, uint8 msgClass, uint8 msg) |
Implementation of the Ekinox binary communication protocol.
You can access low-level communication with the device.
Copyright 2007-20011 SBG Systems. All rights reserved.
You will find below, the frame definition used by Ekinox devices.
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.
#define SBG_ECOM_ETX (0x33) |
End of frame byte.
Definition at line 39 of file sbgEComProtocol.h.
#define SBG_ECOM_MAX_BUFFER_SIZE (4096) |
Maximum reception buffer size in bytes.
Definition at line 35 of file sbgEComProtocol.h.
#define SBG_ECOM_MAX_PAYLOAD_SIZE (4086) |
Maximum payload size in bytes.
Definition at line 36 of file sbgEComProtocol.h.
#define SBG_ECOM_RX_TIME_OUT (450) |
Default time out for new frame reception.
Definition at line 41 of file sbgEComProtocol.h.
#define SBG_ECOM_SYNC_1 (0xFF) |
First synchronization char of the frame.
Definition at line 37 of file sbgEComProtocol.h.
#define SBG_ECOM_SYNC_2 (0x5A) |
Second synchronization char of the frame.
Definition at line 38 of file sbgEComProtocol.h.
typedef struct _SbgEComProtocol SbgEComProtocol |
Struct containing all protocol related data.
SbgErrorCode sbgEComFinalizeFrameGeneration | ( | SbgStreamBuffer * | pOutputStream | ) |
Finalize an output stream that has been initialized with sbgEComStartFrameGeneration.
[in] | pOutputStream | Pointer to an allocated and initialized output stream. |
Definition at line 507 of file sbgEComProtocol.c.
SbgErrorCode sbgEComProtocolClose | ( | SbgEComProtocol * | pHandle | ) |
Close the protocol system.
[in] | pHandle | A valid protocol handle to close. |
Definition at line 38 of file sbgEComProtocol.c.
SbgErrorCode sbgEComProtocolInit | ( | SbgEComProtocol * | pHandle, |
SbgInterface * | pInterface | ||
) |
Initialize the protocol system used to communicate with the product and return the created handle.
[in] | pHandle | Pointer on an allocated protocol structure to initialize. |
[in] | pInterface | Interface to use for read/write operations. |
Definition at line 14 of file sbgEComProtocol.c.
SbgErrorCode sbgEComProtocolReceive | ( | SbgEComProtocol * | pHandle, |
uint8 * | pMsgClass, | ||
uint8 * | 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.
[in] | pHandle | A valid protocol handle. |
[out] | pMsgClass | Pointer to hold the returned message class |
[out] | pMsg | Pointer to hold the returned message id |
[out] | pData | Allocated buffer used to hold received data field. |
[out] | pSize | Pointer used to hold the received data field size. |
[in] | maxSize | Max number of bytes that can be stored in the pData buffer. |
Definition at line 152 of file sbgEComProtocol.c.
SbgErrorCode sbgEComProtocolSend | ( | SbgEComProtocol * | pHandle, |
uint8 | msgClass, | ||
uint8 | msg, | ||
const void * | pData, | ||
size_t | size | ||
) |
Send a frame to the device (size should be less than 4086 bytes).
[in] | pHandle | A valid protocol handle. |
[in] | msgClass | Message class (0-255) |
[in] | msg | Message id (0-255) |
[in] | pData | Pointer on the data payload to send or NULL if no payload. |
[in] | size | Size in bytes of the data payload (less than 4086). |
Definition at line 66 of file sbgEComProtocol.c.
SbgErrorCode sbgEComStartFrameGeneration | ( | SbgStreamBuffer * | pOutputStream, |
uint8 | msgClass, | ||
uint8 | msg | ||
) |
Initialize an output stream for an sbgECom frame generation. This method is helpful to avoid memory copy compared to sbgEComProtocolSend one.
Warning, the stream will be seek to the beginning!
[in] | pOutputStream | Pointer to an allocated and initialized output stream. |
[in] | msgClass | Message class (0-255) |
[in] | msg | Message id (0-255) |
Definition at line 472 of file sbgEComProtocol.c.