mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
Merge pull request #3993 from iNavFlight/de_gps_autoconfig_fix
Fix always-on GPS autoconfig
This commit is contained in:
commit
d9fa9097c7
2 changed files with 43 additions and 38 deletions
|
@ -329,38 +329,40 @@ STATIC_PROTOTHREAD(gpsProtocolStateThreadMTK)
|
|||
}
|
||||
|
||||
// Send configuration commands
|
||||
// Disable all messages except GGA and RMC
|
||||
serialPrint(gpsState.gpsPort, "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
// Set Nav Threshold (the minimum speed the GPS must be moving to update the position) to 0 m/s
|
||||
serialPrint(gpsState.gpsPort, "$PMTK397,0*23\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
// SBAS/WAAS
|
||||
if (gpsState.gpsConfig->sbasMode != SBAS_NONE) {
|
||||
serialPrint(gpsState.gpsPort, "$PMTK313,1*2E\r\n"); // SBAS ON
|
||||
if (gpsState.gpsConfig->autoConfig) {
|
||||
// Disable all messages except GGA and RMC
|
||||
serialPrint(gpsState.gpsPort, "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
serialPrint(gpsState.gpsPort, "$PMTK301,2*2E\r\n"); // WAAS ON
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
}
|
||||
else {
|
||||
serialPrint(gpsState.gpsPort, "$PMTK313,0*2F\r\n"); // SBAS OFF
|
||||
// Set Nav Threshold (the minimum speed the GPS must be moving to update the position) to 0 m/s
|
||||
serialPrint(gpsState.gpsPort, "$PMTK397,0*23\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
serialPrint(gpsState.gpsPort, "$PMTK301,0*2C\r\n"); // WAAS OFF
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
// SBAS/WAAS
|
||||
if (gpsState.gpsConfig->sbasMode != SBAS_NONE) {
|
||||
serialPrint(gpsState.gpsPort, "$PMTK313,1*2E\r\n"); // SBAS ON
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
serialPrint(gpsState.gpsPort, "$PMTK301,2*2E\r\n"); // WAAS ON
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
}
|
||||
else {
|
||||
serialPrint(gpsState.gpsPort, "$PMTK313,0*2F\r\n"); // SBAS OFF
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
serialPrint(gpsState.gpsPort, "$PMTK301,0*2C\r\n"); // WAAS OFF
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
}
|
||||
|
||||
// 5Hz update, should works for most modules
|
||||
serialPrint(gpsState.gpsPort, "$PMTK220,200*2C\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
// Try set 10Hz update rate. Module will ignore it if can't support
|
||||
serialPrint(gpsState.gpsPort, "$PMTK220,100*2F\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
}
|
||||
|
||||
// 5Hz update, should works for most modules
|
||||
serialPrint(gpsState.gpsPort, "$PMTK220,200*2C\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
// Try set 10Hz update rate. Module will ignore it if can't support
|
||||
serialPrint(gpsState.gpsPort, "$PMTK220,100*2F\r\n");
|
||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||
|
||||
// Reset protocol timeout
|
||||
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
||||
|
||||
|
|
|
@ -865,21 +865,24 @@ STATIC_PROTOTHREAD(gpsProtocolStateThread)
|
|||
serialSetBaudRate(gpsState.gpsPort, baudRates[gpsToSerialBaudRate[gpsState.baudrateIndex]]);
|
||||
}
|
||||
|
||||
// Reset protocol timeout
|
||||
gpsSetProtocolTimeout(MIN(GPS_TIMEOUT, ((GPS_VERSION_RETRY_TIMES + 1) * GPS_VERSION_DETECTION_TIMEOUT_MS)));
|
||||
// Configure GPS module if enabled
|
||||
if (gpsState.gpsConfig->autoConfig) {
|
||||
// Reset protocol timeout
|
||||
gpsSetProtocolTimeout(MIN(GPS_TIMEOUT, ((GPS_VERSION_RETRY_TIMES + 1) * GPS_VERSION_DETECTION_TIMEOUT_MS)));
|
||||
|
||||
// Attempt to detect GPS hw version
|
||||
gpsState.hwVersion = 0;
|
||||
gpsState.autoConfigStep = 0;
|
||||
// Attempt to detect GPS hw version
|
||||
gpsState.hwVersion = 0;
|
||||
gpsState.autoConfigStep = 0;
|
||||
|
||||
do {
|
||||
pollVersion();
|
||||
gpsState.autoConfigStep++;
|
||||
ptWaitTimeout((gpsState.hwVersion != 0), GPS_VERSION_DETECTION_TIMEOUT_MS);
|
||||
} while(gpsState.autoConfigStep < GPS_VERSION_RETRY_TIMES && gpsState.hwVersion == 0);
|
||||
do {
|
||||
pollVersion();
|
||||
gpsState.autoConfigStep++;
|
||||
ptWaitTimeout((gpsState.hwVersion != 0), GPS_VERSION_DETECTION_TIMEOUT_MS);
|
||||
} while(gpsState.autoConfigStep < GPS_VERSION_RETRY_TIMES && gpsState.hwVersion == 0);
|
||||
|
||||
// Configure GPS
|
||||
ptSpawn(gpsConfigure);
|
||||
// Configure GPS
|
||||
ptSpawn(gpsConfigure);
|
||||
}
|
||||
|
||||
// GPS setup done, reset timeout
|
||||
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue