Skip to content

Commit

Permalink
Create a threshold value so that average messages below the threshold…
Browse files Browse the repository at this point in the history
… will cause a restart. Fix source issue for s6swrap
  • Loading branch information
fredclausen committed Dec 9, 2023
1 parent 0cd538e commit 4c180d8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ENV DEVICE_INDEX="" \
SERIAL="" \
SOAPYSDR="" \
SERVER_PORT="5556" \
VDLM_FILTER_ENABLE="TRUE"
VDLM_FILTER_ENABLE="TRUE" \
MIN_MESSAGE_THESHOLD="5"

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ Keep in mind not every SDR is usable with HF decoding. If you have an SDR that i

## Configuration options

| Variable | Description | Required | Default |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| `TZ` | Your timezone | No | UTC |
| `SOAPYSDRDRIVER` | SoapySDR driver. Required! Should be in the format that you would use to pass in to soapysdr. See the compose example above. | Yes | `unset` |
| `GAIN_TYPE` | The type of gain to use. Can be `--gain` or `--gain-elements`. | Yes | `unset` |
| `GAIN` | The gain to use. If used with `GAIN_TYPE=--gain-elements` then this should be in the format your SDR expects. For Airspy style devices something like `IFGR=53,RFGR=2`. Otherwise, if used with `GAIN_TYPE=--gain` then it should be a single value representing a gain value your SDR supports. Example above in the compose section. | Yes | `unset` |
| `SOAPYSAMPLERATE` | The sample rate to use. The sample rate that your SDR would expect. | Yes | `unset` |
| `FEED_ID` | The feed ID to use. This is the ID that will be used to identify your feed on the ACARS Hub and any site, such as [airframes](airframes.io) that you feed. | Yes | `unset` |
| `ZMQ_MODE` | The ZMQ mode to use. Can be `server` or `client`. | Yes | `unset` |
| `ZMQ_ENDPOINT` | The ZMQ endpoint to use. If `ZMQ_MODE=server` then this should be the endpoint that `acars_router` and other consumers will connect to. If `ZMQ_MODE=client` then this should be the endpoint that a ZMQ server is listening on and expects data from. | Yes | `unset` |
| `SERVER` | If you want this container to forward JSON data, via TCP, to a consumer then set this to the IP address of a consumer | No | `unset` |
| `SERVER_PORT` | If you want this container to forward JSON data, via TCP, to a consumer then set this to the port of a consumer | No | `unset` |
| `TIMEOUT` | The number of seconds that the frequency selector will run each group of frequencies for to pick the optimal HFDL frequencies for monitoring. | No | `90` |
| Variable | Description | Required | Default |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
| `TZ` | Your timezone | No | UTC |
| `SOAPYSDRDRIVER` | SoapySDR driver. Required! Should be in the format that you would use to pass in to soapysdr. See the compose example above. | Yes | `unset` |
| `GAIN_TYPE` | The type of gain to use. Can be `--gain` or `--gain-elements`. | Yes | `unset` |
| `GAIN` | The gain to use. If used with `GAIN_TYPE=--gain-elements` then this should be in the format your SDR expects. For Airspy style devices something like `IFGR=53,RFGR=2`. Otherwise, if used with `GAIN_TYPE=--gain` then it should be a single value representing a gain value your SDR supports. Example above in the compose section. | Yes | `unset` |
| `SOAPYSAMPLERATE` | The sample rate to use. The sample rate that your SDR would expect. | Yes | `unset` |
| `FEED_ID` | The feed ID to use. This is the ID that will be used to identify your feed on the ACARS Hub and any site, such as [airframes](airframes.io) that you feed. | Yes | `unset` |
| `ZMQ_MODE` | The ZMQ mode to use. Can be `server` or `client`. | Yes | `unset` |
| `ZMQ_ENDPOINT` | The ZMQ endpoint to use. If `ZMQ_MODE=server` then this should be the endpoint that `acars_router` and other consumers will connect to. If `ZMQ_MODE=client` then this should be the endpoint that a ZMQ server is listening on and expects data from. | Yes | `unset` |
| `SERVER` | If you want this container to forward JSON data, via TCP, to a consumer then set this to the IP address of a consumer | No | `unset` |
| `SERVER_PORT` | If you want this container to forward JSON data, via TCP, to a consumer then set this to the port of a consumer | No | `unset` |
| `TIMEOUT` | The number of seconds that the frequency selector will run each group of frequencies for to pick the optimal HFDL frequencies for monitoring. | No | `90` |
| `MIN_MESSAGE_THESHOLD` | The minimum number of messages that should be received, on average, during the rolling 30 minute time period. If the average is below this threshold the frequency selector will be re-run. | No | `5` |

## What this thing does under the hood, or why don't I specify frequencies?

Expand Down
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/scripts/hfdl_feeder
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/command/with-contenv bash
# shellcheck shell=bash

source /scripts/common

set -o pipefail

if [[ -n ${SERVER} ]]; then
Expand Down
14 changes: 8 additions & 6 deletions rootfs/etc/s6-overlay/scripts/hfdl_server
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/command/with-contenv bash
#shellcheck shell=bash

set -o pipefail
set -e
source /scripts/common

# Listens for the output of dumphfdl (UDP), and makes it available for multiple processes at TCP port 15555
# shellcheck disable=SC2016
"${s6wrap[@]}" socat -u udp-listen:5556,fork stdout | ncat -4 --keep-open --listen 0.0.0.0 15556
set -o pipefail
set -e

sleep 5
# Listens for the output of dumphfdl (UDP), and makes it available for multiple processes at TCP port 15555
# shellcheck disable=SC2016
"${s6wrap[@]}" socat -u udp-listen:5556,fork stdout | ncat -4 --keep-open --listen 0.0.0.0 15556

sleep 5
12 changes: 10 additions & 2 deletions rootfs/etc/s6-overlay/scripts/hfdl_stats
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/command/with-contenv bash
#shellcheck shell=bash

#shellcheck disable=SC2154
source /scripts/common

set -o pipefail

# Require that hfdl_server is running
Expand Down Expand Up @@ -38,11 +41,16 @@ while true; do
# first, verify we have 30 minutes of data by verifying there are at least 6 files
if [[ $(find /run/hfdl -type f -name 'hfdl.*.json' | wc -l) -gt 6 ]]; then
# now check the last 6 files for messages
if [[ $(sed 's/}{/}\n{/g' /run/hfdl/hfdl.{0..5}.json | wc -l) -eq 0 ]]; then
"${s6wrap[@]}" echo " No messages received in last 30 minutes, killing dumphfdl to rerun the frequency optimizer"
average_message_count=$(sed 's/}{/}\n{/g' /run/hfdl/hfdl.{0..5}.json | wc -l)
average_message_count=$((average_message_count / 6))
if [[ $average_message_count -lt $MIN_MESSAGE_THESHOLD ]]; then
"${s6wrap[@]}" echo "Average messages (${average_message_count}) received in last 30 minutes is less then the threshold (${MIN_MESSAGE_THRESHOLD})"
"${s6wrap[@]}" echo "Restarting dumphfdl to rerun the frequency optimizer"
s6-svc -r /run/service/dumphfdl
rm -f /run/hfdl/hfdl.*.json
exit
else
"${s6wrap[@]}" echo "Average messages (${average_message_count}) received in last 30 minutes is greater then the threshold (${MIN_MESSAGE_THRESHOLD})"
fi
fi

Expand Down
7 changes: 7 additions & 0 deletions rootfs/reset-dumphfdl.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/command/with-contenv bash
#shellcheck shell=bash

#shellcheck disable=SC2154,SC1091
source /scripts/common


"${s6wrap[@]}" echo "============================================="
"${s6wrap[@]}" echo "Resetting dumphfdl"
"${s6wrap[@]}" echo "============================================="
s6-svc -r /run/service/dumphfdl || exit 1
rm -f /run/hfdl/hfdl.*.json || exit 1

0 comments on commit 4c180d8

Please sign in to comment.