Dump traffic list to log each second

pull/285/head
AvSquirrel 2016-02-23 05:51:52 +00:00
rodzic 2360f90861
commit 62fec20bee
1 zmienionych plików z 115 dodań i 103 usunięć

Wyświetl plik

@ -150,7 +150,19 @@ func sendTrafficUpdates() {
defer trafficMutex.Unlock()
cleanupOldEntries()
var msg []byte
log.Printf("List of all aircraft being tracked:\n")
log.Printf("===================================\n")
for icao, ti := range traffic { // TO-DO: Limit number of aircraft in traffic message. ForeFlight 7.5 chokes at ~1000-2000 messages depending on iDevice RAM. Practical limit likely around ~500 aircraft without filtering.
// DEBUG: Print the list of all tracked targets to the log each second
s_out, err := json.Marshal(ti)
if err != nil {
log.Printf("Error generating output: %s\n", err.Error())
} else {
log.Printf("%X => %s\n", ti.Icao_addr, string(s_out))
}
// end of debug block
ti.Age = stratuxClock.Since(ti.Last_seen).Seconds()
traffic[icao] = ti
//log.Printf("Traffic age of %X is %f seconds\n",icao,ti.Age)
@ -249,7 +261,7 @@ func makeTrafficReportMsg(ti TrafficInfo) []byte {
}
// Position containment / navigational accuracy
msg[13] = ((byte(ti.NIC) << 4) & 0xF0) | ((byte(ti.NACp) & 0x0F))
msg[13] = ((byte(ti.NIC) << 4) & 0xF0) | (byte(ti.NACp) & 0x0F)
// Horizontal velocity (speed).
@ -346,7 +358,7 @@ func parseDownlinkReport(s string, signalLevel int32) {
ti.NIC = int(frame[11] & 0x0F)
if ((msg_type == 1) || (msg_type == 3)) { // Since NACp is passed with normal UATreports, no need to use our ES hack.
if (msg_type == 1) || (msg_type == 3) { // Since NACp is passed with normal UATreports, no need to use our ES hack.
ti.NACp = int((frame[25] >> 4) & 0x0F)
}
@ -360,7 +372,7 @@ func parseDownlinkReport(s string, signalLevel int32) {
ti.TargetType = TARGET_TYPE_ADSR
} else if ti.Addr_type == 2 {
ti.TargetType = TARGET_TYPE_TISB_S
if ((ti.NIC >= 7) && (ti.Emitter_category > 0)) { // If NIC is sufficiently and emitter type is transmitted, we'll assume it's ADS-R.
if (ti.NIC >= 7) && (ti.Emitter_category > 0) { // If NIC is sufficiently and emitter type is transmitted, we'll assume it's ADS-R.
ti.TargetType = TARGET_TYPE_ADSR
}
}
@ -673,7 +685,7 @@ func esListen() {
ti.Speed_valid = true
ti.Last_speed = stratuxClock.Time // only update "last seen" data on position updates
}
} else if (((newTi.DF == 17) || (newTi.DF == 18)) && (newTi.TypeCode == 19)) { // invalid speed on velocity message only
} else if ((newTi.DF == 17) || (newTi.DF == 18)) && (newTi.TypeCode == 19) { // invalid speed on velocity message only
ti.Speed_valid = false
}
@ -712,7 +724,7 @@ func esListen() {
}
ti.NIC = nic
if ((ti.NACp < 7) && (ti.NACp < ti.NIC)) {
if (ti.NACp < 7) && (ti.NACp < ti.NIC) {
ti.NACp = ti.NIC // initialize to NIC, since NIC is sent with every position report, and not all emitters report NACp.
}
}
@ -734,10 +746,10 @@ func esListen() {
if newTi.CA == 6 {
ti.TargetType = TARGET_TYPE_ADSR
ti.Addr_type = 2
} else if (newTi.CA == 2) { // 2 = TIS-B with ICAO address, 5 = TIS-B without ICAO address
} else if newTi.CA == 2 { // 2 = TIS-B with ICAO address, 5 = TIS-B without ICAO address
ti.TargetType = TARGET_TYPE_TISB
ti.Addr_type = 2
} else if (newTi.CA == 5) {
} else if newTi.CA == 5 {
ti.TargetType = TARGET_TYPE_TISB
ti.Addr_type = 3
}