Skip to content

Commit

Permalink
qdetector: storing internal frequency offset range
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Mar 18, 2024
1 parent 8d75f50 commit a39faff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/framing/src/qdetector.proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/framing/tests/dsssframe64_autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion src/framing/tests/qdsync_cccf_autotest.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit a39faff

Please sign in to comment.