diff --git a/auto_rx/auto_rx.py b/auto_rx/auto_rx.py index 6341ef2..c953c25 100644 --- a/auto_rx/auto_rx.py +++ b/auto_rx/auto_rx.py @@ -243,7 +243,8 @@ def start_decoder(freq, sonde_type): rs92_ephemeris = rs92_ephemeris, imet_location = config['station_code'], rs41_drift_tweak = config['rs41_drift_tweak'], - experimental_decoder = config['experimental_decoders'][sonde_type] + experimental_decoder = config['experimental_decoders'][sonde_type], + decoder_stats = config['decoder_stats'] ) autorx.sdr_list[_device_idx]['task'] = autorx.task_list[freq]['task'] diff --git a/auto_rx/autorx/config.py b/auto_rx/autorx/config.py index d93263b..5e8d95d 100644 --- a/auto_rx/autorx/config.py +++ b/auto_rx/autorx/config.py @@ -104,6 +104,7 @@ def read_auto_rx_config(filename): 'payload_id_valid' : 5, 'temporary_block_time' : 60, 'rs41_drift_tweak': False, + 'decoder_stats': False, # Rotator Settings 'enable_rotator': False, 'rotator_update_rate': 30, @@ -262,6 +263,7 @@ def read_auto_rx_config(filename): try: auto_rx_config['rs41_drift_tweak'] = config.getboolean('advanced', 'drift_tweak') auto_rx_config['decoder_spacing_limit'] = config.getint('advanced', 'decoder_spacing_limit') + auto_rx_config['decoder_stats'] = config.getboolean('advanced', 'enable_stats') 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') @@ -272,6 +274,7 @@ def read_auto_rx_config(filename): logging.error("Config - Missing new advanced decoder settings, using defaults.") auto_rx_config['rs41_drift_tweak'] = False auto_rx_config['decoder_spacing_limit'] = 15000 + auto_rx_config['decoder_stats'] = False diff --git a/auto_rx/autorx/decode.py b/auto_rx/autorx/decode.py index 486abb0..0df7f2a 100644 --- a/auto_rx/autorx/decode.py +++ b/auto_rx/autorx/decode.py @@ -87,6 +87,7 @@ class SondeDecoder(object): rs92_ephemeris = None, rs41_drift_tweak = False, experimental_decoder = False, + decoder_stats = False, imet_location = ""): """ Initialise and start a Sonde Decoder. @@ -141,6 +142,7 @@ class SondeDecoder(object): self.rs92_ephemeris = rs92_ephemeris self.rs41_drift_tweak = rs41_drift_tweak self.experimental_decoder = experimental_decoder + self.decoder_stats = decoder_stats self.imet_location = imet_location # iMet ID store. We latch in the first iMet ID we calculate, to avoid issues with iMet-1-RS units @@ -378,10 +380,16 @@ class SondeDecoder(object): else: gain_param = '' - # Emit demodulator statistics every X modem frames. _stats_rate = 10 + if self.decoder_stats: + _stats_command_1 = "--stats=%d " % _stats_rate + _stats_command_2 = "2>stats_%d.txt" % self.sonde_freq + else: + _stats_command_1 = "" + _stats_command_2 = "2>/dev/null" + if self.sonde_type == "RS41": # RS41 Decoder command. @@ -397,7 +405,7 @@ class SondeDecoder(object): if self.save_decode_iq: decode_cmd += " tee decode_IQ_%s.bin |" % str(self.device_idx) - decode_cmd += "./fsk_demod --cs16 -b %d -u %d --stats=%d 2 %d %d - - 2>stats.txt |" % (_lower, _upper, _stats_rate, _sdr_rate, _baud_rate) + decode_cmd += "./fsk_demod --cs16 -b %d -u %d %s2 %d %d - - %s |" % (_lower, _upper, _stats_command_1, _sdr_rate, _baud_rate, _stats_command_2) decode_cmd += "./rs41mod --ptu --json --bin 2>/dev/null" @@ -447,7 +455,7 @@ class SondeDecoder(object): if self.save_decode_iq: decode_cmd += " tee decode_IQ_%s.bin |" % str(self.device_idx) - decode_cmd += "./fsk_demod --cs16 -b %d -u %d --stats=%d 2 %d %d - - 2>stats.txt " % (_lower, _upper, _stats_rate, _sdr_rate, _baud_rate) + decode_cmd += "./fsk_demod --cs16 -b %d -u %d %s2 %d %d - - %s |" % (_lower, _upper, _stats_command_1, _sdr_rate, _baud_rate, _stats_command_2) decode_cmd += "| python ./test/bit_to_samples.py %d %d | sox -t raw -r %d -e unsigned-integer -b 8 -c 1 - -r %d -b 8 -t wav - 2>/dev/null|" % (_output_rate, _baud_rate, _output_rate, _output_rate) # Add in tee command to save audio to disk if debugging is enabled. @@ -475,7 +483,7 @@ class SondeDecoder(object): if self.save_decode_iq: decode_cmd += " tee decode_IQ_%s.bin |" % str(self.device_idx) - decode_cmd += "./fsk_demod --cs16 -b %d -u %d --stats=%d 2 %d %d - - 2>stats.txt " % (_lower, _upper, _stats_rate, _sdr_rate, _baud_rate) + decode_cmd += "./fsk_demod --cs16 -b %d -u %d %s2 %d %d - - %s |" % (_lower, _upper, _stats_command_1, _sdr_rate, _baud_rate, _stats_command_2) decode_cmd += "| python ./test/bit_to_samples.py %d %d | sox -t raw -r %d -e unsigned-integer -b 8 -c 1 - -r %d -b 8 -t wav - 2>/dev/null|" % (_sdr_rate, _baud_rate, _sdr_rate, _sdr_rate) # Add in tee command to save audio to disk if debugging is enabled. @@ -502,7 +510,7 @@ class SondeDecoder(object): if self.save_decode_iq: decode_cmd += " tee decode_IQ_%s.bin |" % str(self.device_idx) - decode_cmd += "./fsk_demod --cs16 -b %d -u %d --stats=%d 2 %d %d - - 2>stats.txt " % (_lower, _upper, _stats_rate, _sdr_rate, _baud_rate) + decode_cmd += "./fsk_demod --cs16 -b %d -u %d %s2 %d %d - - %s |" % (_lower, _upper, _stats_command_1, _sdr_rate, _baud_rate, _stats_command_2) decode_cmd += "| python ./test/bit_to_samples.py %d %d | sox -t raw -r %d -e unsigned-integer -b 8 -c 1 - -r %d -b 8 -t wav - 2>/dev/null| " % (_sdr_rate, _baud_rate, _sdr_rate, _sdr_rate) # Add in tee command to save audio to disk if debugging is enabled. diff --git a/auto_rx/station.cfg.example b/auto_rx/station.cfg.example index 203f691..8f2b743 100644 --- a/auto_rx/station.cfg.example +++ b/auto_rx/station.cfg.example @@ -365,7 +365,6 @@ drift_tweak = False # # Experimental Decoders - Use at your own risk! -# NOTE: These are not yet available in the master/testing branches. Stay tuned! # # These experimental demod chains use David Rowe's fsk_demod modem. # They have much better drift handling performance, and so may be better suited for @@ -377,6 +376,11 @@ dfm_experimental = False m10_experimental = False # Note: As iMet sondes use AFSK, using fsk_demod does not give any advantage, so there is no experimental decoder for them. +# Dump FSK Demod statistics to stats_.txt while the modem is running. +# This ends up at ~200mb per flight, and is over-written with each new sonde tracked. +# The test/plot_fsk_demod_stats.py script can plot these files for debugging purposes. +# Eventually the modem statistics will be integrated into the web GUI. +enable_stats = False