From 2a6beb847858ec9051eb41a7951c55f739373c42 Mon Sep 17 00:00:00 2001 From: Helno Date: Fri, 10 Nov 2017 09:46:39 -0500 Subject: [PATCH 01/21] update readme.md added additional jet tests. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ed411b9b..a020192b 100644 --- a/README.md +++ b/README.md @@ -47,3 +47,5 @@ Jet tests (high gain antennas): * Embraer ERJ 145 * Cessna Citation 501 * Lear 35 +* Rockwell B-1b +* Boeing C-17 From a3fda2aa3cf06a4dd9b2c60f9f86174e3fb8f573 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Fri, 10 Nov 2017 09:57:29 -0500 Subject: [PATCH 02/21] Turn off wireless power management, from D. DeMartini. --- image/interfaces | 1 + 1 file changed, 1 insertion(+) diff --git a/image/interfaces b/image/interfaces index 5e523d50..f99d85dc 100644 --- a/image/interfaces +++ b/image/interfaces @@ -11,6 +11,7 @@ iface wlan0 inet static address 192.168.10.1 netmask 255.255.255.0 post-up /usr/sbin/stratux-wifi.sh + wireless-power off ##################################################################### ## Custom settings not for novice users!!!!!! From bd10be4f63e93609045d577c0bce90ef508b97e5 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Fri, 17 Nov 2017 11:12:20 -0500 Subject: [PATCH 03/21] Add logrotate conf. Keep two days of logs. Run logrotate on boot. --- image/logrotate.conf | 32 ++++++++++++++++++++++++++++++++ image/mkimg.sh | 3 +++ image/rc.local | 7 +++++++ selfupdate/makeupdate.sh | 1 + selfupdate/update_footer.sh | 3 +++ 5 files changed, 46 insertions(+) create mode 100644 image/logrotate.conf diff --git a/image/logrotate.conf b/image/logrotate.conf new file mode 100644 index 00000000..073056d0 --- /dev/null +++ b/image/logrotate.conf @@ -0,0 +1,32 @@ +# see "man logrotate" for details +# rotate log files weekly +daily + +# keep 2 days worth of backlogs +rotate 2 + +# create new (empty) log files after rotating old ones +create + +# uncomment this if you want your log files compressed +compress + +# packages drop log rotation information into this directory +include /etc/logrotate.d + +# no packages own wtmp, or btmp -- we'll rotate them here +/var/log/wtmp { + missingok + monthly + create 0664 root utmp + rotate 1 +} + +/var/log/btmp { + missingok + monthly + create 0660 root utmp + rotate 1 +} + +# system-specific logs may be configured here diff --git a/image/mkimg.sh b/image/mkimg.sh index 15b3c58f..6295a20a 100755 --- a/image/mkimg.sh +++ b/image/mkimg.sh @@ -61,6 +61,9 @@ chmod 755 mnt/usr/sbin/sdr-tool.sh #ping udev cp -f 99-uavionix.rules mnt/etc/udev/rules.d +#logrotate conf +cp -f logrotate.conf mnt/etc/logrotate.conf + #fan/temp control script #remove old script rm -rf mnt/usr/bin/fancontrol.py diff --git a/image/rc.local b/image/rc.local index 56aecd79..565c09ef 100755 --- a/image/rc.local +++ b/image/rc.local @@ -17,6 +17,13 @@ if [ "$_IP" ]; then printf "My IP address is %s\n" "$_IP" fi + +# +# Rotate logs on boot. +# +/usr/sbin/logrotate /etc/logrotate.conf + + /usr/bin/stratux-screen.py start exit 0 diff --git a/selfupdate/makeupdate.sh b/selfupdate/makeupdate.sh index 01de5970..4d2387d9 100755 --- a/selfupdate/makeupdate.sh +++ b/selfupdate/makeupdate.sh @@ -39,6 +39,7 @@ cp image/stratux-wifi.sh work/bin/ cp image/rc.local work/bin/ cp image/dhcpd.conf work/bin/ cp image/interfaces work/bin/ +cp image/logrotate.conf work/bin #TODO: librtlsdr. cd work/ diff --git a/selfupdate/update_footer.sh b/selfupdate/update_footer.sh index e8d8af15..bfa67610 100755 --- a/selfupdate/update_footer.sh +++ b/selfupdate/update_footer.sh @@ -23,6 +23,9 @@ ln -fs /lib/systemd/system/stratux.service /etc/systemd/system/multi-user.target cp -f hostapd.conf /etc/hostapd/hostapd.conf cp -f hostapd-edimax.conf /etc/hostapd/hostapd-edimax.conf +#logrotate config +cp -f logrotate.conf /etc/logrotate.conf + #WiFi Hostapd ver test and hostapd.conf builder script cp -f stratux-wifi.sh /usr/sbin/ From 08f786b4b03f5f0a22c363f0f0dea5679e5e5914 Mon Sep 17 00:00:00 2001 From: Christopher Young Date: Wed, 29 Nov 2017 20:16:29 -0500 Subject: [PATCH 04/21] Add some AHRS and maintenance web calls to documents. --- notes/app-vendor-integration.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/notes/app-vendor-integration.md b/notes/app-vendor-integration.md index bd41ad64..1be50138 100644 --- a/notes/app-vendor-integration.md +++ b/notes/app-vendor-integration.md @@ -55,7 +55,7 @@ Some 1090ES transponders will send the actual registration number of the aircraf a squawk code. -### Additional data available to EFBs +### Additional data/control available to EFBs Stratux makes available a webserver to retrieve statistics which may be useful to EFBs: @@ -262,3 +262,16 @@ Subsequent update (2837120 = 2B4A80 reports a newer position, altitude increased ```json {"Icao_addr":2837120,"OnGround":false,"Lat":42.193336,"Lng":-83.92136,"Position_valid":true,"Alt":3400,"Track":9,"Speed":92,"Speed_valid":true,"Vvel":0,"Tail":"","Last_seen":"2015-12-22T21:29:22.252914555Z","Last_source":2} ``` + +* `http://192.168.10.1/calibrateAHRS` - run AHRS sensor calibration routine. Submit a blank POST to this URL. + +* `http://192.168.10.1/cageAHRS` - "level" attitude display. Submit a blank POST to this URL. + +* `http://192.168.10.1/resetGMeter` - reset G-meter to zero. Submit a blank POST to this URL. + +* `http://192.168.10.1/restart` - restart Stratux application. + +* `http://192.168.10.1/reboot` - reboot the system. + +* `http://192.168.10.1/shutdown` - shutdown the system. + From 607310af245c6c03941be31134dec298f68cae1f Mon Sep 17 00:00:00 2001 From: cyoung Date: Thu, 28 Dec 2017 16:47:38 -0500 Subject: [PATCH 05/21] Change deleted AvSquirrel/dump1090 submodule to mirror at stratux/dump1090 --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 0833484b..5e574385 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "dump1090"] path = dump1090 - url = https://github.com/AvSquirrel/dump1090 + url = https://github.com/stratux/dump1090 [submodule "goflying"] path = goflying url = https://github.com/cyoung/goflying From 31b3e83ea66c24ad6f8241f0e0edb7d0bef5cb5a Mon Sep 17 00:00:00 2001 From: cyoung Date: Thu, 28 Dec 2017 16:58:04 -0500 Subject: [PATCH 06/21] Remove old libimu.so references in selfupdate. --- selfupdate/makeupdate.sh | 1 - selfupdate/update_footer.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/selfupdate/makeupdate.sh b/selfupdate/makeupdate.sh index 4d2387d9..a3539cba 100755 --- a/selfupdate/makeupdate.sh +++ b/selfupdate/makeupdate.sh @@ -18,7 +18,6 @@ mkdir -p work/bin cp gen_gdl90 work/bin/ cp fancontrol work/bin/ cp libdump978.so work/bin/ -cp linux-mpu9150/libimu.so work/bin/ cp __lib__systemd__system__stratux.service work/bin/ cp __root__stratux-pre-start.sh work/bin/ cp dump1090/dump1090 work/bin/ diff --git a/selfupdate/update_footer.sh b/selfupdate/update_footer.sh index bfa67610..e94c8a0a 100755 --- a/selfupdate/update_footer.sh +++ b/selfupdate/update_footer.sh @@ -1,6 +1,5 @@ cp -f gen_gdl90 /usr/bin/gen_gdl90 cp -f libdump978.so /usr/lib/libdump978.so -cp -f libimu.so /usr/lib/libimu.so # Startup script. From df6f844738d2bb22c936caf283308bb39deb689d Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 09:57:00 -0500 Subject: [PATCH 07/21] Create function that tracks critical system errors and issues them only once. #692 --- main/gen_gdl90.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 06b1c203..bc518fc5 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1172,6 +1172,21 @@ func addSystemError(err error) { globalStatus.Errors = append(globalStatus.Errors, err.Error()) } +var systemErrsMutex *sync.Mutex +var systemErrs map[string]string + +func addSingleSystemErrorf(ident string, format string, a ...interface{}) { + systemErrsMutex.Lock() + if _, ok := systemErrs[ident]; !ok { + // Error hasn't been thrown yet. + systemErrs[ident] = fmt.Sprintf(format, a...) + globalStatus.Errors = append(globalStatus.Errors, systemErrs[ident]) + log.Printf("Added critical system error: %s\n", systemErrs[ident]) + } + // Do nothing on this call if the error has already been thrown. + systemErrsMutex.Unlock() +} + func saveSettings() { fd, err := os.OpenFile(configLocation, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(0644)) if err != nil { @@ -1385,6 +1400,11 @@ func main() { mySituation.muBaro = &sync.Mutex{} mySituation.muSatellite = &sync.Mutex{} + // Set up system error tracking. + systemErrsMutex = &sync.Mutex{} + systemErrs = make(map[string]string) + + // Set up status. globalStatus.Version = stratuxVersion globalStatus.Build = stratuxBuild From 033c3ca1e49eb5d2f713ee0d578ac85fa5018726 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 10:09:18 -0500 Subject: [PATCH 08/21] Use addSingleSystemErrorf() instead of tracking error prints individually. #692. --- main/gen_gdl90.go | 20 ++++++-------------- main/managementinterface.go | 6 ++---- main/network.go | 15 +++------------ main/sdr.go | 3 +-- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index bc518fc5..7c6b67e3 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1190,9 +1190,7 @@ func addSingleSystemErrorf(ident string, format string, a ...interface{}) { func saveSettings() { fd, err := os.OpenFile(configLocation, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.FileMode(0644)) if err != nil { - err_ret := fmt.Errorf("can't save settings %s: %s", configLocation, err.Error()) - addSystemError(err_ret) - log.Printf("%s\n", err_ret.Error()) + addSingleSystemErrorf("save-settings", "can't save settings %s: %s", configLocation, err.Error()) return } defer fd.Close() @@ -1240,7 +1238,6 @@ func fsWriteTest(dir string) error { func printStats() { statTimer := time.NewTicker(30 * time.Second) - diskUsageWarning := false for { <-statTimer.C var memstats runtime.MemStats @@ -1265,10 +1262,8 @@ func printStats() { log.Printf("- " + strings.Join(sensorsOutput, ", ") + "\n") } // Check if we're using more than 95% of the free space. If so, throw a warning (only once). - if !diskUsageWarning && usage.Usage() > 0.95 { - err_p := fmt.Errorf("Disk bytes used = %s (%.1f %%), Disk bytes free = %s (%.1f %%)", humanize.Bytes(usage.Used()), 100*usage.Usage(), humanize.Bytes(usage.Free()), 100*(1-usage.Usage())) - addSystemError(err_p) - diskUsageWarning = true + if usage.Usage() > 0.95 { + addSingleSystemErrorf("disk-space", "Disk bytes used = %s (%.1f %%), Disk bytes free = %s (%.1f %%)", humanize.Bytes(usage.Used()), 100*usage.Usage(), humanize.Bytes(usage.Free()), 100*(1-usage.Usage())) } logStatus() } @@ -1432,11 +1427,10 @@ func main() { if vtF < 8.0 { var err_os error if globalStatus.HardwareBuild == "FlightBox" { - err_os = fmt.Errorf("You are running an old Stratux image that can't be updated fully and is now deprecated. Visit https://www.openflightsolutions.com/flightbox/image-update-required for further information.") + addSingleSystemErrorf("deprecated-image", "You are running an old Stratux image that can't be updated fully and is now deprecated. Visit https://www.openflightsolutions.com/flightbox/image-update-required for further information.") } else { - err_os = fmt.Errorf("You are running an old Stratux image that can't be updated fully and is now deprecated. Visit http://stratux.me/ to update using the latest release image.") + addSingleSystemErrorf("deprecated-image", "You are running an old Stratux image that can't be updated fully and is now deprecated. Visit http://stratux.me/ to update using the latest release image.") } - addSystemError(err_os) } else { // Running Jessie or better. Remove some old init.d files. // This made its way in here because /etc/init.d/stratux invokes the update script, which can't delete the init.d file. @@ -1473,9 +1467,7 @@ func main() { // Duplicate log.* output to debugLog. fp, err := os.OpenFile(debugLogf, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) if err != nil { - err_log := fmt.Errorf("Failed to open '%s': %s", debugLogf, err.Error()) - addSystemError(err_log) - log.Printf("%s\n", err_log.Error()) + addSingleSystemErrorf(debugLogf, "Failed to open '%s': %s", debugLogf, err.Error()) } else { defer fp.Close() // Keep the logfile handle for later use diff --git a/main/managementinterface.go b/main/managementinterface.go index 607a8dad..6b187751 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -654,14 +654,12 @@ func defaultServer(w http.ResponseWriter, r *http.Request) { func handleroPartitionRebuild(w http.ResponseWriter, r *http.Request) { out, err := exec.Command("/usr/sbin/rebuild_ro_part.sh").Output() - var ret_err error if err != nil { - ret_err = fmt.Errorf("Rebuild RO Partition error: %s", err.Error()) + addSingleSystemErrorf("partition-rebuild", "Rebuild RO Partition error: %s", err.Error()) } else { - ret_err = fmt.Errorf("Rebuild RO Partition success: %s", out) + addSingleSystemErrorf("partition-rebuild", "Rebuild RO Partition success: %s", out) } - addSystemError(ret_err) } // https://gist.github.com/alexisrobert/982674. diff --git a/main/network.go b/main/network.go index 17b8d742..9c4aab16 100644 --- a/main/network.go +++ b/main/network.go @@ -76,19 +76,16 @@ const ( extra_hosts_file = "/etc/stratux-static-hosts.conf" ) -var dhcpLeaseFileWarning bool var dhcpLeaseDirectoryLastTest time.Time // Last time fsWriteTest() was run on the DHCP lease directory. // Read the "dhcpd.leases" file and parse out IP/hostname. func getDHCPLeases() (map[string]string, error) { // Do a write test. Even if we are able to read the file, it may be out of date because there's a fs write issue. // Only perform the test once every 5 minutes to minimize writes. - if !dhcpLeaseFileWarning && (stratuxClock.Since(dhcpLeaseDirectoryLastTest) >= 5*time.Minute) { + if stratuxClock.Since(dhcpLeaseDirectoryLastTest) >= 5*time.Minute { err := fsWriteTest(dhcp_lease_dir) if err != nil { - err_p := fmt.Errorf("Write error on '%s', your EFB may have issues receiving weather and traffic.", dhcp_lease_dir) - addSystemError(err_p) - dhcpLeaseFileWarning = true + addSingleSystemErrorf("fs-write", "Write error on '%s', your EFB may have issues receiving weather and traffic.", dhcp_lease_dir) } dhcpLeaseDirectoryLastTest = stratuxClock.Time } @@ -602,8 +599,6 @@ func networkStatsCounter() { */ func ffMonitor() { - ff_warned := false // Has a warning been issued via globalStatus.Errors? - addr := net.UDPAddr{Port: 50113, IP: net.ParseIP("0.0.0.0")} conn, err := net.ListenUDP("udp", &addr) if err != nil { @@ -637,11 +632,7 @@ func ffMonitor() { if strings.HasPrefix(s, "i-want-to-play-ffm-udp") || strings.HasPrefix(s, "i-can-play-ffm-udp") || strings.HasPrefix(s, "i-cannot-play-ffm-udp") { p.FFCrippled = true //FIXME: AHRS output doesn't need to be disabled globally, just on the ForeFlight client IPs. - if !ff_warned { - e := errors.New("Stratux is not supported by your EFB app. Your EFB app is known to regularly make changes that cause compatibility issues with Stratux. See the README for a list of apps that officially support Stratux.") - addSystemError(e) - ff_warned = true - } + addSingleSystemErrorf("ff-warn", "Stratux is not supported by your EFB app. Your EFB app is known to regularly make changes that cause compatibility issues with Stratux. See the README for a list of apps that officially support Stratux.") } outSockets[ffIpAndPort] = p netMutex.Unlock() diff --git a/main/sdr.go b/main/sdr.go index f7d57b04..e7b55a5b 100644 --- a/main/sdr.go +++ b/main/sdr.go @@ -484,8 +484,7 @@ func sdrWatcher() { } else if globalSettings.DeveloperMode { // Throw a "critical error" if developer mode is enabled. Alerts the developer that the daemon was restarted (possibly) // unexpectedly. - daemonRestartedErr := fmt.Errorf("System uptime %d seconds. Daemon was restarted.\n", info.Uptime) - addSystemError(daemonRestartedErr) + addSingleSystemErrorf("restart-warn", "System uptime %d seconds. Daemon was restarted.\n", info.Uptime) } } From c4b8216a8499793bde77494a9eb916aa9fab9c06 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 10:40:25 -0500 Subject: [PATCH 09/21] Change error prints to use addSingleSystemErrorf(). #692 --- main/gen_gdl90.go | 1 - main/managementinterface.go | 6 +++--- main/sensors.go | 35 +++++++++++++++-------------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 7c6b67e3..22d731bb 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1399,7 +1399,6 @@ func main() { systemErrsMutex = &sync.Mutex{} systemErrs = make(map[string]string) - // Set up status. globalStatus.Version = stratuxVersion globalStatus.Build = stratuxBuild diff --git a/main/managementinterface.go b/main/managementinterface.go index 6b187751..a94cbde6 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -10,6 +10,7 @@ package main import ( + "archive/zip" "encoding/hex" "encoding/json" "fmt" @@ -21,13 +22,12 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "regexp" "strings" "syscall" "text/template" "time" - "archive/zip" - "path/filepath" ) type SettingMessage struct { @@ -403,7 +403,7 @@ func handleDeleteAHRSLogFiles(w http.ResponseWriter, r *http.Request) { var fn string for _, f := range files { fn = f.Name() - if v, _ := filepath.Match("sensors_*.csv", fn) ; v { + if v, _ := filepath.Match("sensors_*.csv", fn); v { os.Remove("/var/log/" + fn) log.Printf("Deleting AHRS log file %s\n", fn) } diff --git a/main/sensors.go b/main/sensors.go index f03d32ff..d4816dcc 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -22,13 +22,13 @@ const ( ) var ( - i2cbus embd.I2CBus - myPressureReader sensors.PressureReader - myIMUReader sensors.IMUReader - cal chan (string) - analysisLogger *ahrs.AHRSLogger - ahrsCalibrating bool - logMap map[string]interface{} + i2cbus embd.I2CBus + myPressureReader sensors.PressureReader + myIMUReader sensors.IMUReader + cal chan (string) + analysisLogger *ahrs.AHRSLogger + ahrsCalibrating bool + logMap map[string]interface{} ) func initI2CSensors() { @@ -52,7 +52,6 @@ func pollSensors() { // If it's not currently connected, try connecting to IMU if globalSettings.IMU_Sensor_Enabled && !globalStatus.IMUConnected { - log.Println("AHRS Info: attempting IMU connection.") globalStatus.IMUConnected = initIMU() // I2C accel/gyro/mag. } } @@ -62,13 +61,11 @@ func initPressureSensor() (ok bool) { bmp, err := sensors.NewBMP280(&i2cbus, 100*time.Millisecond) if err == nil { myPressureReader = bmp - log.Println("AHRS Info: Successfully initialized BMP280") return true } //TODO westphae: make bmp180.go to fit bmp interface - log.Println("AHRS Info: couldn't initialize BMP280 or BMP180") return false } @@ -93,14 +90,14 @@ func tempAndPressureSender() { // Read temperature and pressure altitude. temp, err = myPressureReader.Temperature() if err != nil { - log.Printf("AHRS Error: Couldn't read temperature from sensor: %s", err) + addSingleSystemErrorf("pressure-sensor-temp-read", "AHRS Error: Couldn't read temperature from sensor: %s", err) } press, err = myPressureReader.Pressure() if err != nil { - log.Printf("AHRS Error: Couldn't read pressure from sensor: %s", err) + addSingleSystemErrorf("pressure-sensor-pressure-read", "AHRS Error: Couldn't read pressure from sensor: %s", err) failNum++ if failNum > numRetries { - log.Printf("AHRS Error: Couldn't read pressure from sensor %d times, closing BMP: %s", failNum, err) + // log.Printf("AHRS Error: Couldn't read pressure from sensor %d times, closing BMP: %s", failNum, err) myPressureReader.Close() globalStatus.BMPConnected = false // Try reconnecting a little later break @@ -129,16 +126,16 @@ func initIMU() (ok bool) { imu, err := sensors.NewMPU9250() if err == nil { myIMUReader = imu - log.Println("AHRS Info: Successfully connected MPU9250") return true } // TODO westphae: try to connect to MPU9150 or other IMUs. - log.Println("AHRS Error: couldn't initialize an IMU") return false } +//FIXME: Shoud be moved to managementinterface.go and standardized on management interface port. + func sensorAttitudeSender() { var ( t time.Time @@ -147,7 +144,6 @@ func sensorAttitudeSender() { failNum uint8 ) - log.Println("AHRS Info: initializing new Simple AHRS") s := ahrs.NewSimpleAHRS() m := ahrs.NewMeasurement() cal = make(chan (string), 1) @@ -155,9 +151,8 @@ func sensorAttitudeSender() { // Set up loggers for analysis ahrswebListener, err := ahrsweb.NewKalmanListener() if err != nil { - log.Printf("AHRS Info: couldn't start ahrswebListener: %s\n", err.Error()) + addSingleSystemErrorf("ahrs-web-start", "AHRS Info: couldn't start ahrswebListener: %s\n", err.Error()) } else { - log.Println("AHRS Info: ahrswebListener started on port 8000") defer ahrswebListener.Close() } @@ -165,7 +160,7 @@ func sensorAttitudeSender() { timer := time.NewTicker(50 * time.Millisecond) // ~20Hz update. for { // Set sensor gyro calibrations - if c, d := &globalSettings.C, &globalSettings.D; d[0]*d[0] + d[1]*d[1] + d[2]*d[2] > 0 { + if c, d := &globalSettings.C, &globalSettings.D; d[0]*d[0]+d[1]*d[1]+d[2]*d[2] > 0 { s.SetCalibrations(c, d) log.Printf("AHRS Info: IMU Calibrations read from settings: accel %6f %6f %6f; gyro %6f %6f %6f\n", c[0], c[1], c[2], d[0], d[1], d[2]) @@ -178,7 +173,7 @@ func sensorAttitudeSender() { } // Set sensor quaternion - if f := &globalSettings.SensorQuaternion; f[0]*f[0] + f[1]*f[1] + f[2]*f[2] + f[3]*f[3] > 0 { + if f := &globalSettings.SensorQuaternion; f[0]*f[0]+f[1]*f[1]+f[2]*f[2]+f[3]*f[3] > 0 { s.SetSensorQuaternion(f) } else { select { // Don't block if cal isn't receiving: only need one calibration in the queue at a time. From c5314de3f2a6ac0bce30ea7c0153f214d802b648 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 10:41:13 -0500 Subject: [PATCH 10/21] Clean up unused imports. #692 --- main/network.go | 2 -- main/sdr.go | 1 - 2 files changed, 3 deletions(-) diff --git a/main/network.go b/main/network.go index 9c4aab16..93425ae2 100644 --- a/main/network.go +++ b/main/network.go @@ -10,8 +10,6 @@ package main import ( - "errors" - "fmt" "github.com/tarm/serial" "golang.org/x/net/icmp" "golang.org/x/net/ipv4" diff --git a/main/sdr.go b/main/sdr.go index e7b55a5b..40fab42f 100644 --- a/main/sdr.go +++ b/main/sdr.go @@ -10,7 +10,6 @@ package main import ( - "fmt" "log" "os/exec" "regexp" From 36ea8c0d40f1b8e850558b674cbdbdfedaabf2fe Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 11:19:30 -0500 Subject: [PATCH 11/21] Upgrade golang version in CircleCI from 1.6 to 1.9.2. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 925e7573..f91fc261 100644 --- a/circle.yml +++ b/circle.yml @@ -5,7 +5,7 @@ machine: dependencies: pre: - - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; mkdir gopath; cd ~/; mkdir gopath; wget https://storage.googleapis.com/golang/go1.6.src.tar.gz; tar -zxvf go1.6.src.tar.gz; cd go/src; export GOROOT_BOOTSTRAP=/usr/local/go; ./make.bash; echo $PATH; echo $GOPATH; go version; env + - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; mkdir gopath; wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz; tar -zxvf go1.9.2.linux-amd64.tar.gz; go version; env override: - cd .. ; rm -rf stratux ; git clone --recursive https://github.com/cyoung/stratux ; cd stratux ; git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ; git fetch origin ; BRANCH=`echo "$CIRCLE_BRANCH" | sed 's/pull\//pr\//g'` ; git checkout $BRANCH ; make From 56ac7ee8fc394dca7dc99b9dff86881fc55deaad Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 11:38:16 -0500 Subject: [PATCH 12/21] Clean gopath on each CircleCI build. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index f91fc261..6e8a26ad 100644 --- a/circle.yml +++ b/circle.yml @@ -5,7 +5,7 @@ machine: dependencies: pre: - - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; mkdir gopath; wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz; tar -zxvf go1.9.2.linux-amd64.tar.gz; go version; env + - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; rm -rf gopath; mkdir gopath; wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz; tar -zxvf go1.9.2.linux-amd64.tar.gz; go version; env override: - cd .. ; rm -rf stratux ; git clone --recursive https://github.com/cyoung/stratux ; cd stratux ; git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ; git fetch origin ; BRANCH=`echo "$CIRCLE_BRANCH" | sed 's/pull\//pr\//g'` ; git checkout $BRANCH ; make From 0eb60143412b99c861fe98860398868e3a91c3b9 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 11:42:50 -0500 Subject: [PATCH 13/21] Install mercurial on CircleCI. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 6e8a26ad..ee477fd6 100644 --- a/circle.yml +++ b/circle.yml @@ -5,7 +5,7 @@ machine: dependencies: pre: - - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; rm -rf gopath; mkdir gopath; wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz; tar -zxvf go1.9.2.linux-amd64.tar.gz; go version; env + - sudo apt-get update; sudo apt-get install libusb-1.0-0-dev mercurial; cd ~/; git clone https://github.com/jpoirier/librtlsdr; cd librtlsdr; mkdir build; cd build; cmake ../; make; sudo make install; sudo ldconfig; cd ~/; rm -rf gopath; mkdir gopath; wget https://dl.google.com/go/go1.9.2.linux-amd64.tar.gz; tar -zxvf go1.9.2.linux-amd64.tar.gz; go version; env override: - cd .. ; rm -rf stratux ; git clone --recursive https://github.com/cyoung/stratux ; cd stratux ; git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ; git fetch origin ; BRANCH=`echo "$CIRCLE_BRANCH" | sed 's/pull\//pr\//g'` ; git checkout $BRANCH ; make From 8b806b8aad9f20626c2606c15c2e753b978bd123 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 11:58:14 -0500 Subject: [PATCH 14/21] Remove "test" directory from go get in gen_gdl90 make. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2ba09e93..7992488d 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ all: make xdump978 xdump1090 xgen_gdl90 $(PLATFORMDEPENDENT) xgen_gdl90: - go get -t -d -v ./main ./test ./godump978 ./uatparse ./sensors + go get -t -d -v ./main ./godump978 ./uatparse ./sensors go build $(BUILDINFO) -p 4 main/gen_gdl90.go main/traffic.go main/gps.go main/network.go main/managementinterface.go main/sdr.go main/ping.go main/uibroadcast.go main/monotonic.go main/datalog.go main/equations.go main/sensors.go main/cputemp.go fancontrol: From b8e149cb61036513e041399cfacfc16b9bbb6dd5 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 12:00:55 -0500 Subject: [PATCH 15/21] Cleanup. #692 --- main/gen_gdl90.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 22d731bb..d4ee896f 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1424,7 +1424,6 @@ func main() { vtF, err := strconv.ParseFloat(vtS, 32) if err == nil { if vtF < 8.0 { - var err_os error if globalStatus.HardwareBuild == "FlightBox" { addSingleSystemErrorf("deprecated-image", "You are running an old Stratux image that can't be updated fully and is now deprecated. Visit https://www.openflightsolutions.com/flightbox/image-update-required for further information.") } else { From 2abfdd11af25801f3e26e4836ff41dcb3a1926ca Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 12:04:41 -0500 Subject: [PATCH 16/21] Remove test build from CircleCI config. --- circle.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/circle.yml b/circle.yml index ee477fd6..499eb8cb 100644 --- a/circle.yml +++ b/circle.yml @@ -11,7 +11,6 @@ dependencies: test: override: - - make test deployment: production: From 95a80395fd423d651feafe05743ada547f0bc44d Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 12:14:32 -0500 Subject: [PATCH 17/21] Change CircleCI to test to build master. --- circle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/circle.yml b/circle.yml index 499eb8cb..75d1fcde 100644 --- a/circle.yml +++ b/circle.yml @@ -11,6 +11,7 @@ dependencies: test: override: + - make deployment: production: From a1ea17e7ca459b7db4aca81f4fd7f8ff3d2298e3 Mon Sep 17 00:00:00 2001 From: cyoung Date: Tue, 9 Jan 2018 16:30:28 -0500 Subject: [PATCH 18/21] Remove unnecessary debug print. --- main/sensors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/sensors.go b/main/sensors.go index d4816dcc..caa593b9 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -151,7 +151,7 @@ func sensorAttitudeSender() { // Set up loggers for analysis ahrswebListener, err := ahrsweb.NewKalmanListener() if err != nil { - addSingleSystemErrorf("ahrs-web-start", "AHRS Info: couldn't start ahrswebListener: %s\n", err.Error()) + // addSingleSystemErrorf("ahrs-web-start", "AHRS Info: couldn't start ahrswebListener: %s\n", err.Error()) } else { defer ahrswebListener.Close() } From 1a1cf2e93c902870a195f5450016db09db1b11cd Mon Sep 17 00:00:00 2001 From: cyoung Date: Wed, 17 Jan 2018 10:33:13 -0500 Subject: [PATCH 19/21] Delete /var/log/stratux* on update. --- selfupdate/update_header.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/selfupdate/update_header.sh b/selfupdate/update_header.sh index ff758008..7c912f32 100755 --- a/selfupdate/update_header.sh +++ b/selfupdate/update_header.sh @@ -3,5 +3,4 @@ rm -rf /root/stratux-update mkdir -p /root/stratux-update cd /root/stratux-update -rm -f /var/log/stratux.sqlite /var/log/stratux.sqlite-wal /var/log/stratux.sqlite-shm -rm -f /var/log/stratux.log +rm -f /var/log/stratux* From da28af53c08a8c0c6a4d004c3b3b84a89b11c3b9 Mon Sep 17 00:00:00 2001 From: cyoung Date: Wed, 17 Jan 2018 10:55:09 -0500 Subject: [PATCH 20/21] Simplify "Settings" page. Only display "Hardware" and "Diagnostic" settings when in developer mode. --- web/plates/settings.html | 222 +++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 116 deletions(-) diff --git a/web/plates/settings.html b/web/plates/settings.html index f02cb072..894ad4c8 100644 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -1,5 +1,110 @@
+
+
AHRS
+
+
+ + + +
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+
Configuration
+
+
+ +
+ + + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+
Commands
+
+ +
+ + + Click to select System Update file + + + + + + +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ + +
+
Hardware
@@ -42,8 +147,7 @@
- -
+
Diagnostics
@@ -75,120 +179,6 @@
-
-
-
AHRS
-
-
- - - -
-
-
- -
-
-
- -
- -
-
-
-
-
-
- -
-
-
-
Configuration
-
-
- -
- - - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
-
-
- -
-
-
Commands
-
- -
- - - Click to select System Update file - - - - - - -
-
-
- -
-
-
-
- -
-
-
-
-
-
- - -
-
-
-
Developer Options
-
-
-
- -
- -
-
-
-
-
-
From 6a40d979b749f59ebe391c63fc24583b8bcbaed1 Mon Sep 17 00:00:00 2001 From: cyoung Date: Wed, 17 Jan 2018 14:10:24 -0500 Subject: [PATCH 21/21] Make PPM setting a developer option. #79. --- web/plates/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/plates/settings.html b/web/plates/settings.html index 894ad4c8..d5202597 100644 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -45,7 +45,7 @@
-
+