kopia lustrzana https://github.com/cyoung/stratux
commit
8f2f161b74
65
main/gpsd.go
65
main/gpsd.go
|
|
@ -8,21 +8,49 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
func getNMEAName(sv int) string {
|
||||
// GPS NMEA = PRN. GLONASS NMEA = PRN + 65. SBAS is PRN; needs to be converted to NMEA for compatiblity with GSV messages.
|
||||
if sv < 33 { // indicates GPS
|
||||
return fmt.Sprintf("G%d", sv)
|
||||
} else if sv < 65 { // indicates SBAS: WAAS, EGNOS, MSAS, etc.
|
||||
return fmt.Sprintf("S%d", sv+87) // add 87 to convert from NMEA to PRN.
|
||||
} else if sv < 97 { // GLONASS
|
||||
return fmt.Sprintf("R%d", sv-64) // subtract 64 to convert from NMEA to PRN.
|
||||
} else if (sv >= 120) && (sv < 162) { // indicates SBAS: WAAS, EGNOS, MSAS, etc.
|
||||
return fmt.Sprintf("S%d", sv)
|
||||
} else { // TO-DO: Galileo
|
||||
return fmt.Sprintf("U%d", sv)
|
||||
// Determine type of satellite based on PRN number.
|
||||
func satelliteType(prnId int) uint8 {
|
||||
// TODO: Galileo
|
||||
switch {
|
||||
case 0 < prnId && prnId <= 32:
|
||||
return SAT_TYPE_GPS
|
||||
case 32 < prnId && prnId <= 64:
|
||||
// This is actually the NMEA id range for SBAS: WAAS, EGNOS, MSAS, etc.
|
||||
return SAT_TYPE_SBAS
|
||||
case 64 < prnId && prnId <= 96:
|
||||
return SAT_TYPE_GLONASS
|
||||
case 120 <= prnId && prnId <= 138:
|
||||
return SAT_TYPE_SBAS
|
||||
default:
|
||||
return SAT_TYPE_UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
func satelliteTypeCode(satType uint8) string {
|
||||
switch satType {
|
||||
case SAT_TYPE_GPS:
|
||||
return "G"
|
||||
case SAT_TYPE_SBAS:
|
||||
return "S"
|
||||
case SAT_TYPE_GLONASS:
|
||||
return "R"
|
||||
case SAT_TYPE_UNKNOWN:
|
||||
return "U"
|
||||
default:
|
||||
return "U"
|
||||
}
|
||||
}
|
||||
|
||||
// Caller must protect Satellites with satelliteMutex.
|
||||
func isSbasInSolution() bool {
|
||||
for _, satellite := range Satellites {
|
||||
if satellite.Type == SAT_TYPE_SBAS && satellite.InSolution {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func processDEVICES(r interface{}) {
|
||||
devices := r.(*gpsd.DEVICESReport)
|
||||
log.Printf("DEVICES (%d)", len(devices.Devices))
|
||||
|
|
@ -53,12 +81,14 @@ func processTPV(r interface{}) {
|
|||
log.Printf("TPV", tpv.Device, tpv.Mode, tpv.Time, tpv.Tag)
|
||||
|
||||
mySituation.mu_GPS.Lock()
|
||||
satelliteMutex.Lock()
|
||||
|
||||
defer func() {
|
||||
if globalSettings.DEBUG {
|
||||
logSituation()
|
||||
}
|
||||
mySituation.mu_GPS.Unlock()
|
||||
satelliteMutex.Unlock()
|
||||
}()
|
||||
|
||||
// 0 = No gps data, 1 = No fix, 2 = 2D fix, 3 = 3D fix
|
||||
|
|
@ -75,7 +105,12 @@ func processTPV(r interface{}) {
|
|||
return
|
||||
}
|
||||
|
||||
mySituation.Quality = 1
|
||||
if isSbasInSolution() {
|
||||
mySituation.Quality = 2
|
||||
} else {
|
||||
mySituation.Quality = 1
|
||||
}
|
||||
|
||||
mySituation.Alt = float32(tpv.Alt) * 3.28084 // meters to feet
|
||||
mySituation.AccuracyVert = float32(tpv.Epv)
|
||||
mySituation.GPSVertVel = float32(tpv.Climb)
|
||||
|
|
@ -107,7 +142,9 @@ func processSKY(r interface{}) {
|
|||
|
||||
for _, satellite := range sky.Satellites {
|
||||
var thisSatellite SatelliteInfo
|
||||
thisSatellite.SatelliteID = getNMEAName(int(satellite.PRN)) // fmt.Sprintf("%v", satellite.PRN)
|
||||
thisSatellite.Type = satelliteType(int(satellite.PRN))
|
||||
thisSatellite.SatelliteID = fmt.Sprint(satelliteTypeCode(thisSatellite.Type), int(satellite.PRN))
|
||||
thisSatellite.Prn = uint8(satellite.PRN)
|
||||
thisSatellite.Azimuth = int16(satellite.Az)
|
||||
thisSatellite.Elevation = int16(satellite.El)
|
||||
thisSatellite.Signal = int8(satellite.Ss)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const (
|
|||
)
|
||||
|
||||
type SatelliteInfo struct {
|
||||
SatelliteNMEA uint8 // NMEA ID of the satellite. 1-32 is GPS, 33-54 is SBAS, 65-88 is Glonass.
|
||||
Prn uint8 // PRN ID of the satellite. 1-32 is GPS, 65-88 is Glonass, 120-138 is SBAS
|
||||
SatelliteID string // Formatted code indicating source and PRN code. e.g. S138==WAAS satellite 138, G2==GPS satellites 2
|
||||
Elevation int16 // Angle above local horizon, -xx to +90
|
||||
Azimuth int16 // Bearing (degrees true), 0-359
|
||||
|
|
@ -716,7 +716,7 @@ func processNMEALine(l string) (sentenceUsed bool) {
|
|||
//log.Printf("UBX,03: Satellite %s already seen. Retrieving from 'Satellites'.\n", svStr) // DEBUG
|
||||
} else { // this satellite isn't in the Satellites data structure
|
||||
thisSatellite.SatelliteID = svStr
|
||||
thisSatellite.SatelliteNMEA = uint8(sv)
|
||||
thisSatellite.Prn = uint8(sv)
|
||||
thisSatellite.Type = uint8(svType)
|
||||
//log.Printf("UBX,03: Creating new satellite %s\n", svStr) // DEBUG
|
||||
}
|
||||
|
|
@ -1125,7 +1125,7 @@ func processNMEALine(l string) (sentenceUsed bool) {
|
|||
//log.Printf("Satellite %s already seen. Retrieving from 'Satellites'.\n", svStr)
|
||||
} else { // this satellite isn't in the Satellites data structure, so create it
|
||||
thisSatellite.SatelliteID = svStr
|
||||
thisSatellite.SatelliteNMEA = uint8(sv)
|
||||
thisSatellite.Prn = uint8(sv)
|
||||
thisSatellite.Type = uint8(svType)
|
||||
//log.Printf("Creating new satellite %s from GSA message\n", svStr) // DEBUG
|
||||
}
|
||||
|
|
@ -1250,7 +1250,7 @@ func processNMEALine(l string) (sentenceUsed bool) {
|
|||
//log.Printf("Satellite %s already seen. Retrieving from 'Satellites'.\n", svStr) // DEBUG
|
||||
} else { // this satellite isn't in the Satellites data structure, so create it new
|
||||
thisSatellite.SatelliteID = svStr
|
||||
thisSatellite.SatelliteNMEA = uint8(sv)
|
||||
thisSatellite.Prn = uint8(sv)
|
||||
thisSatellite.Type = uint8(svType)
|
||||
//log.Printf("Creating new satellite %s\n", svStr) // DEBUG
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,16 +63,16 @@
|
|||
<div class="panel-body towers-page">
|
||||
<div class="row">
|
||||
<span class="col-xs-3"><strong>Satellite</strong></span>
|
||||
<!--<span class="col-xs-2 text-right"><strong>NMEA Code</strong></span>-->
|
||||
<!--<span class="col-xs-2 text-right"><strong>PRN Code</strong></span>-->
|
||||
<span class="col-xs-3 text-right"><strong>Elevation</strong></span>
|
||||
<span class="col-xs-3 text-right"><strong>Azimuth</strong></span>
|
||||
<span class="col-xs-3 text-right"><strong>Signal</strong></span>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-repeat="satellite in data_list | orderBy: 'SatelliteNMEA'">
|
||||
<div class="row" ng-repeat="satellite in data_list | orderBy: 'Prn'">
|
||||
<div class="separator"></div>
|
||||
<span class="col-xs-3">{{satellite.SatelliteID}}<span ng-show="satellite.InSolution"> ✅</span></span>
|
||||
<!--<span class="col-xs-2 text-right">{{satellite.SatelliteNMEA}}</span>-->
|
||||
<!--<span class="col-xs-2 text-right">{{satellite.Prn}}</span>-->
|
||||
<span class="col-xs-3 text-right">{{satellite.Elevation < -5 ? "---" : satellite.Elevation}}°</span>
|
||||
<span class="col-xs-3 text-right">{{satellite.Azimuth < 0 ? "---" : satellite.Azimuth}}°</span>
|
||||
<span class="col-xs-3 text-right">{{satellite.Signal < 1 ? "---" : satellite.Signal}}<span style="font-size:50%"> dB-Hz</span></span>
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) {
|
|||
};
|
||||
|
||||
function setSatellite(obj, new_satellite) {
|
||||
new_satellite.SatelliteNMEA = obj.SatelliteNMEA;
|
||||
new_satellite.Prn = obj.Prn;
|
||||
new_satellite.SatelliteID = obj.SatelliteID; // Formatted code indicating source and PRN code. e.g. S138==WAAS satellite 138, G2==GPS satellites 2
|
||||
new_satellite.Elevation = obj.Elevation; // Angle above local horizon, -xx to +90
|
||||
new_satellite.Azimuth = obj.Azimuth; // Bearing (degrees true), 0-359
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue