@@ -2709,7 +2709,7 @@ boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)
2709
2709
2710
2710
return (true );
2711
2711
}
2712
- boolean SFE_UBLOX_GPS::getUdrStatus (uint16_t maxWait)
2712
+ boolean SFE_UBLOX_GPS::getEsfStatus (uint16_t maxWait)
2713
2713
{
2714
2714
// Requesting Data from the receiver
2715
2715
packetCfg.cls = UBX_CLASS_ESF;
@@ -2723,16 +2723,16 @@ boolean SFE_UBLOX_GPS::getUdrStatus(uint16_t maxWait)
2723
2723
checkUblox ();
2724
2724
2725
2725
// 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 );
2729
2729
2730
2730
// Individual Status Sensor in different function
2731
2731
return (true );
2732
2732
}
2733
2733
2734
2734
//
2735
- boolean SFE_UBLOX_GPS::getInsInfo (uint16_t maxWait)
2735
+ boolean SFE_UBLOX_GPS::getEsfInfo (uint16_t maxWait)
2736
2736
{
2737
2737
packetCfg.cls = UBX_CLASS_ESF;
2738
2738
packetCfg.id = UBX_ESF_INS;
@@ -2747,26 +2747,26 @@ boolean SFE_UBLOX_GPS::getInsInfo(uint16_t maxWait)
2747
2747
// Validity of each sensor value below
2748
2748
uint32_t validity = extractLong (0 );
2749
2749
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 ;
2756
2756
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
2760
2760
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
2764
2764
2765
2765
return (true );
2766
2766
}
2767
2767
2768
2768
//
2769
- boolean SFE_UBLOX_GPS::getExternSensMeas (uint16_t maxWait)
2769
+ boolean SFE_UBLOX_GPS::getEsfMeas (uint16_t maxWait)
2770
2770
{
2771
2771
2772
2772
packetCfg.cls = UBX_CLASS_ESF;
@@ -2787,14 +2787,23 @@ boolean SFE_UBLOX_GPS::getExternSensMeas(uint16_t maxWait)
2787
2787
uint8_t tagValid = (flags && 0x04 ) >> 3 ;
2788
2788
uint8_t numMeas = (flags && 0x1000 ) >> 15 ;
2789
2789
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
+
2790
2801
}
2791
2802
2792
2803
boolean SFE_UBLOX_GPS::getEsfRaw (uint16_t maxWait)
2793
2804
{
2794
2805
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
2798
2807
// Rate selected in UBX-CFG-MSG is not respected
2799
2808
packetCfg.cls = UBX_CLASS_ESF;
2800
2809
packetCfg.id = UBX_ESF_RAW;
@@ -2808,13 +2817,55 @@ boolean SFE_UBLOX_GPS::getEsfRaw(uint16_t maxWait)
2808
2817
2809
2818
uint8_t byteOffset = 8 ;
2810
2819
2811
- for (uint8_t i=0 ; i<imuMetric .numSens ; i++){
2820
+ for (uint8_t i=0 ; i<imuData .numSens ; i++){
2812
2821
2813
2822
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);
2817
2826
2818
2827
}
2819
2828
}
2820
2829
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