Merge pull request #2 from b3nn0/master

pull from b3nn0
pull/827/merge^2
VirusPilot 2019-06-15 19:09:37 +02:00 zatwierdzone przez GitHub
commit fbd9b5494c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
10 zmienionych plików z 359 dodań i 18 usunięć

Wyświetl plik

@ -12,3 +12,32 @@ nice, full featured Stratux-Flarm image that works well for europe.
* Upgraded the RaspberryPi Debian system to the latest debian packages
* Hide Weather/Towers page if UAT is disabled
* Added a simple Flarm Status page, loading the ogn-rf and ogn-decode web pages as iFrames
* Added a special "Skydemon wonky GDL90 parser" workaround to reduce Skydemons constant detection of very short disconnects (see below)
## Building the Europe Edition
Building the european Edition is practically the same as the official Stratux. More information can be found here:
http://stratux.me/
You can also buy a prebuilt unit.
Notable however: Stratux recently started selling a new "V3 Radio" for UAT reception. This radio does NOT work for flarm reception, so make sure you get the old V2 radios instead.
Also, it is highly recommended to purchase a 868 Mhz antenna for FLARM reception. The standard 978 Mhz antenna can receive some FLARM targets, but the range will be very limited.
Additionally, you will need a PC with an SD Card reader.
Download the latest image here: https://github.com/b3nn0/stratux/releases
and use an arbitrary tool to burn the image to your Micro SD Card (e.g. "Etcher", see https://www.raspberrypi.org/documentation/installation/installing-images/).
## Notes to SkyDemon Android/iOS Users
SkyDemon is probably the most popular EFB in Europe, and we are trying hard to make Stratux work as good as possible in SkyDemon, which is not always easy. Most notably, with original Stratux on a RaspberryPI 2b, you can often observe disconnects, which will show as many red dots in your track log.
Thorough analysis has shown that this is caused by a mix of
- RaspberryPI's brcmfmac wifi driver and its behaviour when UDP package delivery is slow
- Androids handling of UDP packets under load - namely the fact that it will delay them
- A wonky GDL90 implementation in SkyDemon (which is not very error tolerant, even though the UDP RFC explicitly says that applications should expect errors and work around them).
If you will suffer from these problems depends on many factors, but it is certainly possible.
The real solution would be, that SkyDemon behaves more error tolerant, but they seem to be resiliant to do so.
As of version 1.5b2-eu004, the web interface has a settings switch labeled "SkyDemon Android disconnect bug workaround". Enabling this will cause Stratux to send position reports to the EFB every 150ms instead of every second.
Experiments show that SkyDemon handles this relatively well and will show disconnects much rarer.
Note that this is an ugly hack and does not conform the GDL90 specification, but it seems to do the job for SkyDemon.

Wyświetl plik

@ -32,11 +32,11 @@ sizelimit=$(( 512*sizelimit ))
# Append one GB and truncate to size
#truncate -s 2600M $IMGNAME
qemu-img resize $IMGNAME 2500M
losetup -f
losetup /dev/loop0 $IMGNAME
partprobe /dev/loop0
e2fsck -f /dev/loop0p2
fdisk /dev/loop0 <<EOF
lo=$(losetup -f)
losetup $lo $IMGNAME
partprobe $lo
e2fsck -f ${lo}p2
fdisk $lo <<EOF
p
d
2
@ -48,9 +48,9 @@ $sector
p
w
EOF
partprobe /dev/loop0
resize2fs -p /dev/loop0p2
losetup -d /dev/loop0
partprobe $lo
resize2fs -p ${lo}p2
losetup -d $lo

Wyświetl plik

@ -29,8 +29,12 @@ rm -r /proc/*
rm -r /root/fake
# For some reason, qemu build fails unless we use a single compilation thread. Compilation takes quite long...
# It also rarely crashes with one process, so the important commands are executed multiple times. Once succeeded, execution will be very fast
# so the performance overhead should be marginal.
export GOMAXPROCS=1
go get -u github.com/kidoman/embd/embd
go get -u github.com/kidoman/embd/embd
go get -u github.com/kidoman/embd/embd
make clean
# Sometimes go build fails for some reason.. we will just try three times and hope for the best
make

Wyświetl plik

@ -0,0 +1,180 @@
#!/bin/bash
# DO NOT CALL ME DIRECTLY!
# This script is called by mk_europe_edition.sh via qemu
cd /root/stratux
# Make sure that the upgrade doesn't restart services in the chroot..
mkdir /root/fake
ln -s /bin/true /root/fake/initctl
ln -s /bin/true /root/fake/invoke-rc.d
ln -s /bin/true /root/fake/restart
ln -s /bin/true /root/fake/start
ln -s /bin/true /root/fake/stop
ln -s /bin/true /root/fake/start-stop-daemon
ln -s /bin/true /root/fake/service
ln -s /bin/true /root/fake/deb-systemd-helper
# Fake a proc FS for raspberrypi-sys-mods_20170519_armhf... Extend me as needed
mkdir -p /proc/sys/vm/
apt update
PATH=/root/fake:$PATH apt dist-upgrade --yes
PATH=/root/fake:$PATH apt install --yes libjpeg8-dev libconfig9 rpi-update hostapd isc-dhcp-server tcpdump git cmake \
libusb-1.0-0.dev build-essential mercurial build-essential autoconf fftw3 fftw3-dev libtool i2c-tools python-smbus \
python-pip python-dev python-pil python-daemon screen #libsdl1.2-dev
apt-get clean
echo y | rpi-update
systemctl enable isc-dhcp-server
systemctl enable ssh
systemctl disable ntp
systemctl disable dhcpcd
systemctl disable hciuart
rm -r /proc/*
rm -r /root/fake
# Prepare wiringpi for fancontrol and some more tools
cd /root && git clone https://github.com/WiringPi/WiringPi.git && cd WiringPi/wiringPi && make && make install
ldconfig
cd /root/stratux
cp image/bashrc.txt /root/.bashrc
source /root/.bashrc
# Prepare librtlsdr
rm -rf /root/librtlsdr
git clone https://github.com/jpoirier/librtlsdr /root/librtlsdr
mkdir -p /root/librtlsdr/build
cd /root/librtlsdr/build && cmake .. && make && make install && ldconfig
chroot mnt/ 'cd /root/librtlsdr/build && cmake ../ && make && make install && ldconfig'
# Compile stratux
cd /root/stratux
# For some reason, qemu build fails unless we use a single compilation thread. Compilation takes quite long...
export GOMAXPROCS=1
#go get -u github.com/kidoman/embd/embd
make clean
# Sometimes go build fails for some reason.. we will just try three times and hope for the best
make
make
make
make install
##### Some device setup - copy files from image directory ####
cd /root/stratux/image
#motd
cp -f motd /etc/motd
#dhcpd config
cp -f dhcpd.conf /etc/dhcp/dhcpd.conf
#hostapd config
cp -f hostapd.conf /etc/hostapd/hostapd.conf
cp -f hostapd-edimax.conf /etc/hostapd/hostapd-edimax.conf
#hostapd manager script
cp -f hostapd_manager.sh /usr/sbin/hostapd_manager.sh
chmod 755 /usr/sbin/hostapd_manager.sh
#hostapd
cp -f hostapd-edimax /usr/sbin/hostapd-edimax
chmod 755 /usr/sbin/hostapd-edimax
#remove hostapd startup scripts
rm -f /etc/rc*.d/*hostapd /etc/network/if-pre-up.d/hostapd /etc/network/if-post-down.d/hostapd /etc/init.d/hostapd /etc/default/hostapd
#interface config
cp -f interfaces /etc/network/interfaces
#custom hostapd start script
cp stratux-wifi.sh /usr/sbin/
chmod 755 /usr/sbin/stratux-wifi.sh
#SDR Serial Script
cp -f sdr-tool.sh /usr/sbin/sdr-tool.sh
chmod 755 /usr/sbin/sdr-tool.sh
#ping udev
cp -f 99-uavionix.rules /etc/udev/rules.d
#logrotate conf
cp -f logrotate.conf /etc/logrotate.conf
#fan/temp control script
#remove old script
rm -rf /usr/bin/fancontrol.py /usr/bin/fancontrol
#install new program
cp ../fancontrol /usr/bin
chmod 755 /usr/bin/fancontrol
/usr/bin/fancontrol remove
/usr/bin/fancontrol install
#isc-dhcp-server config
cp -f isc-dhcp-server /etc/default/isc-dhcp-server
#sshd config
cp -f sshd_config /etc/ssh/sshd_config
#udev config
cp -f 10-stratux.rules /etc/udev/rules.d
#stratux files
cp -f ../libdump978.so /usr/lib/libdump978.so
#debug aliases
cp -f stxAliases.txt /root/.stxAliases
#rtl-sdr setup
cp -f rtl-sdr-blacklist.conf /etc/modprobe.d/
#system tweaks
cp -f modules.txt /etc/modules
#boot settings
cp -f config.txt /boot/
cp /root/stratux/test/screen/screen.py /usr/bin/stratux-screen.py
mkdir -p /etc/stratux-screen/
cp -f /root/stratux/test/screen/stratux-logo-64x64.bmp /etc/stratux-screen/stratux-logo-64x64.bmp
cp -f /root/stratux/test/screen/CnC_Red_Alert.ttf /etc/stratux-screen/CnC_Red_Alert.ttf
#startup scripts
cp -f ../__lib__systemd__system__stratux.service /lib/systemd/system/stratux.service
cp -f ../__root__stratux-pre-start.sh /root/stratux-pre-start.sh
cp -f rc.local /etc/rc.local
#kalibrate-rtl
cd /root
rm -rf kalibrate-rtl
git clone https://github.com/steve-m/kalibrate-rtl
cd kalibrate-rtl
./bootstrap
./configure
make
make install
# TODO: do we need this?
#cd /root
#git clone https://github.com/rm-hull/ssd1306
#cd ssd1306
# Force an older version of ssd1306, since recent changes have caused a lot of compatibility issues.
#git reset --hard 232fc801b0b8bd551290e26a13122c42d628fd39
#python setup.py install
#disable serial console
sed -i /boot/cmdline.txt -e "s/console=ttyAMA0,[0-9]\+ //"
#Set the keyboard layout to US.
sed -i /etc/default/keyboard -e "/^XKBLAYOUT/s/\".*\"/\"us\"/"
# Now also prepare the update file..
cd /root/stratux/selfupdate
./makeupdate.sh

Wyświetl plik

@ -0,0 +1,97 @@
#!/bin/bash
# To run this, make sure that this is installed:
# sudo apt install --yes qemu-user-static gparted qemu-system-arm
# Run this script as root.
# Run with argument "dev" to not clone the stratux repository from remote, but instead copy this current local checkout onto the image
BASE_IMAGE_URL="http://director.downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2019-04-09/2019-04-08-raspbian-stretch-lite.zip"
IMGNAME="2019-04-08-raspbian-stretch-lite.img"
TMPDIR="$HOME/stratux-tmp"
# cd to script directory
cd "$(dirname "$0")"
SRCDIR="$(realpath $(pwd)/..)"
mkdir -p $TMPDIR
cd $TMPDIR
# Download/extract image
wget -c $BASE_IMAGE_URL -O raspbian.zip
unzip raspbian.zip
# Check where in the image the root partition begins:
sector=$(fdisk -l $IMGNAME | grep Linux | awk -F ' ' '{print $2}')
partoffset=$(( 512*sector ))
bootoffset=$(fdisk -l $IMGNAME | grep W95 | awk -F ' ' '{print $2}')
bootoffset=$(( 512*bootoffset ))
sizelimit=$(fdisk -l $IMGNAME | grep W95 | awk -F ' ' '{print $4}')
sizelimit=$(( 512*sizelimit ))
# Original image partition is too small to hold our stuff.. resize it to 2.5gb
# Append one GB and truncate to size
#truncate -s 2600M $IMGNAME
qemu-img resize $IMGNAME 2500M
lo=$(losetup -f)
losetup $lo $IMGNAME
partprobe $lo
e2fsck -f ${lo}p2
fdisk $lo <<EOF
p
d
2
n
p
2
$sector
p
w
EOF
partprobe $lo
resize2fs -p ${lo}p2
losetup -d $lo
# Mount image locally, clone our repo, install packages..
mkdir -p mnt
mount -t ext4 -o offset=$partoffset $IMGNAME mnt/
mount -t vfat -o offset=$bootoffset,sizelimit=$sizelimit $IMGNAME mnt/boot
cp $(which qemu-arm-static) mnt/usr/bin
cd mnt/root
wget https://dl.google.com/go/go1.12.4.linux-armv6l.tar.gz
tar xzf go1.12.4.linux-armv6l.tar.gz
rm go1.12.4.linux-armv6l.tar.gz
if [ "$1" == "dev" ]; then
cp -r $SRCDIR .
else
git clone --recursive https://github.com/b3nn0/stratux.git
fi
cd ../..
# Now download a specific kernel to run raspbian images in qemu and boot it..
chroot mnt qemu-arm-static /bin/bash -c /root/stratux/image/mk_europe_edition_device_setup_stretch.sh
mkdir out
# Copy the selfupdate file out of there..
cp mnt/root/stratux/work/*.sh out
rm -r mnt/root/stratux/work
umount mnt/boot
umount mnt
mv $IMGNAME out/
cd $SRCDIR
outname="stratux-$(git describe --tags --abbrev=0)-$(git log -n 1 --pretty=%H | cut -c 1-8).img"
cd $TMPDIR/out
mv $IMGNAME $outname
zip $outname.zip $outname
echo "Final image has been placed into $TMPDIR/out. Please install and test the image."

Wyświetl plik

@ -751,12 +751,31 @@ func blinkStatusLED() {
}
}
func sendAllOwnshipInfo() {
//log.Printf("Sending ownship info")
sendGDL90(makeHeartbeat(), false)
if !globalSettings.SkyDemonAndroidHack {
// Skydemon ignores these anyway - reduce data rate a bit
sendGDL90(makeStratuxHeartbeat(), false)
sendGDL90(makeStratuxStatus(), false)
sendGDL90(makeFFIDMessage(), false)
}
makeOwnshipReport()
makeOwnshipGeometricAltitudeReport()
}
func heartBeatSender() {
timerFast := time.NewTicker(150 * time.Millisecond)
timer := time.NewTicker(1 * time.Second)
timerMessageStats := time.NewTicker(2 * time.Second)
ledBlinking := false
for {
select {
case <-timerFast.C:
// Skydemon Android socket bug workaround: send ownship info every 200ms
if globalSettings.SkyDemonAndroidHack {
sendAllOwnshipInfo()
}
case <-timer.C:
// Green LED - always on during normal operation.
// Blinking when there is a critical system error (and Stratux is still running).
@ -772,12 +791,10 @@ func heartBeatSender() {
ledBlinking = true
}
sendGDL90(makeHeartbeat(), false)
sendGDL90(makeStratuxHeartbeat(), false)
sendGDL90(makeStratuxStatus(), false)
sendGDL90(makeFFIDMessage(), false)
makeOwnshipReport()
makeOwnshipGeometricAltitudeReport()
// Normal behaviour: Send ownship info once per secopnd
if !globalSettings.SkyDemonAndroidHack {
sendAllOwnshipInfo()
}
// --- debug code: traffic demo ---
// Uncomment and compile to display large number of artificial traffic targets
@ -1144,6 +1161,7 @@ type settings struct {
WiFiSecurityEnabled bool
WiFiPassphrase string
GDL90MSLAlt_Enabled bool
SkyDemonAndroidHack bool
}
type status struct {
@ -1223,6 +1241,7 @@ func defaultSettings() {
globalSettings.DeveloperMode = true
globalSettings.StaticIps = make([]string, 0)
globalSettings.GDL90MSLAlt_Enabled = true
globalSettings.SkyDemonAndroidHack = false
}
func readSettings() {

Wyświetl plik

@ -303,7 +303,9 @@ func initGPSSerial() bool {
time.Sleep(100* time.Millisecond) // pause and wait for the GPS to finish configuring itself before closing / reopening the port
if (globalStatus.GPS_detected_type == GPS_TYPE_UBX8) || (globalStatus.GPS_detected_type == GPS_TYPE_UBX9) || (globalStatus.GPS_detected_type == GPS_TYPE_UART) { // assume that any GPS connected to serial GPIO is ublox8 (RY835/6AI)
log.Printf("UBX8 device detected on USB, or GPS serial connection in use. Attempting GLONASS and Galelio configuration.\n")
if globalSettings.DEBUG {
log.Printf("UBX8/9/unknown device detected on USB, or GPS serial connection in use. Attempting GLONASS and Galelio configuration.\n")
}
cfgGnss := []byte{0x00, 0x20, 0x20, 0x06}
gps := []byte{0x00, 0x08, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01} // enable GPS with 8-16 tracking channels
sbas := []byte{0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x01, 0x01} // disable SBAS

Wyświetl plik

@ -14,8 +14,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
humanize "github.com/dustin/go-humanize"
"golang.org/x/net/websocket"
"io"
"io/ioutil"
"log"
@ -28,6 +26,9 @@ import (
"syscall"
"text/template"
"time"
humanize "github.com/dustin/go-humanize"
"golang.org/x/net/websocket"
)
type SettingMessage struct {
@ -382,6 +383,8 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
resetWiFi = true
case "GDL90MSLAlt_Enabled":
globalSettings.GDL90MSLAlt_Enabled = val.(bool)
case "SkyDemonAndroidHack":
globalSettings.SkyDemonAndroidHack = val.(bool)
default:
log.Printf("handleSettingsSetRequest:json: unrecognized key:%s\n", key)
}

Wyświetl plik

@ -8,7 +8,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.$parent.helppage = 'plates/settings-help.html';
var toggles = ['UAT_Enabled', 'ES_Enabled', 'FLARM_Enabled', 'Ping_Enabled', 'GPS_Enabled', 'IMU_Sensor_Enabled',
'BMP_Sensor_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog', 'AHRSLog', 'GDL90MSLAlt_Enabled'];
'BMP_Sensor_Enabled', 'DisplayTrafficSource', 'DEBUG', 'ReplayLog', 'AHRSLog', 'GDL90MSLAlt_Enabled', 'SkyDemonAndroidHack'];
var settings = {};
for (var i = 0; i < toggles.length; i++) {
settings[toggles[i]] = undefined;
@ -43,6 +43,7 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
$scope.DeveloperMode = settings.DeveloperMode;
$scope.GLimits = settings.GLimits;
$scope.GDL90MSLAlt_Enabled = settings.GDL90MSLAlt_Enabled;
$scope.SkyDemonAndroidHack = settings.SkyDemonAndroidHack;
$scope.StaticIps = settings.StaticIps;
$scope.WiFiSSID = settings.WiFiSSID;

Wyświetl plik

@ -109,6 +109,12 @@
<ui-switch ng-model='GDL90MSLAlt_Enabled' settings-change></ui-switch>
</div>
</div>
<div class="form-group reset-flow">
<label class="control-label col-xs-5">SkyDemon Android disconnect bug workaround</label>
<div class="col-xs-5">
<ui-switch ng-model='SkyDemonAndroidHack' settings-change></ui-switch>
</div>
</div>
</div>
</div>
<!-- WiFi Settings -->