Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing - Add a task preference item to each SDR (ignored the new networked receivers, just port from 1.5) #640

Open
wants to merge 3 commits into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion auto_rx/auto_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@
# This contains frequncies that should be blocked for a short amount of time.
temporary_block_list = {}

def get_sdr_item_pref(sdr_item):
"""A helper function for the purpose of sorting the list of SDR by preference.
Args:
sdr_item (tuple) : Single element resulting from sdr_list.items(). A pair of ID (str) and config (dict).
Returns:
(tuple) : A pair with the scanner preference value inverted and ID, for the purpose of sorting by highest
values first and if equal then lowest to highest ID.
"""
id = sdr_item[0]
cfg = sdr_item[1]
return (-cfg["preference"], id)

def allocate_sdr(check_only=False, task_description=""):
"""Allocate an un-used SDR for a task.
Expand All @@ -104,7 +115,7 @@ def allocate_sdr(check_only=False, task_description=""):
(str): The device index/serial number of the free/allocated SDR, if one is free, else None.
"""

for _idx in sorted(autorx.sdr_list.keys()):
for _idx in [key for key, val in sorted(autorx.sdr_list.items(), key=get_sdr_item_pref)]:
if autorx.sdr_list[_idx]["in_use"] == False:
# Found a free SDR!
if check_only:
Expand Down
2 changes: 2 additions & 0 deletions auto_rx/autorx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ def read_auto_rx_config(filename, no_sdr_test=False):
_ppm = round(config.getfloat(_section, "ppm"))
_gain = config.getfloat(_section, "gain")
_bias = config.getboolean(_section, "bias")
_preference = config.getint(_section, "preference", fallback=0)

if (auto_rx_config["sdr_quantity"] > 1) and (_device_idx == "0"):
logging.critical(
Expand All @@ -758,6 +759,7 @@ def read_auto_rx_config(filename, no_sdr_test=False):
"ppm": _ppm,
"gain": _gain,
"bias": _bias,
"preference": _preference,
"in_use": False,
"task": None,
}
Expand Down
8 changes: 7 additions & 1 deletion auto_rx/station.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ gain = -1
# Bias Tee - Enable the bias tee in the RTLSDR v3 Dongles.
bias = False

# Preference (integer)
# By default all the SDR's have preference of 0 for allocation of scanner and decode tasks.
# Apply an higher value to the SDRs preferred
# Use a negative value to avoid using them.
preference = 1

[sdr_2]
# As above, for the next SDR, if used. Note the warning about serial numbers.
device_idx = 00000002
Expand Down Expand Up @@ -563,4 +569,4 @@ radius_temporary_block = False
# Discard positions if the sonde's reported time is more than X hours from the system time.
# This helps catch glitches around 00Z UTC from iMet & LMS6 sondes, and bad CRC checks from
# DFM sondes.
sonde_time_threshold = 3
sonde_time_threshold = 3