kopia lustrzana https://github.com/cyoung/stratux
				
				
				
			Add signal strength and RS error to uatsummary output.
							rodzic
							
								
									0c614f6beb
								
							
						
					
					
						commit
						399a752025
					
				|  | @ -1,16 +1,14 @@ | |||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"../uatparse" | ||||
| 	"os" | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| func main() { | ||||
| 	reader := bufio.NewReader(os.Stdin) | ||||
| 
 | ||||
|  | @ -30,13 +28,13 @@ func main() { | |||
| 		uatMsg.DecodeUplink() | ||||
| 
 | ||||
| 		/* | ||||
| 		p, _ := uatMsg.GetTextReports() | ||||
| 		for _, r := range p { | ||||
| 			fmt.Printf("!!!!%s!!!!\n", r) | ||||
| 		} | ||||
| 			p, _ := uatMsg.GetTextReports() | ||||
| 			for _, r := range p { | ||||
| 				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) | ||||
| 		for _, uatframe := range uatMsg.Frames { | ||||
| 			if uatframe.Product_id == 413 { | ||||
|  | @ -65,9 +63,9 @@ func main() { | |||
| 				fmt.Printf("%s(%d) ", thisType, thisNum) | ||||
| 			} | ||||
| 			fmt.Printf("\n") | ||||
| //			fmt.Printf("%s\n", buf)
 | ||||
| //			k, _ := uatMsg.GetTextReports()
 | ||||
| //			fmt.Printf("%v\n", k)
 | ||||
| 			//			fmt.Printf("%s\n", buf)
 | ||||
| 			//			k, _ := uatMsg.GetTextReports()
 | ||||
| 			//			fmt.Printf("%v\n", k)
 | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import ( | |||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"io/ioutil" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
|  | @ -63,8 +64,11 @@ type UATFrame struct { | |||
| } | ||||
| 
 | ||||
| type UATMsg struct { | ||||
| 	msg     []byte | ||||
| 	decoded bool | ||||
| 	// Metadata from demodulation.
 | ||||
| 	RS_Err         int | ||||
| 	SignalStrength int | ||||
| 	msg            []byte | ||||
| 	decoded        bool | ||||
| 	// Station location for uplink frames, aircraft position for downlink frames.
 | ||||
| 	Lat    float64 | ||||
| 	Lon    float64 | ||||
|  | @ -581,6 +585,27 @@ func New(buf string) (*UATMsg, error) { | |||
| 	buf = strings.Trim(buf, "\r\n") // Remove newlines.
 | ||||
| 	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] | ||||
| 
 | ||||
| 	// Only want "long" uplink messages.
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Christopher Young
						Christopher Young