Enhance Ping support, add RSSI and RS bit errors

pull/427/head
Ryan C. Braun 2016-02-26 11:18:22 +00:00
rodzic 6ae392af6d
commit 6594cdf5f4
7 zmienionych plików z 68 dodań i 27 usunięć

Wyświetl plik

@ -2,6 +2,5 @@
ATTRS{idProduct}=="74f0", ATTRS{idVendor}=="0403", RUN+="/sbin/modprobe -q ftdi_sio" RUN+="/bin/sh -c 'echo 0403 74f0 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'", OWNER="root", MODE="0666" NAME="ping"
# uAvionix Ping Raw
#ATTRS{idProduct}=="74f1", ATTRS{idVendor}=="0403", RUN+="/sbin/modprobe -q ftdi_sio" RUN+="/bin/sh -c 'echo 0403 74f1 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'", OWNER="root", MODE="0666" SYMLINK+="ping"
ATTRS{idProduct}=="74f1", ATTRS{idVendor}=="0403", RUN+="/sbin/modprobe -q ftdi_sio" RUN+="/bin/sh -c 'echo 0403 74f1 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'", OWNER="root", MODE="0666" NAME="ping"
ATTRS{idProduct}=="74f1", ATTRS{idVendor}=="0403", RUN+="/sbin/modprobe -q ftdi_sio" RUN+="/bin/sh -c 'echo 0403 74f1 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id'", OWNER="root", MODE="0666", SYMLINK+="ping"

Wyświetl plik

@ -436,6 +436,11 @@ func makeStratuxStatus() []byte {
msg[13] = msg[13] | (1 << 6)
}
// Ping provides ES and UAT
if globalSettings.Ping_Enabled {
msg[13] = msg[13] | (1 << 5) | (1 << 6)
}
// Valid/Enabled: GPS Enabled portion.
if globalSettings.GPS_Enabled {
msg[13] = msg[13] | (1 << 7)

Wyświetl plik

@ -16,12 +16,14 @@ import (
"log"
"os"
"sync"
"sync/atomic"
//"sync/atomic"
"time"
"net"
"os/exec"
"github.com/tarm/serial"
// Using forked version of tarm/serial to force Linux
// instead of posix code, allowing for higher baud rates
"github.com/uavionix/serial"
)
// Ping device data
@ -41,13 +43,13 @@ func initPingSerial() bool {
} else if _, err := os.Stat("/dev/ping"); err == nil {
device = "/dev/ping"
} else {
log.Printf("No suitable device found.\n")
log.Printf("No suitable Ping device found.\n")
return false
}
log.Printf("Using %s for Ping\n", device)
// Open port
//pingSerialConfig = &serial.Config{Name: device, Baud: baudrate, ReadTimeout: time.Millisecond * 2500}
// No timeout specified as Ping does not heartbeat
pingSerialConfig = &serial.Config{Name: device, Baud: baudrate}
p, err := serial.OpenPort(pingSerialConfig)
if err != nil {
@ -148,30 +150,51 @@ func pingSerialReader() {
s := scanner.Text()
// Trimspace removes newlines as well as whitespace
s = strings.TrimSpace(s)
logString := fmt.Sprintf("Print received: %s", s);
logString := fmt.Sprintf("Ping received: %s", s);
log.Println(logString)
if s[0] == '*' {
// 1090ES report
// Ping appends a signal strength at the end of the message
// e.g. *8DC01C2860C37797E9732E555B23;ss=049D;
// Remove this before forwarding to dump1090
// We currently aren't doing anything with this information
// and need to develop a scaling equation - we're using a
// log detector for power so it should have a logarithmic
// relationship. In one example, at -25dBm input (upper limit
// of RX) we saw ~0x500. At -95dBm input (lower limit of RX)
// we saw 0x370
report := strings.Split(s, ";")
//replayLog(s, MSGCLASS_DUMP1090);
if dump1090Connection == nil {
log.Println("Starting dump1090 network connection")
pingNetworkConnection()
}
if dump1090Connection != nil {
dump1090Connection.Write([]byte(s + "\r\n"))
log.Println("Relaying 1090ES message")
if (len(report[0]) != 0 && dump1090Connection != nil) {
dump1090Connection.Write([]byte(report[0] + ";\r\n"))
//log.Println("Relaying 1090ES message")
//logString := fmt.Sprintf("Relaying 1090ES: %s;", report[0]);
//log.Println(logString)
}
} else {
} else if (s[0] == '+' || s[0] == '-') {
// UAT report
// Ping appends a signal strength and RS bit errors corrected
// at the end of the message
// e.g. -08A5DFDF3907E982585F029B00040080105C3AB4BC5C240700A206000000000000003A13C82F96C80A63191F05FCB231;rs=1;ss=A2;
// We need to rescale the signal strength for interpretation by dump978,
// which expects a 0-1000 base 10 (linear?) scale
// RSSI is in hex and represents an int8 with -128 (0x80) representing an
// errored measurement. There will be some offset from actual due to loss
// in the path. In one example we measured 0x93 (-98) when injecting a
// -102dBm signal
o, msgtype := parseInput(s)
if o != nil && msgtype != 0 {
logString = fmt.Sprintf("Relaying message, type=%d", msgtype)
log.Println(logString)
//logString = fmt.Sprintf("Relaying message, type=%d", msgtype)
//log.Println(logString)
relayMessage(msgtype, o)
} else if (o == nil) {
log.Println("Not relaying message, o == nil")
//log.Println("Not relaying message, o == nil")
} else {
log.Println("Not relaying message, msgtype == 0")
//log.Println("Not relaying message, msgtype == 0")
}
}
}
@ -224,16 +247,16 @@ func pingWatcher() {
// Global settings have changed, reconfig
if globalSettings.Ping_Enabled && !globalStatus.Ping_connected {
globalStatus.Ping_connected = initPingSerial()
count := 0
//count := 0
if globalStatus.Ping_connected {
//pingWG.Add(1)
go pingNetworkRepeater()
//pingNetworkConnection()
go pingSerialReader()
// Emulate SDR count
count = 2
//count = 2
}
atomic.StoreUint32(&globalStatus.Devices, uint32(count))
//atomic.StoreUint32(&globalStatus.Devices, uint32(count))
} else if !globalSettings.Ping_Enabled {
pingShutdown()
}

Wyświetl plik

@ -482,14 +482,18 @@ func sdrWatcher() {
// true when a ReadSync call fails
if shutdownUAT {
UATDev.shutdown()
UATDev = nil
if UATDev != nil {
UATDev.shutdown()
UATDev = nil
}
shutdownUAT = false
}
// true when we get stderr output
if shutdownES {
ESDev.shutdown()
ESDev = nil
if ESDev != nil {
ESDev.shutdown()
ESDev = nil
}
shutdownES = false
}

Wyświetl plik

@ -585,9 +585,9 @@ func esListen() {
}
rdr := bufio.NewReader(inConn)
for globalSettings.ES_Enabled || globalSettings.Ping_Enabled {
log.Printf("ES enabled. Ready to read next message from dump1090\n")
//log.Printf("ES enabled. Ready to read next message from dump1090\n")
buf, err := rdr.ReadString('\n')
log.Printf("String read from dump1090\n")
//log.Printf("String read from dump1090\n")
if err != nil { // Must have disconnected?
break
}
@ -633,9 +633,9 @@ func esListen() {
// Retrieve previous information on this ICAO code.
if val, ok := traffic[icao]; ok { // if we've already seen it, copy it in to do updates
ti = val
log.Printf("Existing target %X imported for ES update\n", icao)
//log.Printf("Existing target %X imported for ES update\n", icao)
} else {
log.Printf("New target %X created for ES update\n",newTi.Icao_addr)
//log.Printf("New target %X created for ES update\n",newTi.Icao_addr)
ti.Last_seen = stratuxClock.Time // need to initialize to current stratuxClock so it doesn't get cut before we have a chance to populate a position message
ti.Last_alt = stratuxClock.Time // ditto.
ti.Icao_addr = icao
@ -647,6 +647,7 @@ func esListen() {
// generate human readable summary of message types for debug
// TO-DO: Use for ES message statistics?
/*
var s1 string
if newTi.DF == 17 {
s1 = "ADS-B"
@ -674,7 +675,8 @@ func esListen() {
if newTi.DF == 16 {
s1 = "Long Air-Air Surv."
}
log.Printf("Mode S message from icao=%X, DF=%02d, CA=%02d, TC=%02d (%s)\n", ti.Icao_addr, newTi.DF, newTi.CA, newTi.TypeCode, s1)
*/
//log.Printf("Mode S message from icao=%X, DF=%02d, CA=%02d, TC=%02d (%s)\n", ti.Icao_addr, newTi.DF, newTi.CA, newTi.TypeCode, s1)
// Altitude will be sent by dump1090 for ES ADS-B/TIS-B (DF=17 and DF=18)
// and Mode S messages (DF=0, DF = 4, and DF = 20).

Wyświetl plik

@ -44,6 +44,7 @@ function StatusCtrl($rootScope, $scope, $state, $http, $interval) {
$scope.Version = status.Version;
$scope.Build = status.Build.substr(0, 10);
$scope.Devices = status.Devices;
$scope.Ping_connected = status.Ping_connected;
$scope.Connected_Users = status.Connected_Users;
$scope.UAT_messages_last_minute = status.UAT_messages_last_minute;
// $scope.UAT_products_last_minute = JSON.stringify(status.UAT_products_last_minute);

Wyświetl plik

@ -25,10 +25,17 @@
<strong class="col-xs-5">Recent Clients:</strong>
<span class="col-xs-7">{{Connected_Users}}</span>
</div>
</div>
<div class="row">
<div class="col-sm-6 label_adj">
<strong class="col-xs-5">SDR devices:</strong>
<span class="col-xs-7">{{Devices}}</span>
</div>
<div class="col-sm-6 label_adj" ng-class="{'section_invisible': !visible_ping}">
<strong class="col-xs-5">Ping device:</strong>
<span ng-show="Ping_connected == true" class="label label-success">Connected</span>
<span ng-hide="Ping_connected == true" class="label label-danger">Disconnected</span>
</div>
</div>
<div class="separator"></div>
<div class="row">