kopia lustrzana https://github.com/cyoung/stratux
Detect disconnected GPS. Update web UI and attempt reconnect.
rodzic
bfeb190339
commit
90605ef032
|
@ -1 +1 @@
|
|||
Subproject commit af550804eff32bbef740bbaeb62eb0b4094496c7
|
||||
Subproject commit 56658ffe83c23fde04fccc8e747bf9b7c1e184ea
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue