Skip to content

Commit

Permalink
Merge pull request #804 from darksidelemm/testing
Browse files Browse the repository at this point in the history
Merge in some temporary fixes.
  • Loading branch information
darksidelemm authored Sep 2, 2023
2 parents e627edf + fbe4cbe commit 6efc17e
Show file tree
Hide file tree
Showing 19 changed files with 901 additions and 78 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ auto_rx/imet54mod
auto_rx/mXXmod
auto_rx/mp3h1mod
auto_rx/mts01mod
auto_rx/weathex301d

m10
meisei100mod
Expand Down Expand Up @@ -82,3 +83,4 @@ rs_module/rs41mod
rs_module/rs92mod
scan/reset_usb
scan/rs_detect
weathex/weathex301d
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUBDIRS := \
mk2a \
scan \
utils \
weathex \

all: $(SUBDIRS)

Expand Down
9 changes: 6 additions & 3 deletions auto_rx/auto_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def start_scanner():
ppm=autorx.sdr_list[_device_idx]["ppm"],
bias=autorx.sdr_list[_device_idx]["bias"],
save_detection_audio=config["save_detection_audio"],
wideband_sondes=config["wideband_sondes"],
temporary_block_list=temporary_block_list,
temporary_block_time=config["temporary_block_time"],
)
Expand Down Expand Up @@ -272,7 +273,8 @@ def start_decoder(freq, sonde_type, continuous=False):
rs92_ephemeris=rs92_ephemeris,
rs41_drift_tweak=config["rs41_drift_tweak"],
experimental_decoder=config["experimental_decoders"][_exp_sonde_type],
save_raw_hex=config["save_raw_hex"]
save_raw_hex=config["save_raw_hex"],
wideband_sondes=config["wideband_sondes"]
)
autorx.sdr_list[_device_idx]["task"] = autorx.task_list[freq]["task"]

Expand Down Expand Up @@ -818,8 +820,8 @@ def main():
logging.getLogger("geventwebsocket").setLevel(logging.ERROR)

# Check all the RS utilities exist.
logging.debug("Checking if utils exist")
if not check_rs_utils():
logging.debug("Checking if required binaries exist")
if not check_rs_utils(config):
sys.exit(1)

# Attempt to read in config file
Expand All @@ -832,6 +834,7 @@ def main():
config = _temp_cfg
autorx.sdr_list = config["sdr_settings"]


# Apply any logging changes based on configuration file settings.
if config["save_system_log"]:
# Enable system logging.
Expand Down
2 changes: 1 addition & 1 deletion auto_rx/autorx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
# PATCH - Small changes, or minor feature additions.

__version__ = "1.6.3-beta1"
__version__ = "1.6.3-beta4"


# Global Variables
Expand Down
45 changes: 30 additions & 15 deletions auto_rx/autorx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def read_auto_rx_config(filename, no_sdr_test=False):
"sondehub_enabled": True,
"sondehub_upload_rate": 30,
# "sondehub_contact_email": "none@none.com" # Commented out to ensure a warning message is shown on startup
"wideband_sondes": False, # Wideband sonde detection / decoding
}

try:
Expand Down Expand Up @@ -455,27 +456,30 @@ def read_auto_rx_config(filename, no_sdr_test=False):
"MEISEI": True,
"MTS01": False, # Until we test it
"MRZ": False, # .... except for the MRZ, until we know it works.
"WXR301": False, # No fsk_demod chain for this yet.
"UDP": False,
}

auto_rx_config["decoder_spacing_limit"] = config.getint(
"advanced", "decoder_spacing_limit"
)
auto_rx_config["experimental_decoders"]["RS41"] = config.getboolean(
"advanced", "rs41_experimental"
)
auto_rx_config["experimental_decoders"]["RS92"] = config.getboolean(
"advanced", "rs92_experimental"
)
auto_rx_config["experimental_decoders"]["M10"] = config.getboolean(
"advanced", "m10_experimental"
)
auto_rx_config["experimental_decoders"]["DFM"] = config.getboolean(
"advanced", "dfm_experimental"
)
auto_rx_config["experimental_decoders"]["LMS6"] = config.getboolean(
"advanced", "lms6-400_experimental"
)
# Use 'experimental' (not really, anymore!) decoders for RS41, RS92, M10, DFM and LMS6-400.
# Don't allow overriding to the FM based decoders.
# auto_rx_config["experimental_decoders"]["RS41"] = config.getboolean(
# "advanced", "rs41_experimental"
# )
# auto_rx_config["experimental_decoders"]["RS92"] = config.getboolean(
# "advanced", "rs92_experimental"
# )
# auto_rx_config["experimental_decoders"]["M10"] = config.getboolean(
# "advanced", "m10_experimental"
# )
# auto_rx_config["experimental_decoders"]["DFM"] = config.getboolean(
# "advanced", "dfm_experimental"
# )
# auto_rx_config["experimental_decoders"]["LMS6"] = config.getboolean(
# "advanced", "lms6-400_experimental"
# )

try:
auto_rx_config["web_control"] = config.getboolean("web", "web_control")
Expand Down Expand Up @@ -760,6 +764,17 @@ def read_auto_rx_config(filename, no_sdr_test=False):
auto_rx_config["email_encrypted_sonde_notifications"] = True


# 1.6.3 - Weathex WXR301d support
try:
auto_rx_config["wideband_sondes"] = config.getboolean(
"advanced", "wideband_sondes"
)
except:
logging.warning(
"Config - Missing wideband_sondes option (new in v1.6.3), using default (False)"
)
auto_rx_config["wideband_sondes"] = False

# If we are being called as part of a unit test, just return the config now.
if no_sdr_test:
return auto_rx_config
Expand Down
59 changes: 56 additions & 3 deletions auto_rx/autorx/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"MRZ",
"MTS01",
"UDP",
"WXR301"
]

# Known 'Drifty' Radiosonde types
Expand Down Expand Up @@ -119,6 +120,7 @@ class SondeDecoder(object):
"MRZ",
"MTS01",
"UDP",
"WXR301"
]

def __init__(
Expand All @@ -143,7 +145,8 @@ def __init__(
rs92_ephemeris=None,
rs41_drift_tweak=False,
experimental_decoder=False,
save_raw_hex=False
save_raw_hex=False,
wideband_sondes=False
):
""" Initialise and start a Sonde Decoder.
Expand Down Expand Up @@ -182,6 +185,7 @@ def __init__(
rs41_drift_tweak (bool): If True, add a high-pass filter in the decode chain, which can improve decode performance on drifty SDRs.
experimental_decoder (bool): If True, use the experimental fsk_demod-based decode chain.
save_raw_hex (bool): If True, save the raw hex output from the decoder to a file.
wideband_sondes (bool): If True, use a wider bandwidth for iMet sondes. Does not affect settings for any other radiosonde types.
"""
# Thread running flag
self.decoder_running = True
Expand Down Expand Up @@ -212,6 +216,7 @@ def __init__(
self.experimental_decoder = experimental_decoder
self.save_raw_hex = save_raw_hex
self.raw_file = None
self.wideband_sondes = wideband_sondes

# Raw hex filename
if self.save_raw_hex:
Expand Down Expand Up @@ -521,7 +526,11 @@ def generate_decoder_command(self):
elif self.sonde_type == "IMET":
# iMet-4 Sondes

_sample_rate = 48000
# These samples rates probably need to be revisited.
if self.wideband_sondes:
_sample_rate = 96000
else:
_sample_rate = 48000

decode_cmd = get_sdr_iq_cmd(
sdr_type = self.sdr_type,
Expand All @@ -540,8 +549,13 @@ def generate_decoder_command(self):
if self.save_decode_iq:
decode_cmd += f" tee {self.save_decode_iq_path} |"

if self.wideband_sondes:
_wideband = "--imet1"
else:
_wideband = ""

# iMet-4 (IMET1RS) decoder
decode_cmd += f"./imet4iq --iq 0.0 --lpIQ --dc - {_sample_rate} 16 --json 2>/dev/null"
decode_cmd += f"./imet4iq --iq 0.0 --lpIQ --dc - {_sample_rate} 16 --json {_wideband} 2>/dev/null"

elif self.sonde_type == "IMET5":
# iMet-54 Sondes
Expand Down Expand Up @@ -718,6 +732,35 @@ def generate_decoder_command(self):
# Meteosis MTS01 decoder
decode_cmd += f"./mts01mod --json --IQ 0.0 --lpIQ --dc - {_sample_rate} 16 2>/dev/null"


elif self.sonde_type == "WXR301":
# Weathex WxR-301D

_sample_rate = 96000
_if_bw = 64

decode_cmd = get_sdr_iq_cmd(
sdr_type = self.sdr_type,
frequency = self.sonde_freq,
sample_rate = _sample_rate,
sdr_hostname = self.sdr_hostname,
sdr_port = self.sdr_port,
ss_iq_path = self.ss_iq_path,
rtl_device_idx = self.rtl_device_idx,
ppm = self.ppm,
gain = self.gain,
bias = self.bias
)

# Add in tee command to save IQ to disk if debugging is enabled.
if self.save_decode_iq:
decode_cmd += f" tee {self.save_decode_iq_path} |"

# WXR301, via iq_dec as a FM Demod.
decode_cmd += f"./iq_dec --FM --IFbw {_if_bw} --lpFM --wav --iq 0.0 - {_sample_rate} 16 2>/dev/null | ./weathex301d -b --json"



elif self.sonde_type == "UDP":
# UDP Input Mode.
# Used only for testing of new decoders, prior to them being integrated into auto_rx.
Expand Down Expand Up @@ -1607,6 +1650,16 @@ def handle_decoder_line(self, data):
"%Y-%m-%dT%H:%M:%SZ"
)

# Weathex Specific Actions
# Same datetime issues as with iMets, and LMS6
if self.sonde_type == "WXR301":
# Fix up the time.
_telemetry["datetime_dt"] = fix_datetime(_telemetry["datetime"])
# Re-generate the datetime string.
_telemetry["datetime"] = _telemetry["datetime_dt"].strftime(
"%Y-%m-%dT%H:%M:%SZ"
)

# Grab a snapshot of modem statistics, if we are using an experimental decoder.
if self.demod_stats is not None:
if self.demod_stats.snr != -999.0:
Expand Down
7 changes: 6 additions & 1 deletion auto_rx/autorx/rotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ def move_rotator(self, azimuth, elevation):
_curr_az = _pos[0] % 360.0
_curr_el = _pos[1]

if (abs(azimuth - _curr_az) > self.rotator_update_threshold) or (
_azimuth_diff = abs(azimuth - _curr_az)
if (_azimuth_diff > 180.0):
_azimuth_diff = abs(_azimuth_diff - 360.0)


if (_azimuth_diff > self.rotator_update_threshold) or (
abs(elevation - _curr_el) > self.rotator_update_threshold
):
# Move to the target position.
Expand Down
Loading

0 comments on commit 6efc17e

Please sign in to comment.