diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 75777086..c427a65d 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -211,7 +211,7 @@ func makeOwnshipReport() bool { 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. if isGPSGroundTrackValid() { @@ -239,6 +239,15 @@ func makeOwnshipReport() bool { 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) return true } @@ -737,7 +746,7 @@ func printStats() { 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(" - 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) } } diff --git a/main/ry835ai.go b/main/ry835ai.go index 334c1ca2..d58d2d68 100644 --- a/main/ry835ai.go +++ b/main/ry835ai.go @@ -31,6 +31,7 @@ type SituationData struct { quality uint8 Satellites uint16 Accuracy float32 // Meters. + NACp uint8 // NACp categories are defined in AC 20-165A Alt float32 // Feet. alt_accuracy float32 LastFixLocalTime time.Time @@ -266,7 +267,7 @@ func processNMEALine(l string) bool { if err1 != nil { return false } - mySituation.quality = uint8(q) + mySituation.quality = uint8(q) // 1 = 3D GPS; 2 = DGPS (SBAS /WAAS) // Satellites. sat, err1 := strconv.Atoi(x[7]) @@ -280,7 +281,28 @@ func processNMEALine(l string) bool { if err1 != nil { 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. alt, err1 := strconv.ParseFloat(x[9], 32)