diff --git a/horusdemodlib/__init__.py b/horusdemodlib/__init__.py index 970659c..86205cb 100755 --- a/horusdemodlib/__init__.py +++ b/horusdemodlib/__init__.py @@ -1 +1 @@ -__version__ = "0.1.16" +__version__ = "0.1.17" diff --git a/horusdemodlib/demod.py b/horusdemodlib/demod.py index 3a5b2cf..5e9ac22 100644 --- a/horusdemodlib/demod.py +++ b/horusdemodlib/demod.py @@ -333,6 +333,11 @@ class HorusLib(): ) return frame + def set_estimator_limits(self, lower: float, upper: float): + """ Update the modems internal frequency estimator limits """ + self.c_lib.horus_set_freq_est_limits(self.hstates, c_float(lower), c_float(upper)) + + def add_samples(self, samples: bytes): """ Add samples to a input buffer, to pass on to demodulate when we have nin samples """ @@ -363,9 +368,10 @@ class HorusLib(): if __name__ == "__main__": import sys - if len(sys.argv) != 3: - raise ArgumentError("Usage python3 -m horusdemodlib.demod mode filename") + if len(sys.argv) != 4: + raise ArgumentError("Usage python3 -m horusdemodlib.demod mode filename sample_rate") filename = sys.argv[2] + rate = int(sys.argv[3]) if sys.argv[1] == 'rtty7n2': mode = Mode.RTTY_7N2 @@ -394,7 +400,8 @@ if __name__ == "__main__": format="%(asctime)s %(levelname)s: %(message)s", level=logging.DEBUG ) - with HorusLib(mode=mode, verbose=False, callback=frame_callback, sample_rate=48000, rate=300) as horus: + with HorusLib(mode=mode, verbose=False, callback=frame_callback, sample_rate=rate, rate=100) as horus: + #horus.set_estimator_limits(10.0, 3000.0) with open(filename, "rb") as f: while True: # Fixed read size - 2000 samples diff --git a/pyproject.toml b/pyproject.toml index d7cfe18..295fe19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "horusdemodlib" -version = "0.1.16" +version = "0.1.17" description = "Project Horus HAB Telemetry Demodulators" authors = ["Mark Jessop"] license = "LGPL-2.1-or-later" diff --git a/src/fsk.c b/src/fsk.c index 41248fc..de5cf44 100644 --- a/src/fsk.c +++ b/src/fsk.c @@ -628,11 +628,12 @@ void fsk_demod_core(struct FSK *fsk, uint8_t rx_bits[], float rx_sd[], COMP fsk_ modem_probe_samp_f("t_f_est",fsk->f_est,M); #endif float *f_est; - if (fsk->freq_est_type) + + if (fsk->freq_est_type){ f_est = fsk->f2_est; - else + }else{ f_est = fsk->f_est; - + } /* update filter (integrator) memory by shifting in nin samples */ for(m=0; mneyetr = fsk->stats->neyetr; memcpy(stats->rx_eye, fsk->stats->rx_eye, sizeof(stats->rx_eye)); memcpy(stats->f_est, fsk->stats->f_est, fsk->mode*sizeof(float)); + /* these fields not used for FSK so set to something sensible */ diff --git a/src/horus_api.c b/src/horus_api.c index e28dfdc..2689f37 100644 --- a/src/horus_api.c +++ b/src/horus_api.c @@ -921,7 +921,12 @@ void horus_get_modem_extended_stats (struct horus *hstates, struct MODEM_STATS * assert(hstates->mFSK <= MODEM_STATS_MAX_F_EST); for (i=0; imFSK; i++) { - stats->f_est[i] = hstates->fsk->f_est[i]; + // Grab the appropriate frequency estimator data. + if (hstates->fsk->freq_est_type){ + stats->f_est[i] = hstates->fsk->f2_est[i]; + } else { + stats->f_est[i] = hstates->fsk->f_est[i]; + } } }