diff --git a/linux-mpu9150 b/linux-mpu9150 index af550804..56658ffe 160000 --- a/linux-mpu9150 +++ b/linux-mpu9150 @@ -1 +1 @@ -Subproject commit af550804eff32bbef740bbaeb62eb0b4094496c7 +Subproject commit 56658ffe83c23fde04fccc8e747bf9b7c1e184ea diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 76399f99..a61611a2 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -713,20 +713,27 @@ func cpuTempMonitor() { } func updateStatus() { + if mySituation.quality == 2 { + globalStatus.GPS_solution = "DGPS (SBAS / WAAS)" + } else if mySituation.quality == 1 { + globalStatus.GPS_solution = "3D GPS" + } else if mySituation.quality == 6 { + globalStatus.GPS_solution = "Dead Reckoning" + } else { + globalStatus.GPS_solution = "No Fix" + } + if !isGPSConnected() { + mySituation.Satellites = 0 + mySituation.SatellitesSeen = 0 + mySituation.SatellitesTracked = 0 + mySituation.quality = 0 + globalStatus.GPS_solution = "Disconnected" + globalStatus.GPS_connected = false + } + globalStatus.GPS_satellites_locked = mySituation.Satellites globalStatus.GPS_satellites_seen = mySituation.SatellitesSeen globalStatus.GPS_satellites_tracked = mySituation.SatellitesTracked - if isGPSValid() { - if mySituation.quality == 2 { - globalStatus.GPS_solution = "DGPS (SBAS / WAAS)" - } else if mySituation.quality == 1 { - globalStatus.GPS_solution = "3D GPS" - } else if mySituation.quality == 6 { - globalStatus.GPS_solution = "Dead Reckoning" - } else { - globalStatus.GPS_solution = "No Fix" - } - } // Update Uptime value globalStatus.Uptime = int64(stratuxClock.Milliseconds) diff --git a/main/ry835ai.go b/main/ry835ai.go index debc5195..288fbda8 100644 --- a/main/ry835ai.go +++ b/main/ry835ai.go @@ -51,6 +51,7 @@ type SituationData struct { TrueCourse uint16 GroundSpeed uint16 LastGroundTrackTime time.Time + LastNMEAMessage time.Time // time valid NMEA message last seen mu_Attitude *sync.Mutex @@ -367,6 +368,8 @@ func processNMEALine(l string) bool { } x := strings.Split(l_valid, ",") + mySituation.LastNMEAMessage = stratuxClock.Time + if x[0] == "PUBX" { // UBX proprietary message if x[1] == "00" { // position message if len(x) < 20 { @@ -871,18 +874,19 @@ func processNMEALine(l string) bool { func gpsSerialReader() { defer serialPort.Close() - for globalSettings.GPS_Enabled && globalStatus.GPS_connected { + //for globalSettings.GPS_Enabled && globalStatus.GPS_connected { // we never break out of the 'for scanner.Scan()...' loop. Remove to keep multiple instances from running - scanner := bufio.NewScanner(serialPort) - for scanner.Scan() { - s := scanner.Text() - // log.Printf("Output: %s\n", s) - processNMEALine(s) - } - if err := scanner.Err(); err != nil { - log.Printf("reading standard input: %s\n", err.Error()) - } + scanner := bufio.NewScanner(serialPort) + for scanner.Scan() && globalStatus.GPS_connected && globalSettings.GPS_Enabled { + s := scanner.Text() + // log.Printf("Output: %s\n", s) + processNMEALine(s) } + if err := scanner.Err(); err != nil { + log.Printf("reading standard input: %s\n", err.Error()) + } + //} + log.Printf("Exiting gpsSerialReader()\n") globalStatus.GPS_connected = false } @@ -1021,6 +1025,10 @@ func attitudeReaderSender() { globalStatus.RY835AI_connected = false } +func isGPSConnected() bool { + return stratuxClock.Since(mySituation.LastNMEAMessage) < 5*time.Second +} + func isGPSValid() bool { return stratuxClock.Since(mySituation.LastFixLocalTime) < 15*time.Second }