sbgEComCmdFeatures.c
Go to the documentation of this file.
1 #include "sbgEComCmdFeatures.h"
3 
4 //----------------------------------------------------------------------//
5 //- Features commands -//
6 //----------------------------------------------------------------------//
7 
15 {
16  SbgErrorCode errorCode = SBG_NO_ERROR;
17  uint32_t trial;
18  size_t receivedSize;
19  uint8_t receivedBuffer[SBG_ECOM_MAX_BUFFER_SIZE];
20  SbgStreamBuffer inputStream;
21 
22  assert(pHandle);
23  assert(pFeatures);
24 
25  //
26  // Send the command three times
27  //
28  for (trial = 0; trial < pHandle->numTrials; trial++)
29  {
30  //
31  // Send the command only since this is a no-payload command
32  //
34 
35  //
36  // Make sure that the command has been sent
37  //
38  if (errorCode == SBG_NO_ERROR)
39  {
40  //
41  // Try to read the device answer for 500 ms
42  //
43  errorCode = sbgEComReceiveCmd(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_FEATURES, receivedBuffer, &receivedSize, sizeof(receivedBuffer), pHandle->cmdDefaultTimeOut);
44 
45  //
46  // Test if we have received a SBG_ECOM_CMD_GPS_FEATURES command
47  //
48  if (errorCode == SBG_NO_ERROR)
49  {
50  //
51  // Initialize stream buffer to read parameters
52  //
53  sbgStreamBufferInitForRead(&inputStream, receivedBuffer, receivedSize);
54 
55  //
56  // Read parameters
57  //
58  pFeatures->sensorFeaturesMask = sbgStreamBufferReadUint32LE(&inputStream);
59  pFeatures->gnssType = (SbgEComGnssType)sbgStreamBufferReadUint8LE(&inputStream);
60  pFeatures->gnssUpdateRate = sbgStreamBufferReadUint8LE(&inputStream);
61  pFeatures->gnssSignalsMask = sbgStreamBufferReadUint32LE(&inputStream);
62  pFeatures->gnssFeaturesMask = sbgStreamBufferReadUint32LE(&inputStream);
63  sbgStreamBufferReadBuffer(&inputStream, pFeatures->gnssProductCode, 32*sizeof(char));
64  sbgStreamBufferReadBuffer(&inputStream, pFeatures->gnssSerialNumber, 32*sizeof(char));
65 
66  //
67  // The command has been executed successfully so return
68  //
69  break;
70  }
71  }
72  else
73  {
74  //
75  // We have a write error so exit the try loop
76  //
77  break;
78  }
79  }
80 
81  return errorCode;
82 }
sbgStreamBufferReadUint8LE
#define sbgStreamBufferReadUint8LE
Definition: sbgStreamBufferCommon.h:141
_SbgEComFeatures::gnssType
SbgEComGnssType gnssType
Definition: sbgEComCmdFeatures.h:92
NULL
#define NULL
Definition: sbgDefines.h:81
sbgEComCmdFeatures.h
_SbgEComFeatures::gnssProductCode
char gnssProductCode[32]
Definition: sbgEComCmdFeatures.h:96
SBG_ECOM_MAX_BUFFER_SIZE
#define SBG_ECOM_MAX_BUFFER_SIZE
Implementation of the Ekinox binary communication protocol. You can access low-level communication w...
Definition: sbgEComProtocol.h:35
SBG_ECOM_CLASS_LOG_CMD_0
@ SBG_ECOM_CLASS_LOG_CMD_0
Definition: sbgEComIds.h:59
SbgEComGnssType
enum _SbgEComGnssType SbgEComGnssType
sbgEComReceiveCmd
SbgErrorCode sbgEComReceiveCmd(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, void *pData, size_t *pSize, size_t maxSize, uint32_t timeOut)
Definition: sbgEComCmdCommon.c:174
_SbgEComFeatures
Definition: sbgEComCmdFeatures.h:89
_SbgEComFeatures::gnssFeaturesMask
uint32_t gnssFeaturesMask
Definition: sbgEComCmdFeatures.h:95
sbgStreamBufferReadUint32LE
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferLE.h:386
_SbgEComHandle::cmdDefaultTimeOut
uint32_t cmdDefaultTimeOut
Definition: sbgECom.h:78
_SbgEComHandle::protocolHandle
SbgEComProtocol protocolHandle
Definition: sbgECom.h:72
_SbgEComHandle
Definition: sbgECom.h:70
sbgStreamBufferReadBuffer
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
Definition: sbgStreamBufferCommon.h:636
_SbgEComFeatures::gnssUpdateRate
uint8_t gnssUpdateRate
Definition: sbgEComCmdFeatures.h:93
_SbgEComFeatures::gnssSignalsMask
uint32_t gnssSignalsMask
Definition: sbgEComCmdFeatures.h:94
_SbgEComFeatures::gnssSerialNumber
char gnssSerialNumber[32]
Definition: sbgEComCmdFeatures.h:97
_SbgEComHandle::numTrials
uint32_t numTrials
Definition: sbgECom.h:77
_SbgStreamBuffer
Definition: sbgStreamBufferCommon.h:188
sbgEComCmdGetFeatures
SbgErrorCode sbgEComCmdGetFeatures(SbgEComHandle *pHandle, SbgEComFeatures *pFeatures)
Definition: sbgEComCmdFeatures.c:14
SBG_NO_ERROR
@ SBG_NO_ERROR
Definition: sbgErrorCodes.h:35
sbgStreamBuffer.h
_SbgEComFeatures::sensorFeaturesMask
uint32_t sensorFeaturesMask
Definition: sbgEComCmdFeatures.h:91
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
SBG_ECOM_CMD_FEATURES
@ SBG_ECOM_CMD_FEATURES
Definition: sbgEComIds.h:253
sbgEComProtocolSend
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
Definition: sbgEComProtocol.c:60
sbgStreamBufferInitForRead
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
Definition: sbgStreamBufferCommon.h:242


sbg_driver
Author(s): SBG Systems
autogenerated on Fri Oct 11 2024 02:13:40