sbgECom Library  4.0.1987-stable
C library to interface SBG Systems IMU/AHRS/INS
sbgECom.h File Reference

Contains main sbgECom methods. More...

#include <sbgCommon.h>
#include <interfaces/sbgInterface.h>
#include "sbgECanId.h"
#include "sbgEComIds.h"
#include "logs/sbgEComLog.h"
#include "protocol/sbgEComProtocol.h"

Go to the source code of this file.

Data Structures

struct  _SbgEComHandle
 

Typedefs

typedef struct _SbgEComHandle SbgEComHandle
 
typedef SbgErrorCode(* SbgEComReceiveLogFunc) (SbgEComHandle *pHandle, SbgEComClass msgClass, SbgEComMsgId msg, const SbgEComLogUnion *pLogData, void *pUserArg)
 

Functions

SbgErrorCode sbgEComInit (SbgEComHandle *pHandle, SbgInterface *pInterface)
 
SbgErrorCode sbgEComClose (SbgEComHandle *pHandle)
 
SbgErrorCode sbgEComHandleOneLog (SbgEComHandle *pHandle)
 
SbgErrorCode sbgEComHandle (SbgEComHandle *pHandle)
 
SbgErrorCode sbgEComPurgeIncoming (SbgEComHandle *pHandle)
 
void sbgEComSetReceiveLogCallback (SbgEComHandle *pHandle, SbgEComReceiveLogFunc pReceiveLogCallback, void *pUserArg)
 
void sbgEComSetCmdTrialsAndTimeOut (SbgEComHandle *pHandle, uint32_t numTrials, uint32_t cmdDefaultTimeOut)
 
void sbgEComErrorToString (SbgErrorCode errorCode, char errorMsg[256])
 

Detailed Description

Contains main sbgECom methods.

Author
SBG Systems
Date
05 February 2013
License

The MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Typedef Documentation

◆ SbgEComHandle

typedef struct _SbgEComHandle SbgEComHandle

Interface structure pre-definition.

◆ SbgEComReceiveLogFunc

typedef SbgErrorCode(* SbgEComReceiveLogFunc) (SbgEComHandle *pHandle, SbgEComClass msgClass, SbgEComMsgId msg, const SbgEComLogUnion *pLogData, void *pUserArg)

Callback definition called each time a new log is received.

Parameters
[in]pHandleValid handle on the sbgECom instance that has called this callback.
[in]msgClassClass of the message we have received
[in]msgMessage ID of the log received.
[in]pLogDataContains the received log data as an union.
[in]pUserArgOptional user supplied argument.
Returns
SBG_NO_ERROR if the received log has been used successfully.

Function Documentation

◆ sbgEComInit()

SbgErrorCode sbgEComInit ( SbgEComHandle pHandle,
SbgInterface pInterface 
)

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

Parameters
[out]pHandlePointer used to store the allocated and initialized sbgECom handle.
[in]pInterfaceInterface to use for read/write operations.
Returns
SBG_NO_ERROR if we have initialized the protocol system.

◆ sbgEComClose()

SbgErrorCode sbgEComClose ( SbgEComHandle pHandle)

Close the protocol system and release associated memory.

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

◆ sbgEComHandleOneLog()

SbgErrorCode sbgEComHandleOneLog ( SbgEComHandle pHandle)

Try to parse one log from the input interface and then return.

Parameters
[in]pHandleA valid sbgECom handle.
Returns
SBG_NO_ERROR if no error occurs during incoming log parsing.

◆ sbgEComHandle()

SbgErrorCode sbgEComHandle ( SbgEComHandle pHandle)

Handle all incoming logs until no more log are available in the input interface.

Parameters
[in]pHandleA valid sbgECom handle.
Returns
SBG_NO_ERROR if no error occurs during incoming logs parsing.

◆ sbgEComPurgeIncoming()

SbgErrorCode sbgEComPurgeIncoming ( SbgEComHandle pHandle)

Purge the interface rx buffer as well as the sbgECom rx work buffer.

For example, if the program flow has been interrupted, this method can be helpful to discard all trash received data.

WARNING: This method is blocking for 100ms and actively tries to read incoming data.

Parameters
[in]pHandleA valid sbgECom handle.
Returns
SBG_NO_ERROR if the incoming data has been purged successfully.

◆ sbgEComSetReceiveLogCallback()

void sbgEComSetReceiveLogCallback ( SbgEComHandle pHandle,
SbgEComReceiveLogFunc  pReceiveLogCallback,
void *  pUserArg 
)

Define the callback that should be called each time a new binary log is received.

Parameters
[in]pHandleA valid sbgECom handle.
[in]pReceiveLogCallbackPointer on the callback to call when a new log is received.
[in]pUserArgOptional user argument that will be passed to the callback method.

◆ sbgEComSetCmdTrialsAndTimeOut()

void sbgEComSetCmdTrialsAndTimeOut ( SbgEComHandle pHandle,
uint32_t  numTrials,
uint32_t  cmdDefaultTimeOut 
)

Define the default number of trials that should be done when a command is send to the device as well as the time out.

Parameters
[in]pHandleA valid sbgECom handle.
[in]numTrialsNumber of trials when a command is sent (starting at 1).
[in]cmdDefaultTimeOutDefault time out in milliseconds to wait to receive an answer from the device.

◆ sbgEComErrorToString()

void sbgEComErrorToString ( SbgErrorCode  errorCode,
char  errorMsg[256] 
)

Convert an error code into a human readable string.

Parameters
[in]errorCodeThe errorCode to convert into a string.
[out]errorMsgString buffer used to hold the error string.