kopia lustrzana https://github.com/cyoung/stratux
Merge pull request #238 from AvSquirrel/gps_ui_fix
Detect disconnected GPS. Update web UI and attempt reconnect.pull/243/head
commit
41b091f78b
|
@ -1 +1 @@
|
||||||
Subproject commit af550804eff32bbef740bbaeb62eb0b4094496c7
|
Subproject commit 56658ffe83c23fde04fccc8e747bf9b7c1e184ea
|
|
@ -713,20 +713,27 @@ func cpuTempMonitor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateStatus() {
|
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_locked = mySituation.Satellites
|
||||||
globalStatus.GPS_satellites_seen = mySituation.SatellitesSeen
|
globalStatus.GPS_satellites_seen = mySituation.SatellitesSeen
|
||||||
globalStatus.GPS_satellites_tracked = mySituation.SatellitesTracked
|
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
|
// Update Uptime value
|
||||||
globalStatus.Uptime = int64(stratuxClock.Milliseconds)
|
globalStatus.Uptime = int64(stratuxClock.Milliseconds)
|
||||||
|
|
|
@ -51,6 +51,7 @@ type SituationData struct {
|
||||||
TrueCourse uint16
|
TrueCourse uint16
|
||||||
GroundSpeed uint16
|
GroundSpeed uint16
|
||||||
LastGroundTrackTime time.Time
|
LastGroundTrackTime time.Time
|
||||||
|
LastNMEAMessage time.Time // time valid NMEA message last seen
|
||||||
|
|
||||||
mu_Attitude *sync.Mutex
|
mu_Attitude *sync.Mutex
|
||||||
|
|
||||||
|
@ -367,6 +368,8 @@ func processNMEALine(l string) bool {
|
||||||
}
|
}
|
||||||
x := strings.Split(l_valid, ",")
|
x := strings.Split(l_valid, ",")
|
||||||
|
|
||||||
|
mySituation.LastNMEAMessage = stratuxClock.Time
|
||||||
|
|
||||||
if x[0] == "PUBX" { // UBX proprietary message
|
if x[0] == "PUBX" { // UBX proprietary message
|
||||||
if x[1] == "00" { // position message
|
if x[1] == "00" { // position message
|
||||||
if len(x) < 20 {
|
if len(x) < 20 {
|
||||||
|
@ -871,18 +874,19 @@ func processNMEALine(l string) bool {
|
||||||
|
|
||||||
func gpsSerialReader() {
|
func gpsSerialReader() {
|
||||||
defer serialPort.Close()
|
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)
|
scanner := bufio.NewScanner(serialPort)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() && globalStatus.GPS_connected && globalSettings.GPS_Enabled {
|
||||||
s := scanner.Text()
|
s := scanner.Text()
|
||||||
// log.Printf("Output: %s\n", s)
|
// log.Printf("Output: %s\n", s)
|
||||||
processNMEALine(s)
|
processNMEALine(s)
|
||||||
}
|
|
||||||
if err := scanner.Err(); err != nil {
|
|
||||||
log.Printf("reading standard input: %s\n", err.Error())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
log.Printf("reading standard input: %s\n", err.Error())
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
log.Printf("Exiting gpsSerialReader()\n")
|
||||||
globalStatus.GPS_connected = false
|
globalStatus.GPS_connected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,6 +1025,10 @@ func attitudeReaderSender() {
|
||||||
globalStatus.RY835AI_connected = false
|
globalStatus.RY835AI_connected = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isGPSConnected() bool {
|
||||||
|
return stratuxClock.Since(mySituation.LastNMEAMessage) < 5*time.Second
|
||||||
|
}
|
||||||
|
|
||||||
func isGPSValid() bool {
|
func isGPSValid() bool {
|
||||||
return stratuxClock.Since(mySituation.LastFixLocalTime) < 15*time.Second
|
return stratuxClock.Since(mySituation.LastFixLocalTime) < 15*time.Second
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue