Add signal strength and RS error to uatsummary output.

pull/238/head
Christopher Young 2016-01-29 10:30:26 -05:00
rodzic 0c614f6beb
commit 399a752025
2 zmienionych plików z 37 dodań i 14 usunięć

Wyświetl plik

@ -1,16 +1,14 @@
package main package main
import ( import (
"fmt"
"../uatparse" "../uatparse"
"os"
"bufio" "bufio"
"fmt"
"os"
"strconv" "strconv"
"strings" "strings"
) )
func main() { func main() {
reader := bufio.NewReader(os.Stdin) reader := bufio.NewReader(os.Stdin)
@ -30,13 +28,13 @@ func main() {
uatMsg.DecodeUplink() uatMsg.DecodeUplink()
/* /*
p, _ := uatMsg.GetTextReports() p, _ := uatMsg.GetTextReports()
for _, r := range p { for _, r := range p {
fmt.Printf("!!!!%s!!!!\n", r) fmt.Printf("!!!!%s!!!!\n", r)
} }
*/ */
fmt.Printf("(%f,%f) says: ", uatMsg.Lat, uatMsg.Lon) fmt.Printf("(%f,%f,%d,%d) says: ", uatMsg.Lat, uatMsg.Lon, uatMsg.RS_Err, uatMsg.SignalStrength)
types := make(map[string]int) types := make(map[string]int)
for _, uatframe := range uatMsg.Frames { for _, uatframe := range uatMsg.Frames {
if uatframe.Product_id == 413 { if uatframe.Product_id == 413 {
@ -65,9 +63,9 @@ func main() {
fmt.Printf("%s(%d) ", thisType, thisNum) fmt.Printf("%s(%d) ", thisType, thisNum)
} }
fmt.Printf("\n") fmt.Printf("\n")
// fmt.Printf("%s\n", buf) // fmt.Printf("%s\n", buf)
// k, _ := uatMsg.GetTextReports() // k, _ := uatMsg.GetTextReports()
// fmt.Printf("%v\n", k) // fmt.Printf("%v\n", k)
} }
} }
} }

Wyświetl plik

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"strconv"
"strings" "strings"
) )
@ -63,8 +64,11 @@ type UATFrame struct {
} }
type UATMsg struct { type UATMsg struct {
msg []byte // Metadata from demodulation.
decoded bool RS_Err int
SignalStrength int
msg []byte
decoded bool
// Station location for uplink frames, aircraft position for downlink frames. // Station location for uplink frames, aircraft position for downlink frames.
Lat float64 Lat float64
Lon float64 Lon float64
@ -581,6 +585,27 @@ func New(buf string) (*UATMsg, error) {
buf = strings.Trim(buf, "\r\n") // Remove newlines. buf = strings.Trim(buf, "\r\n") // Remove newlines.
x := strings.Split(buf, ";") // We want to discard everything before the first ';'. x := strings.Split(buf, ";") // We want to discard everything before the first ';'.
/*
RS_Err int
SignalStrength int
*/
ret.SignalStrength = -1
ret.RS_Err = -1
for _, f := range x[1:] {
x2 := strings.Split(f, "=")
if len(x2) != 2 {
continue
}
i, err := strconv.Atoi(x2[1])
if err != nil {
continue
}
if x2[0] == "ss" {
ret.SignalStrength = i
} else if x2[0] == "rs" {
ret.RS_Err = i
}
}
s := x[0] s := x[0]
// Only want "long" uplink messages. // Only want "long" uplink messages.