Hi,
Whilst working with this code, I came across some inconsistent sync-ids. Diving in deeper, I found a bug. It’s probably best explained by the patch itself, (see below) but I will also try and explain it in plain words.
In short, when checking which sync_id has the highest correlation, the relevant bit of of the signal (with wiggle room) is correlated against the sync-id pattern into a buffer. This adds the output correlation to the buffer. Then, at the end, it was decided which sync_id was present by looking for the max correlation. In between sync-ids, the buffer was not reset. Hence when checking the last sync_id, the buffer does not hold the correlation between that sync_id and the signal, but the sum of correlations between the signal and all sync_id. Hence the results were very strongly biased towards the later sync_ids.
The fix is easy. Clear the buffer before every correlation. See the patch below. The patch should apply to the master branch, I believe the bug exists in most branches though,.
In my mind, the change is too trivial to be copyrighted. But for completeness sake, I give the osmocom-gmr project permission to use this patch.
Kind regards, Bart Marinissen
diff --git a/src/sdr/pi4cxpsk.c b/src/sdr/pi4cxpsk.c index 1ed40e01989bac05ff915ebd811835a60f95f61e..e8ab843a92d90622b64b5a59fcaff9ef4d01fea0 100644 --- a/src/sdr/pi4cxpsk.c +++ b/src/sdr/pi4cxpsk.c @@ -204,12 +204,12 @@ _gmr1_pi4cxpsk_sync_find(struct gmr1_pi4cxpsk_burst *burst_type, goto err; }
- memset(corr->data, 0x00, sizeof(float complex) * corr->max_len); - corr->len = w; - /* Scan all possible training sequences */ for (i=0; (i < GMR1_MAX_SYNC) && (burst_type->sync[i] != NULL); i++) { + memset(corr->data, 0x00, sizeof(float complex) * corr->max_len); + corr->len = w; + struct gmr1_pi4cxpsk_sync *csync; float s_toa, s_pwr; float complex s_peak;