From 3546a0b922988fcc0182f691d08912d96ac03918 Mon Sep 17 00:00:00 2001 From: "Chadwick, Michael" Date: Mon, 22 Mar 2021 00:08:05 -0400 Subject: [PATCH 1/3] Update piaware container Adding a dockerfile and a new services run script. This adds a single command line argument to Dump1090, the "--gnss" argument which outputs geometric altitude vs. barometric altitude. --- piaware/Dockerfile | 9 ++++++++ piaware/run | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 piaware/Dockerfile create mode 100644 piaware/run diff --git a/piaware/Dockerfile b/piaware/Dockerfile new file mode 100644 index 0000000..6c4731e --- /dev/null +++ b/piaware/Dockerfile @@ -0,0 +1,9 @@ +FROM mikenye/piaware:latest + +ADD run /etc/services.d/dump1090/ + +EXPOSE 80/tcp 30003/tcp 30005/tcp 30105/tcp 30978/tcp 30979/tcp + +ENTRYPOINT [ "/init" ] + +HEALTHCHECK --start-period=7200s --interval=600s CMD /scripts/healthcheck.sh \ No newline at end of file diff --git a/piaware/run b/piaware/run new file mode 100644 index 0000000..f2ddc55 --- /dev/null +++ b/piaware/run @@ -0,0 +1,51 @@ +#!/usr/bin/with-contenv bash +# shellcheck shell=bash +set -eo pipefail + +mkdir -p /run/dump1090-fa + +DUMP1090_BIN="/usr/local/bin/dump1090" + +# Global settings +DUMP1090_CMD=("--quiet") +DUMP1090_CMD+=("--lat" "$LAT") +DUMP1090_CMD+=("--lon" "$LONG") +DUMP1090_CMD+=("--net") +DUMP1090_CMD+=("--fix") +DUMP1090_CMD+=("--gnss") +DUMP1090_CMD+=("--json-location-accuracy" "2") +DUMP1090_CMD+=("--write-json" "/run/dump1090-fa") +DUMP1090_CMD+=("--net-bind-address" "0.0.0.0") + +# Handle "--modeac" +if [[ "$ALLOW_MODEAC" == "yes" ]]; then + DUMP1090_CMD+=("--modeac") +fi + +# If a BEASTHOST is specified +if [[ -n "$BEASTHOST" ]]; then + DUMP1090_CMD+=("--net-only") + +# Default - rtlsdr mode +else + DUMP1090_CMD+=("--device-type" "rtlsdr") + + if [[ -n "$DUMP1090_DEVICE" ]]; then + DUMP1090_CMD+=("--device" "$DUMP1090_DEVICE") + fi + + if [[ -n "$RTLSDR_PPM" ]]; then + DUMP1090_CMD+=("--ppm" "$RTLSDR_PPM") + fi + + if [[ -n "$RTLSDR_GAIN" ]]; then + DUMP1090_CMD+=("--gain" "$RTLSDR_GAIN") + fi + +fi + +# shellcheck disable=SC2016 +"${DUMP1090_BIN}" "${DUMP1090_CMD[@]}" \ + 2>&1 | stdbuf -o0 awk '{print "[dump1090] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}' + +sleep 5 From b0a8263ba627dec8a0292595cc96dbdd0efd9001 Mon Sep 17 00:00:00 2001 From: "Chadwick, Michael" Date: Mon, 22 Mar 2021 00:09:53 -0400 Subject: [PATCH 2/3] Update docker-compose file Updating the Docker Compose file to build off of the new container Dockerfile, vs. taking the raw image from Dockerhub. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index e867d03..24d8b2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: restart: unless-stopped piaware: - image: mikenye/piaware:latest + build: ./piaware tty: true container_name: piaware restart: always From 152a5df735ade307d1e2d0ec8b4b67522f6ed98e Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 22 Mar 2021 11:43:27 -0400 Subject: [PATCH 3/3] Update sbs1.py --- adsb-mqtt/sbs1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adsb-mqtt/sbs1.py b/adsb-mqtt/sbs1.py index 295a1c4..7a37c4d 100644 --- a/adsb-mqtt/sbs1.py +++ b/adsb-mqtt/sbs1.py @@ -9,6 +9,7 @@ from typing import * from datetime import datetime import logging +import re try: import dateutil.parser except ImportError as e: @@ -124,7 +125,8 @@ def __parseInt(array: List, index: int): """Parse int at given index in array Return int value or None if index is out of bounds or type casting failed""" try: - return int(array[index]) + numbers = re.findall('[0-9]+', array[index])[0] + return int(numbers) except ValueError as e: return None except TypeError as e: