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 trial;
22  uint8 outputBuffer[1];
23  SbgStreamBuffer outputStream;
24 
25  //
26  // Test that the protocol handle is valid
27  //
28  if (pHandle)
29  {
30  //
31  // Send the command three times
32  //
33  for (trial = 0; trial < pHandle->numTrials; trial++)
34  {
35  //
36  // Send the command and the action as a 1-byte payload
37  //
38  sbgStreamBufferInitForWrite(&outputStream, outputBuffer, sizeof(outputBuffer));
39  sbgStreamBufferWriteUint8(&outputStream, action);
41 
42  //
43  // Make sure that the command has been sent
44  //
45  if (errorCode == SBG_NO_ERROR)
46  {
47  //
48  // Try to read the device answer for 500 ms
49  //
51 
52  //
53  // Test if we have received a valid ACK
54  //
55  if (errorCode == SBG_NO_ERROR)
56  {
57  //
58  // The command has been executed successfully so return
59  //
60  break;
61  }
62  }
63  else
64  {
65  //
66  // We have a write error so exit the try loop
67  //
68  break;
69  }
70  }
71  }
72  else
73  {
74  //
75  // Invalid protocol handle.
76  //
77  errorCode = SBG_NULL_POINTER;
78  }
79 
80  return errorCode;
81 }
82 
91 SbgErrorCode sbgEComCmdImportSettings(SbgEComHandle *pHandle, const void *pBuffer, size_t size)
92 {
93  //
94  // Call function that handle data transfer
95  //
97 }
98 
107 SbgErrorCode sbgEComCmdExportSettings(SbgEComHandle *pHandle, void *pBuffer, size_t *pSize, size_t maxSize)
108 {
109  //
110  // Call function that handle data transfer
111  //
112  return sbgEComTransferReceive(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_EXPORT_SETTINGS, pBuffer, pSize, maxSize);
113 }
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8(SbgStreamBuffer *pHandle, uint8 value)
SbgErrorCode sbgEComCmdImportSettings(SbgEComHandle *pHandle, const void *pBuffer, size_t size)
SbgErrorCode sbgEComCmdSettingsAction(SbgEComHandle *pHandle, SbgEComSettingsAction action)
unsigned int uint32
Definition: sbgTypes.h:58
enum _SbgEComSettingsAction SbgEComSettingsAction
Used to read/write data from/to a memory buffer stream.
SbgErrorCode sbgEComTransferSend(SbgEComHandle *pHandle, uint8 msgClass, uint8 msg, const void *pBuffer, size_t size)
SbgErrorCode sbgEComWaitForAck(SbgEComHandle *pHandle, uint8 msgClass, uint8 msg, uint32 timeOut)
Handle large send/receive transfer for specific ECom Protocol commands.
SbgEComProtocol protocolHandle
Definition: sbgECom.h:82
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite(SbgStreamBuffer *pHandle, void *pLinkedBuffer, size_t bufferSize)
This file implements SbgECom commands related to settings.
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8 msgClass, uint8 msg, const void *pData, size_t size)
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComCmdExportSettings(SbgEComHandle *pHandle, void *pBuffer, size_t *pSize, size_t maxSize)
uint32 numTrials
Definition: sbgECom.h:86
uint32 cmdDefaultTimeOut
Definition: sbgECom.h:87
unsigned char uint8
Definition: sbgTypes.h:56
SBG_INLINE size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle)
enum _SbgErrorCode SbgErrorCode
SbgErrorCode sbgEComTransferReceive(SbgEComHandle *pHandle, uint8 msgClass, uint8 msg, void *pBuffer, size_t *pActualSize, size_t bufferSize)


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