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 trial;
18  size_t receivedSize;
19  uint8 receivedBuffer[SBG_ECOM_MAX_BUFFER_SIZE];
20  SbgStreamBuffer inputStream;
21 
22  //
23  // Test that the input pointers are valid
24  //
25  if ((pHandle) && (pFeatures))
26  {
27  //
28  // Send the command three times
29  //
30  for (trial = 0; trial < pHandle->numTrials; trial++)
31  {
32  //
33  // Send the command only since this is a no-payload command
34  //
36 
37  //
38  // Make sure that the command has been sent
39  //
40  if (errorCode == SBG_NO_ERROR)
41  {
42  //
43  // Try to read the device answer for 500 ms
44  //
45  errorCode = sbgEComReceiveCmd(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_FEATURES, receivedBuffer, &receivedSize, sizeof(receivedBuffer), pHandle->cmdDefaultTimeOut);
46 
47  //
48  // Test if we have received a SBG_ECOM_CMD_GPS_FEATURES command
49  //
50  if (errorCode == SBG_NO_ERROR)
51  {
52  //
53  // Initialize stream buffer to read parameters
54  //
55  sbgStreamBufferInitForRead(&inputStream, receivedBuffer, receivedSize);
56 
57  //
58  // Read parameters
59  //
60  pFeatures->sensorFeaturesMask = sbgStreamBufferReadUint32LE(&inputStream);
61  pFeatures->gnssType = (SbgEComGnssType)sbgStreamBufferReadUint8LE(&inputStream);
62  pFeatures->gnssUpdateRate = sbgStreamBufferReadUint8LE(&inputStream);
63  pFeatures->gnssSignalsMask = sbgStreamBufferReadUint32LE(&inputStream);
64  pFeatures->gnssFeaturesMask = sbgStreamBufferReadUint32LE(&inputStream);
65  sbgStreamBufferReadBuffer(&inputStream, pFeatures->gnssProductCode, 32*sizeof(char));
66  sbgStreamBufferReadBuffer(&inputStream, pFeatures->gnssSerialNumber, 32*sizeof(char));
67 
68  //
69  // The command has been executed successfully so return
70  //
71  break;
72  }
73  }
74  else
75  {
76  //
77  // We have a write error so exit the try loop
78  //
79  break;
80  }
81  }
82  }
83  else
84  {
85  //
86  // Null pointer
87  //
88  errorCode = SBG_NULL_POINTER;
89  }
90 
91  return errorCode;
92 }
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
SbgErrorCode sbgEComReceiveCmd(SbgEComHandle *pHandle, uint8 msgClass, uint8 msg, void *pData, size_t *pSize, size_t maxSize, uint32 timeOut)
unsigned int uint32
Definition: sbgTypes.h:58
Used to read/write data from/to a memory buffer stream.
SbgEComProtocol protocolHandle
Definition: sbgECom.h:82
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8 msgClass, uint8 msg, const void *pData, size_t size)
SbgEComGnssType gnssType
uint32 numTrials
Definition: sbgECom.h:86
#define NULL
Definition: sbgDefines.h:43
uint32 cmdDefaultTimeOut
Definition: sbgECom.h:87
SBG_INLINE uint32 sbgStreamBufferReadUint32LE(SbgStreamBuffer *pHandle)
enum _SbgEComGnssType SbgEComGnssType
This file implements SbgECom commands related to device features.
#define sbgStreamBufferReadUint8LE
unsigned char uint8
Definition: sbgTypes.h:56
SbgErrorCode sbgEComCmdGetFeatures(SbgEComHandle *pHandle, SbgEComFeatures *pFeatures)
enum _SbgErrorCode SbgErrorCode
#define SBG_ECOM_MAX_BUFFER_SIZE


sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20