kopia lustrzana https://github.com/cyoung/stratux
Merge.
commit
5916f00960
|
@ -211,7 +211,7 @@ func makeOwnshipReport() bool {
|
||||||
msg[12] = msg[12] | 0x0B // "Airborne" + "True Heading"
|
msg[12] = msg[12] | 0x0B // "Airborne" + "True Heading"
|
||||||
}
|
}
|
||||||
|
|
||||||
msg[13] = 0xBB // NIC and NACp.
|
msg[13] = byte(0x80 | (mySituation.NACp & 0x0F)) //Set NIC = 8 and use NACp from ry835ai.go.
|
||||||
|
|
||||||
gdSpeed := uint16(0) // 1kt resolution.
|
gdSpeed := uint16(0) // 1kt resolution.
|
||||||
if isGPSGroundTrackValid() {
|
if isGPSGroundTrackValid() {
|
||||||
|
@ -239,6 +239,15 @@ func makeOwnshipReport() bool {
|
||||||
|
|
||||||
msg[18] = 0x01 // "Light (ICAO) < 15,500 lbs"
|
msg[18] = 0x01 // "Light (ICAO) < 15,500 lbs"
|
||||||
|
|
||||||
|
// Create callsign "Stratux".
|
||||||
|
msg[19] = 0x53
|
||||||
|
msg[20] = 0x74
|
||||||
|
msg[21] = 0x72
|
||||||
|
msg[22] = 0x61
|
||||||
|
msg[23] = 0x74
|
||||||
|
msg[24] = 0x75
|
||||||
|
msg[25] = 0x78
|
||||||
|
|
||||||
sendGDL90(prepareMessage(msg), false)
|
sendGDL90(prepareMessage(msg), false)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -264,6 +273,33 @@ func makeOwnshipGeometricAltitudeReport() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
"Stratux" GDL90 message.
|
||||||
|
|
||||||
|
Message ID 0xCC.
|
||||||
|
Byte1: p p p p p p GPS AHRS
|
||||||
|
First 6 bytes are protocol version codes.
|
||||||
|
Protocol 1: GPS on/off | AHRS on/off.
|
||||||
|
*/
|
||||||
|
|
||||||
|
func makeStratuxHeartbeat() []byte {
|
||||||
|
msg := make([]byte, 2)
|
||||||
|
msg[0] = 0xCC // Message type "Stratux".
|
||||||
|
msg[1] = 0
|
||||||
|
if isGPSValid() {
|
||||||
|
msg[1] = 0x02
|
||||||
|
}
|
||||||
|
if isAHRSValid() {
|
||||||
|
msg[1] = msg[1] | 0x01
|
||||||
|
}
|
||||||
|
|
||||||
|
protocolVers := int8(1)
|
||||||
|
msg[1] = msg[1] | byte(protocolVers << 2)
|
||||||
|
|
||||||
|
return prepareMessage(msg)
|
||||||
|
}
|
||||||
|
|
||||||
func makeHeartbeat() []byte {
|
func makeHeartbeat() []byte {
|
||||||
msg := make([]byte, 7)
|
msg := make([]byte, 7)
|
||||||
// See p.10.
|
// See p.10.
|
||||||
|
@ -312,6 +348,7 @@ func heartBeatSender() {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
sendGDL90(makeHeartbeat(), false)
|
sendGDL90(makeHeartbeat(), false)
|
||||||
|
sendGDL90(makeStratuxHeartbeat(), false)
|
||||||
// sendGDL90(makeTrafficReport())
|
// sendGDL90(makeTrafficReport())
|
||||||
makeOwnshipReport()
|
makeOwnshipReport()
|
||||||
makeOwnshipGeometricAltitudeReport()
|
makeOwnshipGeometricAltitudeReport()
|
||||||
|
@ -738,7 +775,7 @@ func printStats() {
|
||||||
log.Printf("stats [up since: %s]\n", humanize.Time(timeStarted))
|
log.Printf("stats [up since: %s]\n", humanize.Time(timeStarted))
|
||||||
log.Printf(" - CPUTemp=%.02f deg C, MemStats.Alloc=%s, MemStats.Sys=%s, totalNetworkMessagesSent=%s\n", globalStatus.CPUTemp, humanize.Bytes(uint64(memstats.Alloc)), humanize.Bytes(uint64(memstats.Sys)), humanize.Comma(int64(totalNetworkMessagesSent)))
|
log.Printf(" - CPUTemp=%.02f deg C, MemStats.Alloc=%s, MemStats.Sys=%s, totalNetworkMessagesSent=%s\n", globalStatus.CPUTemp, humanize.Bytes(uint64(memstats.Alloc)), humanize.Bytes(uint64(memstats.Sys)), humanize.Comma(int64(totalNetworkMessagesSent)))
|
||||||
log.Printf(" - UAT/min %s/%s [maxSS=%.02f%%], ES/min %s/%s\n", humanize.Comma(int64(globalStatus.UAT_messages_last_minute)), humanize.Comma(int64(globalStatus.UAT_messages_max)), float64(maxSignalStrength)/10.0, humanize.Comma(int64(globalStatus.ES_messages_last_minute)), humanize.Comma(int64(globalStatus.ES_messages_max)))
|
log.Printf(" - UAT/min %s/%s [maxSS=%.02f%%], ES/min %s/%s\n", humanize.Comma(int64(globalStatus.UAT_messages_last_minute)), humanize.Comma(int64(globalStatus.UAT_messages_max)), float64(maxSignalStrength)/10.0, humanize.Comma(int64(globalStatus.ES_messages_last_minute)), humanize.Comma(int64(globalStatus.ES_messages_max)))
|
||||||
log.Printf(" - Total traffic targets tracked=%s, last GPS fix: %s\n", humanize.Comma(int64(len(seenTraffic))), humanize.Time(mySituation.LastFixLocalTime))
|
log.Printf(" - Total traffic targets tracked=%s, last GPS fix: %s, GPS solution type: %d, NACp: %d, est accuracy %.02f m\n", humanize.Comma(int64(len(seenTraffic))), humanize.Time(mySituation.LastFixLocalTime), mySituation.quality, mySituation.NACp, mySituation.Accuracy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ type SituationData struct {
|
||||||
quality uint8
|
quality uint8
|
||||||
Satellites uint16
|
Satellites uint16
|
||||||
Accuracy float32 // Meters.
|
Accuracy float32 // Meters.
|
||||||
|
NACp uint8 // NACp categories are defined in AC 20-165A
|
||||||
Alt float32 // Feet.
|
Alt float32 // Feet.
|
||||||
alt_accuracy float32
|
alt_accuracy float32
|
||||||
LastFixLocalTime time.Time
|
LastFixLocalTime time.Time
|
||||||
|
@ -266,7 +267,7 @@ func processNMEALine(l string) bool {
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mySituation.quality = uint8(q)
|
mySituation.quality = uint8(q) // 1 = 3D GPS; 2 = DGPS (SBAS /WAAS)
|
||||||
|
|
||||||
// Satellites.
|
// Satellites.
|
||||||
sat, err1 := strconv.Atoi(x[7])
|
sat, err1 := strconv.Atoi(x[7])
|
||||||
|
@ -280,7 +281,28 @@ func processNMEALine(l string) bool {
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mySituation.Accuracy = float32(hdop * 5.0) //FIXME: 5 meters ~ 1.0 HDOP?
|
if mySituation.quality == 2 {
|
||||||
|
mySituation.Accuracy = float32(hdop * 4.0) //Estimate for WAAS / DGPS solution
|
||||||
|
} else {
|
||||||
|
mySituation.Accuracy = float32(hdop * 8.0) //Estimate for 3D non-WAAS solution
|
||||||
|
}
|
||||||
|
|
||||||
|
// NACp estimate.
|
||||||
|
if mySituation.Accuracy < 3 {
|
||||||
|
mySituation.NACp = 11
|
||||||
|
} else if mySituation.Accuracy < 10 {
|
||||||
|
mySituation.NACp = 10
|
||||||
|
} else if mySituation.Accuracy < 30 {
|
||||||
|
mySituation.NACp = 9
|
||||||
|
} else if mySituation.Accuracy < 92.6 {
|
||||||
|
mySituation.NACp = 8
|
||||||
|
} else if mySituation.Accuracy < 185.2 {
|
||||||
|
mySituation.NACp = 7
|
||||||
|
} else if mySituation.Accuracy < 555.6 {
|
||||||
|
mySituation.NACp = 6
|
||||||
|
} else {
|
||||||
|
mySituation.NACp = 0
|
||||||
|
}
|
||||||
|
|
||||||
// Altitude.
|
// Altitude.
|
||||||
alt, err1 := strconv.ParseFloat(x[9], 32)
|
alt, err1 := strconv.ParseFloat(x[9], 32)
|
||||||
|
|
Ładowanie…
Reference in New Issue