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 }
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
Used to read/write data from/to a memory buffer stream.
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
SbgEComProtocol protocolHandle
Definition: sbgECom.h:72
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
uint32_t cmdDefaultTimeOut
Definition: sbgECom.h:78
SbgEComGnssType gnssType
#define NULL
Definition: sbgDefines.h:81
enum _SbgEComGnssType SbgEComGnssType
This file implements SbgECom commands related to device features.
SbgErrorCode sbgEComReceiveCmd(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, void *pData, size_t *pSize, size_t maxSize, uint32_t timeOut)
#define sbgStreamBufferReadUint8LE
uint32_t numTrials
Definition: sbgECom.h:77
SbgErrorCode sbgEComCmdGetFeatures(SbgEComHandle *pHandle, SbgEComFeatures *pFeatures)
SBG_INLINE uint32_t sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
enum _SbgErrorCode SbgErrorCode
#define SBG_ECOM_MAX_BUFFER_SIZE


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35