Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GPS] Fix message rate for newer ublox devices and add some extra debugging features #10179

Merged
merged 24 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ce5156b
Use correct method to set message rate for newer ublox devices.
mmosca Jun 25, 2024
eca4674
Add some extra gps status info to status command
mmosca Jun 25, 2024
5451413
Status formatting
mmosca Jun 25, 2024
615402a
Add line feed to sparete satelites
mmosca Jun 25, 2024
19a4fc3
Cleanup
mmosca Jun 25, 2024
bab841c
UBLOX8 did not support new message and used old configuratoin interface.
mmosca Jun 26, 2024
d7e8525
use version checks to pick NAV-SAT or NAV-SIG
mmosca Jun 26, 2024
8f7fe5b
missed on of the functions when remove parameters
mmosca Jun 26, 2024
6de0900
rename args
mmosca Jun 26, 2024
b612e65
First attempt at parsing signal info
mmosca Jun 26, 2024
e59a635
Simplify message rate setup.
mmosca Jun 26, 2024
d078157
Still simpler, but 3 cases.
mmosca Jun 26, 2024
9ad5252
Disable nmed with new api for swversion >23.1
mmosca Jun 26, 2024
c9fc18f
use 0xff as no sat.
mmosca Jun 26, 2024
2bca68b
make sure to init satelites as not used
mmosca Jun 27, 2024
ceebe35
Merge remote-tracking branch 'origin/master' into mmosca-ublox-satinfo
mmosca Jul 3, 2024
6e3bf51
Fix signal info struct size for NAV_SIG devices
mmosca Jul 3, 2024
cdcbd3f
Remove some debugging info
mmosca Jul 3, 2024
db459e5
NAV_SAT parsing
mmosca Jul 3, 2024
78a6a2a
Fix test
mmosca Jul 3, 2024
7677abe
cleanup and static asserts
mmosca Jul 3, 2024
341bb4f
Add warning about old ublox versions
mmosca Jul 4, 2024
29ee096
Make UBLOX functionally equal to UBLOX7
mmosca Jul 4, 2024
017cb30
Small fixes.
mmosca Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/build/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ typedef enum {
DEBUG_POS_EST,
DEBUG_ADAPTIVE_FILTER,
DEBUG_HEADTRACKING,
DEBUG_COUNT
DEBUG_GPS,
DEBUG_COUNT // also update debugModeNames in cli.c
} debugType_e;

#ifdef SITL_BUILD
Expand Down
1 change: 1 addition & 0 deletions src/main/common/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ int tfp_nformat(void *putp, int size, void (*putf) (void *, char), const char *f
written += putchw(putp, end, putf, w, lz, bf);
break;
}
case 'i':
case 'd':{
#ifdef REQUIRE_PRINTF_LONG_SUPPORT
if (lng)
Expand Down
176 changes: 173 additions & 3 deletions src/main/fc/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,39 @@ static const char * const blackboxIncludeFlagNames[] = {
};
#endif

/* Sensor names (used in lookup tables for *_hardware settings and in status command output) */
static const char *debugModeNames[DEBUG_COUNT] = {
"NONE",
"AGL",
"FLOW_RAW",
"FLOW",
"ALWAYS",
"SAG_COMP_VOLTAGE",
"VIBE",
"CRUISE",
"REM_FLIGHT_TIME",
"SMARTAUDIO",
"ACC",
"NAV_YAW",
"PCF8574",
"DYN_GYRO_LPF",
"AUTOLEVEL",
"ALTITUDE",
"AUTOTRIM",
"AUTOTUNE",
"RATE_DYNAMICS",
"LANDING",
"POS_EST",
"ADAPTIVE_FILTER",
"HEADTRACKER",
"GPS"
};

/* Sensor names (used in lookup tables for *_hardware settings and in status
command output) */
// sync with gyroSensor_e
static const char * const gyroNames[] = { "NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160", "ICM20689", "BMI088", "ICM42605", "BMI270","LSM6DXX", "FAKE"};
static const char *const gyroNames[] = {
"NONE", "AUTO", "MPU6000", "MPU6500", "MPU9250", "BMI160",
"ICM20689", "BMI088", "ICM42605", "BMI270", "LSM6DXX", "FAKE"};

// sync this with sensors_e
static const char * const sensorTypeNames[] = {
Expand Down Expand Up @@ -253,6 +283,7 @@ static void cliPrintLine(const char *str)
cliPrintLinefeed();
}


static void cliPrintError(const char *str)
{
cliPrint("### ERROR: ");
Expand Down Expand Up @@ -3858,10 +3889,17 @@ static void cliStatus(char *cmdline)
cliPrintLinefeed();
#endif

if (featureConfigured(FEATURE_GPS) && (gpsConfig()->provider == GPS_UBLOX || gpsConfig()->provider == GPS_UBLOX7PLUS)) {
if (featureConfigured(FEATURE_GPS) && isGpsUblox()) {
cliPrint("GPS: ");
cliPrintf("HW Version: %s Proto: %d.%02d Baud: %d", getGpsHwVersion(), getGpsProtoMajorVersion(), getGpsProtoMinorVersion(), getGpsBaudrate());
if(ubloxVersionLT(15, 0)) {
cliPrintf(" (UBLOX Proto >= 15.0 required)");
}
cliPrintLinefeed();
cliPrintLinef(" SATS: %i", gpsSol.numSat);
cliPrintLinef(" HDOP: %f", (double)(gpsSol.hdop / (float)HDOP_SCALE));
cliPrintLinef(" EPH : %f m", (double)(gpsSol.eph / 100.0f));
cliPrintLinef(" EPV : %f m", (double)(gpsSol.epv / 100.0f));
//cliPrintLinef(" GNSS Capabilities: %d", gpsUbloxCapLastUpdate());
cliPrintLinef(" GNSS Capabilities:");
cliPrintLine(" GNSS Provider active/default");
Expand Down Expand Up @@ -4259,6 +4297,136 @@ typedef struct {
}
#endif

static void cliCmdDebug(char *arg)
{
UNUSED(arg);
if (debugMode != DEBUG_NONE) {
cliPrintLinef("Debug fields: [%s (%i)]", debugMode < DEBUG_COUNT ? debugModeNames[debugMode] : "unknown", debugMode);
for (int i = 0; i < DEBUG32_VALUE_COUNT; i++) {
cliPrintLinef("debug[%d] = %d", i, debug[i]);
}
} else {
cliPrintLine("Debug mode is disabled");
}
}


#if defined(USE_GPS) && defined(USE_GPS_PROTO_UBLOX)

static const char* _ubloxGetSigId(uint8_t gnssId, uint8_t sigId)
{
if(gnssId == 0) {
switch(sigId) {
case 0: return "GPS L1C/A";
case 3: return "GPS L2 CL";
case 4: return "GPS L2 CM";
case 6: return "GPS L5 I";
case 7: return "GPS L5 Q";
default: return "GPS Unknown";
}
} else if(gnssId == 1) {
switch(sigId) {
case 0: return "SBAS L1C/A";
default: return "SBAS Unknown";
}
} else if(gnssId == 2) {
switch(sigId) {
case 0: return "Galileo E1 C";
case 1: return "Galileo E1 B";
case 3: return "Galileo E5 al";
case 4: return "Galileo E5 aQ";
case 5: return "Galileo E5 bl";
case 6: return "Galileo E5 bQ";
default: return "Galileo Unknown";
}
} else if(gnssId == 3) {
switch(sigId) {
case 0: return "BeiDou B1I D1";
case 1: return "BeiDou B1I D2";
case 2: return "BeiDou B2I D1";
case 3: return "BeiDou B2I D2";
case 5: return "BeiDou B1C";
case 7: return "BeiDou B2a";
default: return "BeiDou Unknown";
}
} else if(gnssId == 5) {
switch(sigId) {
case 0: return "QZSS L1C/A";
case 1: return "QZSS L1S";
case 4: return "QZSS L2 CM";
case 5: return "QZSS L2 CL";
case 8: return "QZSS L5 I";
case 9: return "QZSS L5 Q";
default: return "QZSS Unknown";
}
} else if(gnssId == 6) {
switch(sigId) {
case 0: return "GLONASS L1 OF";
case 2: return "GLONASS L2 OF";
default: return "GLONASS Unknown";
}
}

return "Unknown GNSS/SigId";
}

static const char *_ubloxGetQuality(uint8_t quality)
{
switch(quality) {
case UBLOX_SIG_QUALITY_NOSIGNAL: return "No signal";
case UBLOX_SIG_QUALITY_SEARCHING: return "Searching signal...";
case UBLOX_SIG_QUALITY_ACQUIRED: return "Signal acquired";
case UBLOX_SIG_QUALITY_UNUSABLE: return "Signal detected but unusable";
case UBLOX_SIG_QUALITY_CODE_LOCK_TIME_SYNC: return "Code locked and time sync";
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC:
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC2:
case UBLOX_SIG_QUALITY_CODE_CARRIER_LOCK_TIME_SYNC3:
return "Code and carrier locked and time sync";
default: return "Unknown";
}
}

static void cliUbloxPrintSatelites(char *arg)
{
UNUSED(arg);
if(!isGpsUblox() /*|| !(gpsState.flags.sig || gpsState.flags.sat)*/) {
cliPrint("GPS is not UBLOX or does not report satelites.");
return;
}

cliPrintLine("UBLOX Satelites");

for(int i = 0; i < UBLOX_MAX_SIGNALS; ++i)
{
const ubx_nav_sig_info *sat = gpsGetUbloxSatelite(i);
if(sat == NULL) {
continue;
}

cliPrintLinef("satelite[%d]: %d:%d", i+1, sat->gnssId, sat->svId);
cliPrintLinef("sigId: %d (%s)", sat->sigId, _ubloxGetSigId(sat->gnssId, sat->sigId));
cliPrintLinef("signal strength: %i dbHz", sat->cno);
cliPrintLinef("quality: %i (%s)", sat->quality, _ubloxGetQuality(sat->quality));
//cliPrintLinef("Correlation: %i", sat->corrSource);
//cliPrintLinef("Iono model: %i", sat->ionoModel);
cliPrintLinef("signal flags: 0x%02X", sat->sigFlags);
switch(sat->sigFlags & UBLOX_SIG_HEALTH_MASK) {
case UBLOX_SIG_HEALTH_HEALTHY:
cliPrintLine("signal: Healthy");
break;
case UBLOX_SIG_HEALTH_UNHEALTHY:
cliPrintLine("signal: Unhealthy");
break;
case UBLOX_SIG_HEALTH_UNKNOWN:
default:
cliPrintLinef("signal: Unknown (0x%X)", sat->sigFlags & UBLOX_SIG_HEALTH_MASK);
break;
}
cliPrintLinefeed();
}
}
#endif

static void cliHelp(char *cmdline);

// should be sorted a..z for bsearch()
Expand Down Expand Up @@ -4318,6 +4486,7 @@ const clicmd_t cmdTable[] = {
CLI_COMMAND_DEF("get", "get variable value", "[name]", cliGet),
#ifdef USE_GPS
CLI_COMMAND_DEF("gpspassthrough", "passthrough gps to serial", NULL, cliGpsPassthrough),
CLI_COMMAND_DEF("gpssats", "show GPS satellites", NULL, cliUbloxPrintSatelites),
#endif
CLI_COMMAND_DEF("help", NULL, NULL, cliHelp),
#ifdef USE_LED_STRIP
Expand Down Expand Up @@ -4370,6 +4539,7 @@ const clicmd_t cmdTable[] = {
#ifdef USE_SDCARD
CLI_COMMAND_DEF("sd_info", "sdcard info", NULL, cliSdInfo),
#endif
CLI_COMMAND_DEF("showdebug", "Show debug fields.", NULL, cliCmdDebug),
CLI_COMMAND_DEF("status", "show status", NULL, cliStatus),
CLI_COMMAND_DEF("tasks", "show task stats", NULL, cliTasks),
#ifdef USE_TEMPERATURE_SENSOR
Expand Down
3 changes: 2 additions & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ tables:
values: ["NONE", "AGL", "FLOW_RAW", "FLOW", "ALWAYS", "SAG_COMP_VOLTAGE",
"VIBE", "CRUISE", "REM_FLIGHT_TIME", "SMARTAUDIO", "ACC",
"NAV_YAW", "PCF8574", "DYN_GYRO_LPF", "AUTOLEVEL", "ALTITUDE",
"AUTOTRIM", "AUTOTUNE", "RATE_DYNAMICS", "LANDING", "POS_EST", "ADAPTIVE_FILTER", "HEADTRACKER" ]
"AUTOTRIM", "AUTOTUNE", "RATE_DYNAMICS", "LANDING", "POS_EST",
"ADAPTIVE_FILTER", "HEADTRACKER", "GPS" ]
- name: aux_operator
values: ["OR", "AND"]
enum: modeActivationOperator_e
Expand Down
6 changes: 6 additions & 0 deletions src/main/io/gps_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ typedef struct {
gpsBaudRate_e baudrateIndex;
gpsBaudRate_e autoBaudrateIndex; // Driver internal use (for autoBaud)
uint8_t autoConfigStep; // Driver internal use (for autoConfig)
struct
{
uint8_t pvt : 1;
uint8_t sig : 1;
uint8_t sat : 1;
} flags;

timeMs_t lastStateSwitchMs;
timeMs_t lastLastMessageMs;
Expand Down
Loading
Loading