@@ -2709,7 +2709,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
27092709
27102710 return  (true );
27112711}
2712- boolean SFE_UBLOX_GPS::getUdrStatus  (uint16_t  maxWait)
2712+ boolean SFE_UBLOX_GPS::getEsfStatus  (uint16_t  maxWait)
27132713{
27142714 //  Requesting Data from the receiver
27152715 packetCfg.cls  = UBX_CLASS_ESF;
@@ -2723,16 +2723,16 @@ boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait)
27232723 checkUblox ();
27242724
27252725 //  payload should be loaded. 
2726-  imuMetric .version  = extractByte (4 ); 
2727-  imuMetric .fusionMode  = extractByte (12 );
2728-  imuMetric .numSens  = extractByte (15 );
2726+  imuData .version  = extractByte (4 ); 
2727+  imuData .fusionMode  = extractByte (12 );
2728+  imuData .numSens  = extractByte (15 );
27292729
27302730 //  Individual Status Sensor in different function
27312731 return (true );
27322732}
27332733
27342734// 
2735- boolean SFE_UBLOX_GPS::getInsInfo  (uint16_t  maxWait)
2735+ boolean SFE_UBLOX_GPS::getEsfInfo  (uint16_t  maxWait)
27362736{
27372737 packetCfg.cls  = UBX_CLASS_ESF;
27382738 packetCfg.id  = UBX_ESF_INS;
@@ -2747,26 +2747,26 @@ boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait)
27472747 //  Validity of each sensor value below 
27482748 uint32_t  validity = extractLong (0 ); 
27492749
2750-  imuMetric .xAngRateVald  = (validity && 0x0080 ) >> 8 ;
2751-  imuMetric .yAngRateVald  = (validity && 0x0100 ) >> 9 ; 
2752-  imuMetric .zAngRateVald  = (validity && 0x0200 ) >> 10 ; 
2753-  imuMetric .xAccelVald  = (validity && 0x0400 ) >> 11 ;
2754-  imuMetric .yAccelVald  = (validity && 0x0800 ) >> 12 ;
2755-  imuMetric .zAccelVald  = (validity && 0x1000 ) >> 13 ;
2750+  imuData .xAngRateVald  = (validity && 0x0080 ) >> 8 ;
2751+  imuData .yAngRateVald  = (validity && 0x0100 ) >> 9 ; 
2752+  imuData .zAngRateVald  = (validity && 0x0200 ) >> 10 ; 
2753+  imuData .xAccelVald  = (validity && 0x0400 ) >> 11 ;
2754+  imuData .yAccelVald  = (validity && 0x0800 ) >> 12 ;
2755+  imuData .zAccelVald  = (validity && 0x1000 ) >> 13 ;
27562756
2757-  imuMetric .xAngRate  = extractLong (12 ); //  deg/s
2758-  imuMetric .yAngRate  = extractLong (16 ); //  deg/s
2759-  imuMetric .zAngRate  = extractLong (20 ); //  deg/s
2757+  imuData .xAngRate  = extractLong (12 ); //  deg/s
2758+  imuData .yAngRate  = extractLong (16 ); //  deg/s
2759+  imuData .zAngRate  = extractLong (20 ); //  deg/s
27602760
2761-  imuMetric .xAccel  = extractLong (24 ); //  m/s
2762-  imuMetric .yAccel  = extractLong (28 ); //  m/s
2763-  imuMetric .zAccel  = extractLong (32 ); //  m/s
2761+  imuData .xAccel  = extractLong (24 ); //  m/s
2762+  imuData .yAccel  = extractLong (28 ); //  m/s
2763+  imuData .zAccel  = extractLong (32 ); //  m/s
27642764
27652765 return (true );
27662766}
27672767
27682768// 
2769- boolean SFE_UBLOX_GPS::getExternSensMeas  (uint16_t  maxWait)
2769+ boolean SFE_UBLOX_GPS::getEsfMeas  (uint16_t  maxWait)
27702770{ 
27712771
27722772 packetCfg.cls  = UBX_CLASS_ESF;
@@ -2787,14 +2787,23 @@ boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait)
27872787 uint8_t  tagValid = (flags && 0x04 ) >> 3 ;
27882788 uint8_t  numMeas = (flags && 0x1000 ) >> 15 ;
27892789
2790+  uint8_t  byteOffset = 4 ;
2791+ 
2792+  for (uint8_t  i=0 ; i<imuData.numSens ; i++){
2793+ 
2794+  uint32_t  bitField = extractLong (4  + byteOffset * i);
2795+  imuData.dataType [i] = (bitField && 0xFF000000 ) >> 23 ; 
2796+  imuData.data [i] = (bitField && 0xFFFFFF );
2797+  imuData.dataTStamp [i] = extractLong (8  + byteOffset * i); 
2798+ 
2799+  }
2800+ 
27902801}
27912802
27922803boolean SFE_UBLOX_GPS::getEsfRaw (uint16_t  maxWait)
27932804{
27942805
2795-  //  Need the number of sensors to know what to sample.
2796-  getUdrStatus ();
2797- 
2806+  //  Need to know the number of sensor to get the correct data
27982807 //  Rate selected in UBX-CFG-MSG is not respected
27992808 packetCfg.cls  = UBX_CLASS_ESF;
28002809 packetCfg.id  = UBX_ESF_RAW;
@@ -2808,13 +2817,55 @@ boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait)
28082817
28092818 uint8_t  byteOffset = 8 ;
28102819
2811-  for (uint8_t  i=0 ; i<imuMetric .numSens ; i++){
2820+  for (uint8_t  i=0 ; i<imuData .numSens ; i++){
28122821
28132822 uint32_t  bitField = extractLong (4  + byteOffset * i);
2814-  imuMetric. dataType [i] = (bitField && 0xFF000000 ) >> 23 ; //  Repeating Blocks on the back burner... 
2815-  imuMetric. data [i] = (bitField && 0xFFFFFF );
2816-  imuMetric. timeStamp [i] = extractLong (8  + byteOffset * i); 
2823+  imuData. rawDataType [i] = (bitField && 0xFF000000 ) >> 23 ; 
2824+  imuData. rawData [i] = (bitField && 0xFFFFFF );
2825+  imuData. rawTStamp [i] = extractLong (8  + byteOffset * i); 
28172826
28182827 }
28192828}
28202829
2830+ boolean SFE_UBLOX_GPS::getSensorStatus (uint8_t  sensor)
2831+ {
2832+ 
2833+  packetCfg.cls  = UBX_CLASS_ESF;
2834+  packetCfg.id  = UBX_ESF_STATUS;
2835+  packetCfg.len  = 0 ;
2836+  packetCfg.startingSpot  = 0 ;
2837+ 
2838+  if  (sendCommand (packetCfg, maxWait) == false )
2839+  return  (false ); // If command send fails then bail
2840+ 
2841+  uint8_t  numberSens = extactByte (15 )
2842+  if  (sensor > numberSens)
2843+  return  SFE_UBLOX_STATUS_OUT_OF_RANGE;
2844+ 
2845+  checkUblox ();
2846+  
2847+  uint8_t  offset = 4 ; 
2848+ 
2849+  //  Only the last sensor value checked will remain.
2850+  for (uint8_t  i=0 ; i<sensor; i++){
2851+ 
2852+  uint8_t  sensorFieldOne = extractByte (16  + offset * i); 
2853+  uint8_t  sensorFieldTwo = extractByte (17  + offset * i); 
2854+  ublox.freq  = extractByte (18  + offset * i); 
2855+  uint8_t  sensorFieldThr = extractByte (19  + offset * i); 
2856+ 
2857+  ubloxSen.senType  = (sensorFieldOne && 0x10 ) >> 5 ;
2858+  ubloxSen.isUsed  = (sensorFieldOne && 0x20 ) >> 6 ; 
2859+  ubloxSen.isReady  = (sensorFieldOne && 0x30 ) >> 7 ; 
2860+ 
2861+  ubloxSen.calibStatus  = sensorFieldTwo && 0x03 ;
2862+  ubloxSen.timeStatus  = (sensorFieldTwo && 0xC ) >> 2 ;
2863+  
2864+  ubloxSen.badMeas  = (sensorFieldThr && 0x01 ); 
2865+  ubloxSen.badTag  = (sensorFieldThr && 0x02 ) >> 1 ; 
2866+  ubloxSen.missMeas  = (sensorFieldThr && 0x04 ) >> 2 ; 
2867+  ubloxSen.noisyMeas  = (sensorFieldThr && 0x08 ) >> 3 ; 
2868+  }
2869+  
2870+ }
2871+ 
0 commit comments