Skip to content

Commit ca82d1c

Browse files
authored
Merge pull request iNavFlight#10179 from iNavFlight/mmosca-ublox-satinfo
[GPS] Fix message rate for newer ublox devices and add some extra debugging features
2 parents a35d44b + 017cb30 commit ca82d1c

File tree

10 files changed

+508
-119
lines changed

10 files changed

+508
-119
lines changed

Diff for: src/main/build/debug.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ typedef enum {
7676
DEBUG_POS_EST,
7777
DEBUG_ADAPTIVE_FILTER,
7878
DEBUG_HEADTRACKING,
79-
DEBUG_COUNT
79+
DEBUG_GPS,
80+
DEBUG_COUNT // also update debugModeNames in cli.c
8081
} debugType_e;
8182

8283
#ifdef SITL_BUILD

Diff for: src/main/common/printf.c

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ int tfp_nformat(void *putp, int size, void (*putf) (void *, char), const char *f
162162
written += putchw(putp, end, putf, w, lz, bf);
163163
break;
164164
}
165+
case 'i':
165166
case 'd':{
166167
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
167168
if (lng)

Diff for: src/main/fc/cli.c

+173-3
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,39 @@ static const char * const blackboxIncludeFlagNames[] = {
187187
};
188188
#endif
189189

190-
/* Sensor names (used in lookup tables for *_hardware settings and in status command output) */
190+
static const char *debugModeNames[DEBUG_COUNT] = {
191+
"NONE",
192+
"AGL",
193+
"FLOW_RAW",
194+
"FLOW",
195+
"ALWAYS",
196+
"SAG_COMP_VOLTAGE",
197+
"VIBE",
198+
"CRUISE",
199+
"REM_FLIGHT_TIME",
200+
"SMARTAUDIO",
201+
"ACC",
202+
"NAV_YAW",
203+
"PCF8574",
204+
"DYN_GYRO_LPF",
205+
"AUTOLEVEL",
206+
"ALTITUDE",
207+
"AUTOTRIM",
208+
"AUTOTUNE",
209+
"RATE_DYNAMICS",
210+
"LANDING",
211+
"POS_EST",
212+
"ADAPTIVE_FILTER",
213+
"HEADTRACKER",
214+
"GPS"
215+
};
216+
217+
/* Sensor names (used in lookup tables for *_hardware settings and in status
218+
command output) */
191219
// sync with gyroSensor_e
192-
static const char * const gyroNames[] = { "NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"};
220+
static const char *const gyroNames[] = {
221+
"NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160",
222+
"ICM20689", "BMI088", "ICM42605", "BMI270", "LSM6DXX", "FAKE"};
193223

194224
// sync this with sensors_e
195225
static const char * const sensorTypeNames[] = {
@@ -253,6 +283,7 @@ static void cliPrintLine(const char *str)
253283
cliPrintLinefeed();
254284
}
255285

286+
256287
static void cliPrintError(const char *str)
257288
{
258289
cliPrint("### ERROR: ");
@@ -3858,10 +3889,17 @@ static void cliStatus(char *cmdline)
38583889
cliPrintLinefeed();
38593890
#endif
38603891

3861-
if (featureConfigured(FEATURE_GPS) && (gpsConfig()->provider == GPS_UBLOX || gpsConfig()->provider == GPS_UBLOX7PLUS)) {
3892+
if (featureConfigured(FEATURE_GPS) && isGpsUblox()) {
38623893
cliPrint("GPS: ");
38633894
cliPrintf("HW Version: %s Proto: %d.%02d Baud: %d", getGpsHwVersion(), getGpsProtoMajorVersion(), getGpsProtoMinorVersion(), getGpsBaudrate());
3895+
if(ubloxVersionLT(15, 0)) {
3896+
cliPrintf(" (UBLOX Proto >= 15.0 required)");
3897+
}
38643898
cliPrintLinefeed();
3899+
cliPrintLinef(" SATS: %i", gpsSol.numSat);
3900+
cliPrintLinef(" HDOP: %f", (double)(gpsSol.hdop / (float)HDOP_SCALE));
3901+
cliPrintLinef(" EPH : %f m", (double)(gpsSol.eph / 100.0f));
3902+
cliPrintLinef(" EPV : %f m", (double)(gpsSol.epv / 100.0f));
38653903
//cliPrintLinef(" GNSS Capabilities: %d", gpsUbloxCapLastUpdate());
38663904
cliPrintLinef(" GNSS Capabilities:");
38673905
cliPrintLine(" GNSS Provider active/default");
@@ -4259,6 +4297,136 @@ typedef struct {
42594297
}
42604298
#endif
42614299

4300+
static void cliCmdDebug(char *arg)
4301+
{
4302+
UNUSED(arg);
4303+
if (debugMode != DEBUG_NONE) {
4304+
cliPrintLinef("Debug fields: [%s (%i)]", debugMode < DEBUG_COUNT ? debugModeNames[debugMode] : "unknown", debugMode);
4305+
for (int i = 0; i < DEBUG32_VALUE_COUNT; i++) {
4306+
cliPrintLinef("debug[%d] = %d", i, debug[i]);
4307+
}
4308+
} else {
4309+
cliPrintLine("Debug mode is disabled");
4310+
}
4311+
}
4312+
4313+
4314+
#if defined(USE_GPS) && defined(USE_GPS_PROTO_UBLOX)
4315+
4316+
static const char* _ubloxGetSigId(uint8_t gnssId, uint8_t sigId)
4317+
{
4318+
if(gnssId == 0) {
4319+
switch(sigId) {
4320+
case 0: return "GPS L1C/A";
4321+
case 3: return "GPS L2 CL";
4322+
case 4: return "GPS L2 CM";
4323+
case 6: return "GPS L5 I";
4324+
case 7: return "GPS L5 Q";
4325+
default: return "GPS Unknown";
4326+
}
4327+
} else if(gnssId == 1) {
4328+
switch(sigId) {
4329+
case 0: return "SBAS L1C/A";
4330+
default: return "SBAS Unknown";
4331+
}
4332+
} else if(gnssId == 2) {
4333+
switch(sigId) {
4334+
case 0: return "Galileo E1 C";
4335+
case 1: return "Galileo E1 B";
4336+
case 3: return "Galileo E5 al";
4337+
case 4: return "Galileo E5 aQ";
4338+
case 5: return "Galileo E5 bl";
4339+
case 6: return "Galileo E5 bQ";
4340+
default: return "Galileo Unknown";
4341+
}
4342+
} else if(gnssId == 3) {
4343+
switch(sigId) {
4344+
case 0: return "BeiDou B1I D1";
4345+
case 1: return "BeiDou B1I D2";
4346+
case 2: return "BeiDou B2I D1";
4347+
case 3: return "BeiDou B2I D2";
4348+
case 5: return "BeiDou B1C";
4349+
case 7: return "BeiDou B2a";
4350+
default: return "BeiDou Unknown";
4351+
}
4352+
} else if(gnssId == 5) {
4353+
switch(sigId) {
4354+
case 0: return "QZSS L1C/A";
4355+
case 1: return "QZSS L1S";
4356+
case 4: return "QZSS L2 CM";
4357+
case 5: return "QZSS L2 CL";
4358+
case 8: return "QZSS L5 I";
4359+
case 9: return "QZSS L5 Q";
4360+
default: return "QZSS Unknown";
4361+
}
4362+
} else if(gnssId == 6) {
4363+
switch(sigId) {
4364+
case 0: return "GLONASS L1 OF";
4365+
case 2: return "GLONASS L2 OF";
4366+
default: return "GLONASS Unknown";
4367+
}
4368+
}
4369+
4370+
return "Unknown GNSS/SigId";
4371+
}
4372+
4373+
static const char *_ubloxGetQuality(uint8_t quality)
4374+
{
4375+
switch(quality) {
4376+
case UBLOX_SIG_QUALITY_NOSIGNAL: return "No signal";
4377+
case UBLOX_SIG_QUALITY_SEARCHING: return "Searching signal...";
4378+
case UBLOX_SIG_QUALITY_ACQUIRED: return "Signal acquired";
4379+
case UBLOX_SIG_QUALITY_UNUSABLE: return "Signal detected but unusable";
4380+
case UBLOX_SIG_QUALITY_CODE_LOCK_TIME_SYNC: return "Code locked and time sync";
4381+
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC:
4382+
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC2:
4383+
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC3:
4384+
return "Code and carrier locked and time sync";
4385+
default: return "Unknown";
4386+
}
4387+
}
4388+
4389+
static void cliUbloxPrintSatelites(char *arg)
4390+
{
4391+
UNUSED(arg);
4392+
if(!isGpsUblox() /*|| !(gpsState.flags.sig || gpsState.flags.sat)*/) {
4393+
cliPrint("GPS is not UBLOX or does not report satelites.");
4394+
return;
4395+
}
4396+
4397+
cliPrintLine("UBLOX Satelites");
4398+
4399+
for(int i = 0; i < UBLOX_MAX_SIGNALS; ++i)
4400+
{
4401+
const ubx_nav_sig_info *sat = gpsGetUbloxSatelite(i);
4402+
if(sat == NULL) {
4403+
continue;
4404+
}
4405+
4406+
cliPrintLinef("satelite[%d]: %d:%d", i+1, sat->gnssId, sat->svId);
4407+
cliPrintLinef("sigId: %d (%s)", sat->sigId, _ubloxGetSigId(sat->gnssId, sat->sigId));
4408+
cliPrintLinef("signal strength: %i dbHz", sat->cno);
4409+
cliPrintLinef("quality: %i (%s)", sat->quality, _ubloxGetQuality(sat->quality));
4410+
//cliPrintLinef("Correlation: %i", sat->corrSource);
4411+
//cliPrintLinef("Iono model: %i", sat->ionoModel);
4412+
cliPrintLinef("signal flags: 0x%02X", sat->sigFlags);
4413+
switch(sat->sigFlags & UBLOX_SIG_HEALTH_MASK) {
4414+
case UBLOX_SIG_HEALTH_HEALTHY:
4415+
cliPrintLine("signal: Healthy");
4416+
break;
4417+
case UBLOX_SIG_HEALTH_UNHEALTHY:
4418+
cliPrintLine("signal: Unhealthy");
4419+
break;
4420+
case UBLOX_SIG_HEALTH_UNKNOWN:
4421+
default:
4422+
cliPrintLinef("signal: Unknown (0x%X)", sat->sigFlags & UBLOX_SIG_HEALTH_MASK);
4423+
break;
4424+
}
4425+
cliPrintLinefeed();
4426+
}
4427+
}
4428+
#endif
4429+
42624430
static void cliHelp(char *cmdline);
42634431

42644432
// should be sorted a..z for bsearch()
@@ -4318,6 +4486,7 @@ const clicmd_t cmdTable[] = {
43184486
CLI_COMMAND_DEF("get", "get variable value", "[name]", cliGet),
43194487
#ifdef USE_GPS
43204488
CLI_COMMAND_DEF("gpspassthrough", "passthrough gps to serial", NULL, cliGpsPassthrough),
4489+
CLI_COMMAND_DEF("gpssats", "show GPS satellites", NULL, cliUbloxPrintSatelites),
43214490
#endif
43224491
CLI_COMMAND_DEF("help", NULL, NULL, cliHelp),
43234492
#ifdef USE_LED_STRIP
@@ -4370,6 +4539,7 @@ const clicmd_t cmdTable[] = {
43704539
#ifdef USE_SDCARD
43714540
CLI_COMMAND_DEF("sd_info", "sdcard info", NULL, cliSdInfo),
43724541
#endif
4542+
CLI_COMMAND_DEF("showdebug", "Show debug fields.", NULL, cliCmdDebug),
43734543
CLI_COMMAND_DEF("status", "show status", NULL, cliStatus),
43744544
CLI_COMMAND_DEF("tasks", "show task stats", NULL, cliTasks),
43754545
#ifdef USE_TEMPERATURE_SENSOR

Diff for: src/main/fc/settings.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ tables:
8383
values: ["NONE", "AGL", "FLOW_RAW", "FLOW", "ALWAYS", "SAG_COMP_VOLTAGE",
8484
"VIBE", "CRUISE", "REM_FLIGHT_TIME", "SMARTAUDIO", "ACC",
8585
"NAV_YAW", "PCF8574", "DYN_GYRO_LPF", "AUTOLEVEL", "ALTITUDE",
86-
"AUTOTRIM", "AUTOTUNE", "RATE_DYNAMICS", "LANDING", "POS_EST", "ADAPTIVE_FILTER", "HEADTRACKER" ]
86+
"AUTOTRIM", "AUTOTUNE", "RATE_DYNAMICS", "LANDING", "POS_EST",
87+
"ADAPTIVE_FILTER", "HEADTRACKER", "GPS" ]
8788
- name: aux_operator
8889
values: ["OR", "AND"]
8990
enum: modeActivationOperator_e

Diff for: src/main/io/gps_private.h

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ typedef struct {
5050
gpsBaudRate_e baudrateIndex;
5151
gpsBaudRate_e autoBaudrateIndex; // Driver internal use (for autoBaud)
5252
uint8_t autoConfigStep; // Driver internal use (for autoConfig)
53+
struct
54+
{
55+
uint8_t pvt : 1;
56+
uint8_t sig : 1;
57+
uint8_t sat : 1;
58+
} flags;
5359

5460
timeMs_t lastStateSwitchMs;
5561
timeMs_t lastLastMessageMs;

0 commit comments

Comments
 (0)