mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 17:55:28 +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
|
// Send configuration commands
|
||||||
// Disable all messages except GGA and RMC
|
if (gpsState.gpsConfig->autoConfig) {
|
||||||
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");
|
// Disable all messages except GGA and RMC
|
||||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
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");
|
||||||
|
|
||||||
// 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
|
|
||||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||||
|
|
||||||
serialPrint(gpsState.gpsPort, "$PMTK301,2*2E\r\n"); // WAAS ON
|
// Set Nav Threshold (the minimum speed the GPS must be moving to update the position) to 0 m/s
|
||||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
serialPrint(gpsState.gpsPort, "$PMTK397,0*23\r\n");
|
||||||
}
|
|
||||||
else {
|
|
||||||
serialPrint(gpsState.gpsPort, "$PMTK313,0*2F\r\n"); // SBAS OFF
|
|
||||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
||||||
|
|
||||||
serialPrint(gpsState.gpsPort, "$PMTK301,0*2C\r\n"); // WAAS OFF
|
// SBAS/WAAS
|
||||||
ptWait(isSerialTransmitBufferEmpty(gpsState.gpsPort));
|
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
|
// Reset protocol timeout
|
||||||
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
||||||
|
|
||||||
|
|
|
@ -865,21 +865,24 @@ STATIC_PROTOTHREAD(gpsProtocolStateThread)
|
||||||
serialSetBaudRate(gpsState.gpsPort, baudRates[gpsToSerialBaudRate[gpsState.baudrateIndex]]);
|
serialSetBaudRate(gpsState.gpsPort, baudRates[gpsToSerialBaudRate[gpsState.baudrateIndex]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset protocol timeout
|
// Configure GPS module if enabled
|
||||||
gpsSetProtocolTimeout(MIN(GPS_TIMEOUT, ((GPS_VERSION_RETRY_TIMES + 1) * GPS_VERSION_DETECTION_TIMEOUT_MS)));
|
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
|
// Attempt to detect GPS hw version
|
||||||
gpsState.hwVersion = 0;
|
gpsState.hwVersion = 0;
|
||||||
gpsState.autoConfigStep = 0;
|
gpsState.autoConfigStep = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pollVersion();
|
pollVersion();
|
||||||
gpsState.autoConfigStep++;
|
gpsState.autoConfigStep++;
|
||||||
ptWaitTimeout((gpsState.hwVersion != 0), GPS_VERSION_DETECTION_TIMEOUT_MS);
|
ptWaitTimeout((gpsState.hwVersion != 0), GPS_VERSION_DETECTION_TIMEOUT_MS);
|
||||||
} while(gpsState.autoConfigStep < GPS_VERSION_RETRY_TIMES && gpsState.hwVersion == 0);
|
} while(gpsState.autoConfigStep < GPS_VERSION_RETRY_TIMES && gpsState.hwVersion == 0);
|
||||||
|
|
||||||
// Configure GPS
|
// Configure GPS
|
||||||
ptSpawn(gpsConfigure);
|
ptSpawn(gpsConfigure);
|
||||||
|
}
|
||||||
|
|
||||||
// GPS setup done, reset timeout
|
// GPS setup done, reset timeout
|
||||||
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
gpsSetProtocolTimeout(GPS_TIMEOUT);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue