sbgEComCmdSettings.c
Go to the documentation of this file.
1 #include "sbgEComCmdSettings.h"
4 
5 //----------------------------------------------------------------------//
6 //- Settings commands -//
7 //----------------------------------------------------------------------//
8 
19 {
20  SbgErrorCode errorCode = SBG_NO_ERROR;
21  uint32_t trial;
22  uint8_t outputBuffer[1];
23  SbgStreamBuffer outputStream;
24 
25  assert(pHandle);
26 
27  //
28  // Send the command three times
29  //
30  for (trial = 0; trial < pHandle->numTrials; trial++)
31  {
32  //
33  // Send the command and the action as a 1-byte payload
34  //
35  sbgStreamBufferInitForWrite(&outputStream, outputBuffer, sizeof(outputBuffer));
36  sbgStreamBufferWriteUint8(&outputStream, action);
38 
39  //
40  // Make sure that the command has been sent
41  //
42  if (errorCode == SBG_NO_ERROR)
43  {
44  //
45  // Try to read the device answer for 500 ms
46  //
48 
49  //
50  // Test if we have received a valid ACK
51  //
52  if (errorCode == SBG_NO_ERROR)
53  {
54  //
55  // The command has been executed successfully so return
56  //
57  break;
58  }
59  }
60  else
61  {
62  //
63  // We have a write error so exit the try loop
64  //
65  break;
66  }
67  }
68 
69  return errorCode;
70 }
71 
80 SbgErrorCode sbgEComCmdImportSettings(SbgEComHandle *pHandle, const void *pBuffer, size_t size)
81 {
82  //
83  // Call function that handle data transfer
84  //
86 }
87 
96 SbgErrorCode sbgEComCmdExportSettings(SbgEComHandle *pHandle, void *pBuffer, size_t *pSize, size_t maxSize)
97 {
98  //
99  // Call function that handle data transfer
100  //
101  return sbgEComTransferReceive(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_EXPORT_SETTINGS, pBuffer, pSize, maxSize);
102 }
SbgErrorCode sbgEComCmdImportSettings(SbgEComHandle *pHandle, const void *pBuffer, size_t size)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8(SbgStreamBuffer *pHandle, uint8_t value)
SbgErrorCode sbgEComCmdSettingsAction(SbgEComHandle *pHandle, SbgEComSettingsAction action)
enum _SbgEComSettingsAction SbgEComSettingsAction
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)
Handle large send/receive transfer for specific ECom Protocol commands.
SbgEComProtocol protocolHandle
Definition: sbgECom.h:72
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite(SbgStreamBuffer *pHandle, void *pLinkedBuffer, size_t bufferSize)
SbgErrorCode sbgEComTransferSend(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, const void *pBuffer, size_t size)
This file implements SbgECom commands related to settings.
SbgErrorCode sbgEComWaitForAck(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t timeOut)
uint32_t cmdDefaultTimeOut
Definition: sbgECom.h:78
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComCmdExportSettings(SbgEComHandle *pHandle, void *pBuffer, size_t *pSize, size_t maxSize)
SbgErrorCode sbgEComTransferReceive(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, void *pBuffer, size_t *pActualSize, size_t bufferSize)
uint32_t numTrials
Definition: sbgECom.h:77
SBG_INLINE size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle)
enum _SbgErrorCode SbgErrorCode


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