Skip to content

Commit

Permalink
Try GPS_BAUDRATE first, not only.
Browse files Browse the repository at this point in the history
  • Loading branch information
fifieldt committed Nov 2, 2024
1 parent 2954095 commit d1dcf8f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
48 changes: 18 additions & 30 deletions src/gps/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,41 +426,29 @@ bool GPS::setup()
if (!didSerialInit) {
int msglen = 0;
if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) {

// if GPS_BAUDRATE is specified in variant, skip to the specified rate.
if (GPS_BAUDRATE_FIXED) {
gnssModel = probe(GPS_BAUDRATE);
if (gnssModel == GNSS_MODEL_UNKNOWN && probeTries == 1) {
LOG_WARN("GPS probe failed, setting to %d", GPS_BAUDRATE);
return true;
} else {
++probeTries;
return false;
}
} else {
if (probeTries == 0) {
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
speedSelect = 0;
++probeTries;
}
if (probeTries == 0) {
LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]);
gnssModel = probe(serialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) {
speedSelect = 0;
++probeTries;
}
}
// Rare Serial Speeds
if (probeTries == 1) {
LOG_DEBUG("Probing for GPS at %d", rareSerialSpeeds[speedSelect]);
gnssModel = probe(rareSerialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) {
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
return true;
}
}
// Rare Serial Speeds
if (probeTries == 1) {
LOG_DEBUG("Probing for GPS at %d", rareSerialSpeeds[speedSelect]);
gnssModel = probe(rareSerialSpeeds[speedSelect]);
if (gnssModel == GNSS_MODEL_UNKNOWN) {
if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) {
LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE);
return true;
}
}
return false;
}
return false;

} else {
gnssModel = GNSS_MODEL_UNKNOWN;
}
Expand Down
5 changes: 5 additions & 0 deletions src/gps/GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ class GPS : private concurrency::OSThread
uint8_t fixType = 0; // fix type from GPGSA
#endif
private:
#if GPS_BAUDRATE_FIXED
// if GPS_BAUDRATE is specified in variant, try that first.
const int serialSpeeds[4] = {GPS_BAUDRATE, 9600, 115200, 38400};
#else
const int serialSpeeds[3] = {9600, 115200, 38400};
#endif
const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE};

uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
Expand Down

0 comments on commit d1dcf8f

Please sign in to comment.