Files
ximeaAirborneSystem/Header_Files/sbgbuffer.h

98 lines
3.5 KiB
C++

#ifndef SBGBUFFER_H
#define SBGBUFFER_H
#include "sbgerrorcodes.h"
#include <QByteArray>
namespace sbgtc
{
#define SBG_ECOM_MAX_BUFFER_SIZE (4096) /*!< Maximum reception buffer size in bytes. */
#define SBG_ECOM_MAX_PAYLOAD_SIZE (4086) /*!< Maximum payload size in bytes. */
#define SBG_ECOM_SYNC_1 (0xFF) /*!< First synchronization char of the frame. */
#define SBG_ECOM_SYNC_2 (0x5A) /*!< Second synchronization char of the frame. */
#define SBG_ECOM_ETX (0x33) /*!< End of frame byte. */
/*!
* Windows x86 & x64 support both aligned and unaligned access
*/
#define SBG_CONFIG_UNALIGNED_ACCESS_AUTH (0)
/*!
* Windows is using little endianess
*/
#define SBG_CONFIG_BIG_ENDIAN (0)
/*!
* Union that allows type punning (access to a floating point number bits)
*/
typedef union _FloatNint
{
float valF;
int32_t valI;
uint32_t valU;
} FloatNint;
/*!
* Union that allows type punning (access to a double number bits)
*/
typedef union _DoubleNint
{
double valF;
uint64_t valU;
int64_t valI;
} DoubleNint;
typedef struct _rawBuffer
{
uint8_t * rxBuffer;
size_t rxBufferSize;
}rawBuffer;
typedef struct _SbgStreamBuffer
{
//SbgSBMode modes; /*!< Defines the stream buffer modes (read/write). */
size_t bufferSize; /*!< Size in bytes of the linked buffer. */
uint8_t *pBufferPtr; /*!< Pointer to the buffer linked with this stream. */
uint8_t *pCurrentPtr; /*!< Current pointer within the buffer. */
SbgErrorCode errorCode; /*!< Current error code on stream buffer. */
} SbgStreamBuffer;
typedef enum _SbgSBSeekOrigin
{
SB_SEEK_SET, /*!< The offset is referenced to the begining of the stream. */
SB_SEEK_CUR_INC, /*!< The offset is referenced to the current cursor position and increment the current cursor. */
SB_SEEK_CUR_DEC, /*!< The offset is referenced to the current cursor position and decrement the current cursor. */
SB_SEEK_END /*!< The offset is referenced to the end of the stream. */
} SbgSBSeekOrigin;
rawBuffer initRawBuffer(QByteArray * sbgMessage);
SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize);
SbgErrorCode sbgStreamBufferSeek(SbgStreamBuffer *pHandle, size_t offset, SbgSBSeekOrigin origin);
size_t sbgStreamBufferTell(SbgStreamBuffer *pHandle);
void *sbgStreamBufferGetCursor(SbgStreamBuffer *pHandle);
size_t sbgStreamBufferGetSize(SbgStreamBuffer *pHandle);
size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle);
size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle);
void *sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle);
uint8_t sbgStreamBufferReadUint8LE(SbgStreamBuffer *pHandle);
uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle);
uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle);
uint64_t sbgStreamBufferReadUint64LE(SbgStreamBuffer *pHandle);
int8_t sbgStreamBufferReadInt8LE(SbgStreamBuffer *pHandle);
int32_t sbgStreamBufferReadInt32LE(SbgStreamBuffer *pHandle);
float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle);
double sbgStreamBufferReadDoubleLE(SbgStreamBuffer *pHandle);
SbgErrorCode sbgStreamBufferGetLastError(SbgStreamBuffer *pHandle);
}
#endif // SBGBUFFER_H