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

Definitions and methods common to all commands. More...

#include <sbgCommon.h>
#include <sbgECom.h>

Go to the source code of this file.

Macros

#define SBG_ECOM_DEFAULT_CMD_TIME_OUT   (500)
 

Typedefs

typedef enum _SbgEComRejectionMode SbgEComRejectionMode
 
typedef enum _SbgEComAxisDirection SbgEComAxisDirection
 

Enumerations

enum  _SbgEComRejectionMode {
  SBG_ECOM_NEVER_ACCEPT_MODE = 0 ,
  SBG_ECOM_AUTOMATIC_MODE = 1 ,
  SBG_ECOM_ALWAYS_ACCEPT_MODE = 2
}
 
enum  _SbgEComAxisDirection {
  SBG_ECOM_ALIGNMENT_FORWARD = 0 ,
  SBG_ECOM_ALIGNMENT_BACKWARD = 1 ,
  SBG_ECOM_ALIGNMENT_LEFT = 2 ,
  SBG_ECOM_ALIGNMENT_RIGHT = 3 ,
  SBG_ECOM_ALIGNMENT_UP = 4 ,
  SBG_ECOM_ALIGNMENT_DOWN = 5
}
 

Functions

SbgErrorCode sbgEComReceiveAnyCmd (SbgEComHandle *pHandle, uint8_t *pMsgClass, uint8_t *pMsgId, void *pData, size_t *pSize, size_t maxSize, uint32_t timeOut)
 
SbgErrorCode sbgEComReceiveAnyCmd2 (SbgEComHandle *pHandle, uint8_t *pMsgClass, uint8_t *pMsgId, SbgEComProtocolPayload *pPayload, uint32_t timeOut)
 
SbgErrorCode sbgEComReceiveCmd (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msgId, void *pData, size_t *pSize, size_t maxSize, uint32_t timeOut)
 
SbgErrorCode sbgEComReceiveCmd2 (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msgId, SbgEComProtocolPayload *pPayload, uint32_t timeOut)
 
SbgErrorCode sbgEComWaitForAck (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t timeOut)
 
SbgErrorCode sbgEComSendAck (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, SbgErrorCode cmdError)
 
SbgErrorCode sbgEComCmdGenericSetModelId (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t modelId)
 
SbgErrorCode sbgEComCmdGenericGetModelId (SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t *pModelId)
 

Detailed Description

Definitions and methods common to all commands.

Author
SBG Systems
Date
11 June 2014
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.

Macro Definition Documentation

◆ SBG_ECOM_DEFAULT_CMD_TIME_OUT

#define SBG_ECOM_DEFAULT_CMD_TIME_OUT   (500)

Default time out in ms for commands reception.

Typedef Documentation

◆ SbgEComRejectionMode

List of all rejection modes for aiding inputs.

◆ SbgEComAxisDirection

List of all axis directions for modules/sensor alignment.

Enumeration Type Documentation

◆ _SbgEComRejectionMode

List of all rejection modes for aiding inputs.

Enumerator
SBG_ECOM_NEVER_ACCEPT_MODE 

Measurement is not taken into account.

SBG_ECOM_AUTOMATIC_MODE 

Measurement is accepted and rejected automatically depending on consistency checks

SBG_ECOM_ALWAYS_ACCEPT_MODE 

Measurement is always accepted. Should be used with caution

◆ _SbgEComAxisDirection

List of all axis directions for modules/sensor alignment.

Enumerator
SBG_ECOM_ALIGNMENT_FORWARD 

IMU/module Axis is turned in vehicle's forward direction.

SBG_ECOM_ALIGNMENT_BACKWARD 

IMU/module Axis is turned in vehicle's backward direction.

SBG_ECOM_ALIGNMENT_LEFT 

IMU/module Axis is turned in vehicle's left direction.

SBG_ECOM_ALIGNMENT_RIGHT 

IMU/module Axis is turned in vehicle's right direction.

SBG_ECOM_ALIGNMENT_UP 

IMU/module Axis is turned in vehicle's up direction.

SBG_ECOM_ALIGNMENT_DOWN 

IMU/module Axis is turned in vehicle's down direction.

Function Documentation

◆ sbgEComReceiveAnyCmd()

SbgErrorCode sbgEComReceiveAnyCmd ( SbgEComHandle pHandle,
uint8_t *  pMsgClass,
uint8_t *  pMsgId,
void *  pData,
size_t *  pSize,
size_t  maxSize,
uint32_t  timeOut 
)

Receive a command message.

All binary logs received are handled trough the standard callback system.

Parameters
[in]pHandleSbgECom handle.
[out]pMsgClassMessage class.
[out]pMsgIdMessage ID.
[out]pDataData buffer, may be NULL.
[out]pSizeNumber of bytes received, in bytes, may be NULL.
[in]maxSizeData buffer size, in bytes.
[in]timeOutTime-out, in ms.
Returns
SBG_NO_ERROR if successful, SBG_TIME_OUT if no command message was received within the specified time out (even if timeOut = 0). SBG_NOT_READY to indicate the underlying interface is empty (only applicable when timeOut = 0). SBG_BUFFER_OVERFLOW if the payload of the received frame couldn't fit into the buffer,

◆ sbgEComReceiveAnyCmd2()

SbgErrorCode sbgEComReceiveAnyCmd2 ( SbgEComHandle pHandle,
uint8_t *  pMsgClass,
uint8_t *  pMsgId,
SbgEComProtocolPayload pPayload,
uint32_t  timeOut 
)

Receive a command message.

All binary logs received are handled trough the standard callback system.

This function is equivalent to sbgEComReceiveAnyCmd() with two exceptions :

  • the use of a payload object allows handling payloads not limited by the size of a user-provided buffer
  • the payload object allows direct access to the protocol work buffer to avoid an extra copy per call

Any allocated resource associated with the given payload is released when calling this function.

Because the payload buffer may directly refer to the protocol work buffer on return, it is only valid until the next attempt to receive a frame, with any of the receive functions.

Parameters
[in]pHandleSbgECom handle.
[out]pMsgClassMessage class.
[out]pMsgIdMessage ID.
[out]pPayloadPayload.
[in]timeOutTime-out, in ms.
Returns
SBG_NO_ERROR if successful. SBG_TIME_OUT if no command message was received within the specified time out (even if timeOut = 0). SBG_NOT_READY to indicate the underlying interface is empty (only applicable when timeOut = 0).

◆ sbgEComReceiveCmd()

SbgErrorCode sbgEComReceiveCmd ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msgId,
void *  pData,
size_t *  pSize,
size_t  maxSize,
uint32_t  timeOut 
)

Receive a specific command message.

This function also processes ACK messages for the given class and ID.

All binary logs received during this time are handled trough the standard callback system.

Parameters
[in]pHandleSbgECom handle.
[in]msgClassMessage class.
[in]msgIdMessage ID.
[out]pDataData buffer.
[out]pSizeNumber of bytes received, in bytes.
[in]maxSizeData buffer size, in bytes.
[in]timeOutTime-out, in ms.
Returns
SBG_NO_ERROR if successful, SBG_NOT_READY if no command message has been received, SBG_BUFFER_OVERFLOW if the payload of the received frame couldn't fit into the buffer, SBG_TIME_OUT if no command message was received within the specified time out, any error code reported by an ACK message for the given class and ID.

◆ sbgEComReceiveCmd2()

SbgErrorCode sbgEComReceiveCmd2 ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msgId,
SbgEComProtocolPayload pPayload,
uint32_t  timeOut 
)

Receive a specific command message.

This function also processes ACK messages for the given class and ID.

All binary logs received during this time are handled trough the standard callback system.

This function is equivalent to sbgEComReceiveCmd() with two exceptions :

  • the use of a payload object allows handling payloads not limited by the size of a user-provided buffer
  • the payload object allows direct access to the protocol work buffer to avoid an extra copy per call

Any allocated resource associated with the given payload is released when calling this function.

Because the payload buffer may directly refer to the protocol work buffer on return, it is only valid until the next attempt to receive a frame, with any of the receive functions.

Parameters
[in]pHandleSbgECom handle.
[in]msgClassMessage class.
[in]msgIdMessage ID.
[out]pPayloadPayload.
[in]timeOutTime-out, in ms.
Returns
SBG_NO_ERROR if successful, SBG_NOT_READY if no command message has been received SBG_TIME_OUT if no command message was received within the specified time out, any error code reported by an ACK message for the given class and ID.

◆ sbgEComWaitForAck()

SbgErrorCode sbgEComWaitForAck ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msg,
uint32_t  timeOut 
)

Wait for an ACK for a specified amount of time.

Parameters
[in]pHandleA valid sbgECom handle.
[in]msgClassThe message class that we want to check
[in]msgThe message ID that we want to check
[in]timeOutTime out in ms during which we can receive the ACK.
Returns
SBG_NO_ERROR if the ACK has been received.

◆ sbgEComSendAck()

SbgErrorCode sbgEComSendAck ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msg,
SbgErrorCode  cmdError 
)

Send an ACK for a specific command with an associated error code.

Parameters
[in]pHandleA valid sbgECom handle.
[in]msgClassThe message class that we want to send
[in]msgThe message ID that we want to send.
[in]cmdErrorThe associated error code.
Returns
SBG_NO_ERROR if the ACK has been sent.

◆ sbgEComCmdGenericSetModelId()

SbgErrorCode sbgEComCmdGenericSetModelId ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msg,
uint32_t  modelId 
)

Generic function to set an error model ID

Parameters
[in]pHandleA valid sbgECom handle.
[in]msgClassOriginal message class
[in]msgOriginal message ID
[in]modelIdModel ID to set
Returns
SBG_NO_ERROR if the command has been executed successfully.

◆ sbgEComCmdGenericGetModelId()

SbgErrorCode sbgEComCmdGenericGetModelId ( SbgEComHandle pHandle,
uint8_t  msgClass,
uint8_t  msg,
uint32_t *  pModelId 
)

Generic function to get an error model ID

Parameters
[in]pHandleA valid sbgECom handle.
[in]msgClassOriginal message class
[in]msgOriginal message ID
[out]pModelIdReturns the currently used model ID.
Returns
SBG_NO_ERROR if the command has been executed successfully.