Use only /dev/ping. Formatting.

pull/470/head^2
Christopher Young 2016-05-26 23:31:06 -04:00
rodzic 5bafa0d8b0
commit 751d211b38
1 zmienionych plików z 8 dodań i 10 usunięć

Wyświetl plik

@ -12,14 +12,14 @@ package main
import ( import (
"bufio" "bufio"
"fmt" "fmt"
"strings"
"log" "log"
"os" "os"
"strings"
"sync" "sync"
//"sync/atomic" //"sync/atomic"
"time"
"net" "net"
"os/exec" "os/exec"
"time"
// Using forked version of tarm/serial to force Linux // Using forked version of tarm/serial to force Linux
// instead of posix code, allowing for higher baud rates // instead of posix code, allowing for higher baud rates
@ -38,9 +38,7 @@ func initPingSerial() bool {
log.Printf("Configuring Ping ADS-B\n") log.Printf("Configuring Ping ADS-B\n")
if _, err := os.Stat("/dev/ttyUSB0"); err == nil { if _, err := os.Stat("/dev/ping"); err == nil {
device = "/dev/ttyUSB0"
} else if _, err := os.Stat("/dev/ping"); err == nil {
device = "/dev/ping" device = "/dev/ping"
} else { } else {
log.Printf("No suitable Ping device found.\n") log.Printf("No suitable Ping device found.\n")
@ -150,7 +148,7 @@ func pingSerialReader() {
s := scanner.Text() s := scanner.Text()
// Trimspace removes newlines as well as whitespace // Trimspace removes newlines as well as whitespace
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
logString := fmt.Sprintf("Ping received: %s", s); logString := fmt.Sprintf("Ping received: %s", s)
log.Println(logString) log.Println(logString)
if s[0] == '*' { if s[0] == '*' {
// 1090ES report // 1090ES report
@ -169,13 +167,13 @@ func pingSerialReader() {
log.Println("Starting dump1090 network connection") log.Println("Starting dump1090 network connection")
pingNetworkConnection() pingNetworkConnection()
} }
if (len(report[0]) != 0 && dump1090Connection != nil) { if len(report[0]) != 0 && dump1090Connection != nil {
dump1090Connection.Write([]byte(report[0] + ";\r\n")) dump1090Connection.Write([]byte(report[0] + ";\r\n"))
//log.Println("Relaying 1090ES message") //log.Println("Relaying 1090ES message")
//logString := fmt.Sprintf("Relaying 1090ES: %s;", report[0]); //logString := fmt.Sprintf("Relaying 1090ES: %s;", report[0]);
//log.Println(logString) //log.Println(logString)
} }
} else if (s[0] == '+' || s[0] == '-') { } else if s[0] == '+' || s[0] == '-' {
// UAT report // UAT report
// Ping appends a signal strength and RS bit errors corrected // Ping appends a signal strength and RS bit errors corrected
// at the end of the message // at the end of the message
@ -191,7 +189,7 @@ func pingSerialReader() {
//logString = fmt.Sprintf("Relaying message, type=%d", msgtype) //logString = fmt.Sprintf("Relaying message, type=%d", msgtype)
//log.Println(logString) //log.Println(logString)
relayMessage(msgtype, o) relayMessage(msgtype, o)
} else if (o == nil) { } else if o == nil {
//log.Println("Not relaying message, o == nil") //log.Println("Not relaying message, o == nil")
} else { } else {
//log.Println("Not relaying message, msgtype == 0") //log.Println("Not relaying message, msgtype == 0")