Merge branch 'master' into rework

pull/13/head^2
Joseph Poirier 2015-08-15 12:39:34 -05:00
commit 3e95d069c4
1 zmienionych plików z 37 dodań i 39 usunięć

Wyświetl plik

@ -3,12 +3,13 @@ package main
import (
"bufio"
"encoding/hex"
"encoding/json"
"fmt"
"net"
"os"
"runtime"
"strings"
"time"
"encoding/json"
)
// http://www.faa.gov/nextgen/programs/adsb/wsa/media/GDL90_Public_ICD_RevA.PDF
@ -154,12 +155,11 @@ func makeOwnshipReport() bool {
msg[9] = tmp[1] // Longitude.
msg[10] = tmp[2] // Longitude.
//TODO: 0xFFF "invalid altitude."
//FIXME: This is **PRESSURE ALTITUDE**
//TODO: 0xFFF "invalid altitude."
//FIXME: This is **PRESSURE ALTITUDE**
alt := uint16(myGPS.alt)
alt = (alt + 1000)/25
alt = (alt + 1000) / 25
alt = alt & 0xFFF // Should fit in 12 bits.
msg[11] = byte((alt & 0xFF0) >> 4) // Altitude.
@ -184,10 +184,9 @@ func makeOwnshipReport() bool {
verticalVelocity := int16(1000 / 64) // ft/min. 64 ft/min resolution.
//TODO: 0x800 = no information available.
verticalVelocity = verticalVelocity & 0x0FFF // Should fit in 12 bits.
msg[15] = msg[15] | byte((verticalVelocity & 0x0F00) >> 8)
msg[15] = msg[15] | byte((verticalVelocity&0x0F00)>>8)
msg[16] = byte(verticalVelocity & 0xFF)
// Showing magnetic (corrected) on ForeFlight. Needs to be True Heading.
groundTrack := uint16(0)
if isGPSGroundTrackValid() {
@ -212,7 +211,7 @@ func makeOwnshipGeometricAltitudeReport() bool {
// See p.28.
msg[0] = 0x0B // Message type "Ownship Geo Alt".
alt := int16(myGPS.alt)
alt = alt/5
alt = alt / 5
msg[1] = byte(alt >> 8) // Altitude.
msg[2] = byte(alt & 0x00FF) // Altitude.
@ -273,7 +272,7 @@ func relayMessage(msgtype uint16, msg []byte) {
func heartBeatSender() {
for {
outConn.Write(makeHeartbeat())
// outConn.Write(makeTrafficReport())
// outConn.Write(makeTrafficReport())
makeOwnshipReport()
makeOwnshipGeometricAltitudeReport()
outConn.Write(makeInitializationMessage())
@ -307,7 +306,6 @@ func updateStatus() {
}
}
func parseInput(buf string) ([]byte, uint16) {
x := strings.Split(buf, ";") // Discard everything after the first ';'.
if len(x) == 0 {
@ -428,7 +426,6 @@ func managementInterface() {
}
}
func defaultSettings() {
globalSettings.UAT_Enabled = true //TODO
globalSettings.ES_Enabled = false //TODO
@ -462,7 +459,7 @@ func readSettings() {
}
func saveSettings() {
fd, err := os.OpenFile(configLocation, os.O_CREATE | os.O_WRONLY, os.FileMode(0644))
fd, err := os.OpenFile(configLocation, os.O_CREATE|os.O_WRONLY, os.FileMode(0644))
defer fd.Close()
if err != nil {
fmt.Printf("can't save settings %s: %s\n", configLocation, err.Error())
@ -474,6 +471,7 @@ func saveSettings() {
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU()) // redundant with Go v1.5+ compiler
MsgLog = make([]msg, 0)
crcInit() // Initialize CRC16 table.