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 }
sbgEComCmdExportSettings
SbgErrorCode sbgEComCmdExportSettings(SbgEComHandle *pHandle, void *pBuffer, size_t *pSize, size_t maxSize)
Definition: sbgEComCmdSettings.c:96
sbgEComWaitForAck
SbgErrorCode sbgEComWaitForAck(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t timeOut)
Definition: sbgEComCmdCommon.c:278
SBG_ECOM_CMD_EXPORT_SETTINGS
@ SBG_ECOM_CMD_EXPORT_SETTINGS
Definition: sbgEComIds.h:204
sbgStreamBufferWriteUint8
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8(SbgStreamBuffer *pHandle, uint8_t value)
Definition: sbgStreamBufferCommon.h:726
sbgStreamBufferInitForWrite
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite(SbgStreamBuffer *pHandle, void *pLinkedBuffer, size_t bufferSize)
Definition: sbgStreamBufferCommon.h:208
sbgEComTransfer.h
sbgStreamBufferGetLinkedBuffer
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferCommon.h:467
SBG_ECOM_CLASS_LOG_CMD_0
@ SBG_ECOM_CLASS_LOG_CMD_0
Definition: sbgEComIds.h:59
sbgEComCmdSettings.h
sbgEComTransferReceive
SbgErrorCode sbgEComTransferReceive(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, void *pBuffer, size_t *pActualSize, size_t bufferSize)
Definition: sbgEComTransfer.c:569
sbgEComCmdImportSettings
SbgErrorCode sbgEComCmdImportSettings(SbgEComHandle *pHandle, const void *pBuffer, size_t size)
Definition: sbgEComCmdSettings.c:80
_SbgEComHandle::cmdDefaultTimeOut
uint32_t cmdDefaultTimeOut
Definition: sbgECom.h:78
_SbgEComHandle::protocolHandle
SbgEComProtocol protocolHandle
Definition: sbgECom.h:72
_SbgEComHandle
Definition: sbgECom.h:70
SBG_ECOM_CMD_SETTINGS_ACTION
@ SBG_ECOM_CMD_SETTINGS_ACTION
Definition: sbgEComIds.h:202
sbgEComTransferSend
SbgErrorCode sbgEComTransferSend(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, const void *pBuffer, size_t size)
Definition: sbgEComTransfer.c:484
_SbgEComHandle::numTrials
uint32_t numTrials
Definition: sbgECom.h:77
_SbgStreamBuffer
Definition: sbgStreamBufferCommon.h:188
sbgStreamBufferGetLength
SBG_INLINE size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle)
Definition: sbgStreamBufferCommon.h:333
SBG_NO_ERROR
@ SBG_NO_ERROR
Definition: sbgErrorCodes.h:35
SbgEComSettingsAction
enum _SbgEComSettingsAction SbgEComSettingsAction
This file implements SbgECom commands related to settings.
sbgEComCmdSettingsAction
SbgErrorCode sbgEComCmdSettingsAction(SbgEComHandle *pHandle, SbgEComSettingsAction action)
Definition: sbgEComCmdSettings.c:18
sbgStreamBuffer.h
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
SBG_ECOM_CMD_IMPORT_SETTINGS
@ SBG_ECOM_CMD_IMPORT_SETTINGS
Definition: sbgEComIds.h:203
sbgEComProtocolSend
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
Definition: sbgEComProtocol.c:60


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