diff --git a/src/framing/src/qdetector.proto.c b/src/framing/src/qdetector.proto.c index 4511ea018..5128adb0e 100644 --- a/src/framing/src/qdetector.proto.c +++ b/src/framing/src/qdetector.proto.c @@ -57,6 +57,7 @@ struct QDETECTOR(_s) { unsigned int counter; // sample counter for determining when to compute FFTs float threshold; // detection threshold + float dphi_max; // carrier offset search range (radians/sample) int range; // carrier offset search range (subcarriers) unsigned int num_transforms; // number of transforms taken (debugging) @@ -287,6 +288,7 @@ QDETECTOR() QDETECTOR(_copy)(QDETECTOR() q_orig) // copy internal state q_copy->counter = q_orig->counter; q_copy->threshold = q_orig->threshold; + q_copy->dphi_max = q_orig->dphi_max; q_copy->range = q_orig->range; q_copy->num_transforms = q_orig->num_transforms; // buffer power magnitude @@ -324,7 +326,7 @@ int QDETECTOR(_print)(QDETECTOR() _q) printf("qdetector_%s:\n", EXTENSION_FULL); printf(" template length (time): %-u\n", _q->s_len); printf(" FFT size : %-u\n", _q->nfft); - printf(" search range (bins) : %-d\n", _q->range); + printf(" search range : %g [radians/sample], %-d [bins]\n",_q->dphi_max, _q->range); printf(" detection threshold : %6.4f\n", _q->threshold); printf(" sum{ s^2 } : %.2f\n", _q->s2_sum); return LIQUID_OK; @@ -383,19 +385,20 @@ int QDETECTOR(_set_threshold)(QDETECTOR() _q, // get carrier offset search range float QDETECTOR(_get_range)(QDETECTOR() _q) { - return _q->range; + return _q->dphi_max; } // set carrier offset search range int QDETECTOR(_set_range)(QDETECTOR() _q, - float _dphi_max) + float _dphi_max) { if (_dphi_max < 0.0f || _dphi_max > 0.5f) return liquid_error(LIQUID_EICONFIG,"carrier offset search range (%12.4e) out of range; ignoring", _dphi_max); // set internal search range - _q->range = (int)(_dphi_max * _q->nfft / (2*M_PI)); - _q->range = _q->range < 0 ? 0 : _q->range; + _q->dphi_max = _dphi_max; + _q->range = (int)(_q->dphi_max * _q->nfft / (2*M_PI)); + _q->range = _q->range < 0 ? 0 : _q->range; //printf("range: %d / %u\n", _q->range, _q->nfft); return LIQUID_OK; } diff --git a/src/framing/tests/dsssframe64_autotest.c b/src/framing/tests/dsssframe64_autotest.c index 31acf9877..030e7abf1 100644 --- a/src/framing/tests/dsssframe64_autotest.c +++ b/src/framing/tests/dsssframe64_autotest.c @@ -108,7 +108,7 @@ void autotest_dsssframe64_config() CONTEND_EQUALITY( threshold, dsssframe64sync_get_threshold(fs) ); float range = 0.00722f; CONTEND_EQUALITY( LIQUID_OK, dsssframe64sync_set_range(fs, range) ); - //CONTEND_EQUALITY( range, dsssframe64sync_get_range(fs) ); + CONTEND_EQUALITY( range, dsssframe64sync_get_range(fs) ); dsssframe64gen_destroy(fg); dsssframe64sync_destroy(fs); diff --git a/src/framing/tests/qdsync_cccf_autotest.c b/src/framing/tests/qdsync_cccf_autotest.c index 1e1c59eaf..443642399 100644 --- a/src/framing/tests/qdsync_cccf_autotest.c +++ b/src/framing/tests/qdsync_cccf_autotest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2023 Joseph Gaeddert + * Copyright (c) 2007 - 2024 Joseph Gaeddert * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -325,6 +325,10 @@ void autotest_qdsync_cccf_config() CONTEND_EQUALITY(LIQUID_OK, qdsync_cccf_set_threshold(q,0.654321f)) CONTEND_EQUALITY(0.654321f, qdsync_cccf_get_threshold(q)) + // set/get range + CONTEND_EQUALITY(LIQUID_OK, qdsync_cccf_set_range(q,0.007220f)) + CONTEND_EQUALITY(0.007220f, qdsync_cccf_get_range(q)) + // set invalid buffer length CONTEND_INEQUALITY(LIQUID_OK, qdsync_cccf_set_buf_len(q,0))