sbgEComCmdSensor.c
Go to the documentation of this file.
1 #include "sbgEComCmdSensor.h"
4 
5 //----------------------------------------------------------------------//
6 //- Sensor commands -//
7 //----------------------------------------------------------------------//
8 
16 {
17  //
18  // Call generic function with specific command name
19  //
21 }
22 
23 
31 {
32  //
33  // Call generic function with specific command name
34  //
36 }
37 
45 {
46  SbgErrorCode errorCode = SBG_NO_ERROR;
47  uint32_t trial;
48  size_t receivedSize;
49  uint8_t receivedBuffer[SBG_ECOM_MAX_BUFFER_SIZE];
50  SbgStreamBuffer inputStream;
51 
52  assert(pHandle);
53  assert(pConf);
54 
55  //
56  // Send the command three times
57  //
58  for (trial = 0; trial < pHandle->numTrials; trial++)
59  {
60  //
61  // Send the command only since this is a no payload command
62  //
64 
65  //
66  // Make sure that the command has been sent
67  //
68  if (errorCode == SBG_NO_ERROR)
69  {
70  //
71  // Try to read the device answer for 500 ms
72  //
73  errorCode = sbgEComReceiveCmd(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_INIT_PARAMETERS, receivedBuffer, &receivedSize, sizeof(receivedBuffer), pHandle->cmdDefaultTimeOut);
74 
75  //
76  // Test if we have received a SBG_ECOM_CMD_INIT_PARAMETERS command
77  //
78  if (errorCode == SBG_NO_ERROR)
79  {
80  //
81  // Initialize stream buffer to read parameters
82  //
83  sbgStreamBufferInitForRead(&inputStream, receivedBuffer, receivedSize);
84 
85  //
86  // Read parameters
87  //
88  pConf->latitude = sbgStreamBufferReadDoubleLE(&inputStream);
89  pConf->longitude = sbgStreamBufferReadDoubleLE(&inputStream);
90  pConf->altitude = sbgStreamBufferReadDoubleLE(&inputStream);
91  pConf->year = sbgStreamBufferReadUint16LE(&inputStream);
92  pConf->month = sbgStreamBufferReadUint8LE(&inputStream);
93  pConf->day = sbgStreamBufferReadUint8LE(&inputStream);
94 
95  //
96  // The command has been executed successfully so return
97  //
98  break;
99  }
100  }
101  else
102  {
103  //
104  // We have a write error so exit the try loop
105  //
106  break;
107  }
108  }
109 
110  return errorCode;
111 }
112 
120 {
121  SbgErrorCode errorCode = SBG_NO_ERROR;
122  uint32_t trial;
123  uint8_t outputBuffer[SBG_ECOM_MAX_BUFFER_SIZE];
124  SbgStreamBuffer outputStream;
125 
126  assert(pHandle);
127  assert(pConf);
128 
129  //
130  // Send the command three times
131  //
132  for (trial = 0; trial < pHandle->numTrials; trial++)
133  {
134  //
135  // Init stream buffer for output
136  //
137  sbgStreamBufferInitForWrite(&outputStream, outputBuffer, sizeof(outputBuffer));
138 
139  //
140  // Build payload
141  //
142  sbgStreamBufferWriteDoubleLE(&outputStream, pConf->latitude);
143  sbgStreamBufferWriteDoubleLE(&outputStream, pConf->longitude);
144  sbgStreamBufferWriteDoubleLE(&outputStream, pConf->altitude);
145  sbgStreamBufferWriteUint16LE(&outputStream, (uint16_t)pConf->year);
146  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->month);
147  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->day);
148 
149  //
150  // Send the payload over ECom
151  //
153 
154  //
155  // Make sure that the command has been sent
156  //
157  if (errorCode == SBG_NO_ERROR)
158  {
159  //
160  // Try to read the device answer for 500 ms
161  //
163 
164  //
165  // Test if we have received a valid ACK
166  //
167  if (errorCode == SBG_NO_ERROR)
168  {
169  //
170  // The command has been executed successfully so return
171  //
172  break;
173  }
174  }
175  else
176  {
177  //
178  // We have a write error so exit the try loop
179  //
180  break;
181  }
182  }
183 
184  return errorCode;
185 }
186 
194 {
195  SbgErrorCode errorCode = SBG_NO_ERROR;
196  uint32_t trial;
197  size_t receivedSize;
198  uint8_t receivedBuffer[16];
199  SbgStreamBuffer inputStream;
200 
201  assert(pHandle);
202  assert(pConf);
203 
204  //
205  // Send the command three times
206  //
207  for (trial = 0; trial < pHandle->numTrials; trial++)
208  {
209  //
210  // Send the command only since this is a no payload command
211  //
213 
214  //
215  // Make sure that the command has been sent
216  //
217  if (errorCode == SBG_NO_ERROR)
218  {
219  //
220  // Try to read the device answer for 500 ms
221  //
222  errorCode = sbgEComReceiveCmd(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_AIDING_ASSIGNMENT, receivedBuffer, &receivedSize, sizeof(receivedBuffer), pHandle->cmdDefaultTimeOut);
223 
224  //
225  // Test if we have received a SBG_ECOM_CMD_AIDING_ASSIGNMENT command
226  //
227  if (errorCode == SBG_NO_ERROR)
228  {
229  //
230  // Initialize stream buffer to read parameters
231  //
232  sbgStreamBufferInitForRead(&inputStream, receivedBuffer, receivedSize);
233 
234  //
235  // Read parameters
236  //
239 
240  sbgStreamBufferSeek(&inputStream, 4*sizeof(uint8_t), SB_SEEK_CUR_INC);
244 
248 
249  //
250  // The command has been executed successfully so return
251  //
252  break;
253  }
254  }
255  else
256  {
257  //
258  // We have a write error so exit the try loop
259  //
260  break;
261  }
262  }
263 
264  return errorCode;
265 }
266 
274 {
275  SbgErrorCode errorCode = SBG_NO_ERROR;
276  uint32_t trial;
277  uint8_t outputBuffer[16];
278  SbgStreamBuffer outputStream;
279 
280  assert(pHandle);
281  assert(pConf);
282 
283  //
284  // Send the command three times
285  //
286  for (trial = 0; trial < pHandle->numTrials; trial++)
287  {
288  //
289  // Init stream buffer for output
290  //
291  sbgStreamBufferInitForWrite(&outputStream, outputBuffer, sizeof(outputBuffer));
292 
293  //
294  // Build payload
295  //
296  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->gps1Port);
297  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->gps1Sync);
298 
299  //
300  // Skip the 4 reserved bytes
301  //
302  sbgStreamBufferWriteUint8LE(&outputStream, 0);
303  sbgStreamBufferWriteUint8LE(&outputStream, 0);
304  sbgStreamBufferWriteUint8LE(&outputStream, 0);
305  sbgStreamBufferWriteUint8LE(&outputStream, 0);
306 
307  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->dvlPort);
308  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->dvlSync);
309  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->rtcmPort);
310  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->airDataPort);
311  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pConf->odometerPinsConf);
312 
313  //
314  // Send the payload over ECom
315  //
317 
318  //
319  // Make sure that the command has been sent
320  //
321  if (errorCode == SBG_NO_ERROR)
322  {
323  //
324  // Try to read the device answer for 500 ms
325  //
327 
328  //
329  // Test if we have received a valid ACK
330  //
331  if (errorCode == SBG_NO_ERROR)
332  {
333  //
334  // The command has been executed successfully so return
335  //
336  break;
337  }
338  }
339  else
340  {
341  //
342  // We have a write error so exit the try loop
343  //
344  break;
345  }
346  }
347 
348  return errorCode;
349 }
350 
359 {
360  SbgErrorCode errorCode = SBG_NO_ERROR;
361  uint32_t trial;
362  size_t receivedSize;
363  uint8_t receivedBuffer[32];
364  SbgStreamBuffer inputStream;
365 
366  assert(pHandle);
367  assert(pAlignConf);
368  assert(leverArm);
369 
370  //
371  // Send the command three times
372  //
373  for (trial = 0; trial < pHandle->numTrials; trial++)
374  {
375  //
376  // Send the command only since this is a no-payload command
377  //
379 
380  //
381  // Make sure that the command has been sent
382  //
383  if (errorCode == SBG_NO_ERROR)
384  {
385  //
386  // Try to read the device answer for 500 ms
387  //
388  errorCode = sbgEComReceiveCmd(pHandle, SBG_ECOM_CLASS_LOG_CMD_0, SBG_ECOM_CMD_IMU_ALIGNMENT_LEVER_ARM, receivedBuffer, &receivedSize, sizeof(receivedBuffer), pHandle->cmdDefaultTimeOut);
389 
390  //
391  // Test if we have received a SBG_ECOM_CMD_IMU_ALIGNMENT command
392  //
393  if (errorCode == SBG_NO_ERROR)
394  {
395  //
396  // Initialize stream buffer to read parameters
397  //
398  sbgStreamBufferInitForRead(&inputStream, receivedBuffer, receivedSize);
399 
400  //
401  // Read parameters
402  //
405  pAlignConf->misRoll = sbgStreamBufferReadFloatLE(&inputStream);
406  pAlignConf->misPitch = sbgStreamBufferReadFloatLE(&inputStream);
407  pAlignConf->misYaw = sbgStreamBufferReadFloatLE(&inputStream);
408  leverArm[0] = sbgStreamBufferReadFloatLE(&inputStream);
409  leverArm[1] = sbgStreamBufferReadFloatLE(&inputStream);
410  leverArm[2] = sbgStreamBufferReadFloatLE(&inputStream);
411 
412  //
413  // The command has been executed successfully so return
414  //
415  break;
416  }
417  }
418  else
419  {
420  //
421  // We have a write error so exit the try loop
422  //
423  break;
424  }
425  }
426 
427  return errorCode;
428 }
429 
438 {
439  SbgErrorCode errorCode = SBG_NO_ERROR;
440  uint32_t trial;
441  uint8_t outputBuffer[32];
442  SbgStreamBuffer outputStream;
443 
444  assert(pHandle);
445  assert(pAlignConf);
446  assert(leverArm);
447 
448  //
449  // Send the command three times
450  //
451  for (trial = 0; trial < pHandle->numTrials; trial++)
452  {
453  //
454  // Init stream buffer for output
455  //
456  sbgStreamBufferInitForWrite(&outputStream, outputBuffer, sizeof(outputBuffer));
457 
458  //
459  // Build payload
460  //
461  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pAlignConf->axisDirectionX);
462  sbgStreamBufferWriteUint8LE(&outputStream, (uint8_t)pAlignConf->axisDirectionY);
463  sbgStreamBufferWriteFloatLE(&outputStream, pAlignConf->misRoll);
464  sbgStreamBufferWriteFloatLE(&outputStream, pAlignConf->misPitch);
465  sbgStreamBufferWriteFloatLE(&outputStream, pAlignConf->misYaw);
466  sbgStreamBufferWriteFloatLE(&outputStream, leverArm[0]);
467  sbgStreamBufferWriteFloatLE(&outputStream, leverArm[1]);
468  sbgStreamBufferWriteFloatLE(&outputStream, leverArm[2]);
469 
470  //
471  // Send the payload over ECom
472  //
474 
475  //
476  // Make sure that the command has been sent
477  //
478  if (errorCode == SBG_NO_ERROR)
479  {
480  //
481  // Try to read the device answer for 500 ms
482  //
484 
485  //
486  // Test if we have received a valid ACK
487  //
488  if (errorCode == SBG_NO_ERROR)
489  {
490  //
491  // The command has been executed successfully so return
492  //
493  break;
494  }
495  }
496  else
497  {
498  //
499  // We have a write error so exit the try loop
500  //
501  break;
502  }
503  }
504 
505  return errorCode;
506 }
SbgEComModulePortAssignment airDataPort
SbgErrorCode sbgEComCmdSensorSetAlignmentAndLeverArm(SbgEComHandle *pHandle, const SbgEComSensorAlignmentInfo *pAlignConf, const float leverArm[3])
SbgEComAxisDirection axisDirectionX
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead(SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
SbgEComModuleSyncAssignment dvlSync
This file implements SbgECom commands related to sensor.
SBG_INLINE SbgErrorCode sbgStreamBufferSeek(SbgStreamBuffer *pHandle, size_t offset, SbgSBSeekOrigin origin)
SbgEComModulePortAssignment gps1Port
SbgErrorCode sbgEComCmdGenericGetModelInfo(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, SbgEComModelInfo *pModelInfo)
SBG_INLINE float sbgStreamBufferReadFloatLE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComCmdSensorGetAidingAssignment(SbgEComHandle *pHandle, SbgEComAidingAssignConf *pConf)
SbgEComAxisDirection axisDirectionY
SbgErrorCode sbgEComCmdSensorGetMotionProfileInfo(SbgEComHandle *pHandle, SbgEComModelInfo *pModelInfo)
Used to read/write data from/to a memory buffer stream.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteDoubleLE(SbgStreamBuffer *pHandle, double value)
SbgErrorCode sbgEComProtocolSend(SbgEComProtocol *pHandle, uint8_t msgClass, uint8_t msg, const void *pData, size_t size)
SbgErrorCode sbgEComCmdGenericSetModelId(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t modelId)
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)
SbgEComModuleSyncAssignment gps1Sync
SBG_INLINE uint16_t sbgStreamBufferReadUint16LE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComCmdSensorSetAidingAssignment(SbgEComHandle *pHandle, const SbgEComAidingAssignConf *pConf)
enum _SbgEComModuleSyncAssignment SbgEComModuleSyncAssignment
enum _SbgEComOdometerPinAssignment SbgEComOdometerPinAssignment
SbgEComModulePortAssignment rtcmPort
SbgErrorCode sbgEComWaitForAck(SbgEComHandle *pHandle, uint8_t msgClass, uint8_t msg, uint32_t timeOut)
uint32_t cmdDefaultTimeOut
Definition: sbgECom.h:78
#define sbgStreamBufferWriteUint8LE
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer(SbgStreamBuffer *pHandle)
#define NULL
Definition: sbgDefines.h:81
SbgErrorCode sbgEComCmdSensorGetInitCondition(SbgEComHandle *pHandle, SbgEComInitConditionConf *pConf)
SbgEComOdometerPinAssignment odometerPinsConf
SbgEComModulePortAssignment dvlPort
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
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatLE(SbgStreamBuffer *pHandle, float value)
enum _SbgEComAxisDirection SbgEComAxisDirection
enum _SbgEComModulePortAssignment SbgEComModulePortAssignment
SBG_INLINE size_t sbgStreamBufferGetLength(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16LE(SbgStreamBuffer *pHandle, uint16_t value)
SbgErrorCode sbgEComCmdSensorSetMotionProfileId(SbgEComHandle *pHandle, uint32_t id)
SBG_INLINE double sbgStreamBufferReadDoubleLE(SbgStreamBuffer *pHandle)
SbgErrorCode sbgEComCmdSensorSetInitCondition(SbgEComHandle *pHandle, const SbgEComInitConditionConf *pConf)
enum _SbgErrorCode SbgErrorCode
#define SBG_ECOM_MAX_BUFFER_SIZE
SbgErrorCode sbgEComCmdSensorGetAlignmentAndLeverArm(SbgEComHandle *pHandle, SbgEComSensorAlignmentInfo *pAlignConf, float leverArm[3])


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