Fix IQ recorder/player for nrUE

This commit is contained in:
Bruno Mongazon-Cazavet
2023-02-17 12:00:46 +01:00
parent f984f49310
commit 8601b8c990
28 changed files with 331 additions and 150 deletions
+17 -12
View File
@@ -685,7 +685,7 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
nsamps2 = (nsamps+3)>>2;
int16x8_t buff_tmp[cc<2 ? 2 : cc][nsamps2];
#endif
static int read_count = 0;
int rxshift;
switch (device->type) {
case USRP_B200_DEV:
@@ -756,25 +756,30 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
recplay_state_t *recPlay=device->recplay_state;
if ( recPlay != NULL) { // record mode
if (device->openair0_cfg->recplay_mode == RECPLAY_RECORDMODE) { // record mode
// Copy subframes to memory (later dump on a file)
if (recPlay->nbSamplesBlocks < device->openair0_cfg->recplay_conf->u_sf_max &&
recPlay->maxSizeBytes > (recPlay->currentPtr-(uint8_t *)recPlay->ms_sample) +
sizeof(iqrec_t) + nsamps*4 ) {
// The number of read samples might differ from BELL_LABS_IQ_BYTES_PER_SF
// The number of read samples is always stored in nbBytes but the record is always of BELL_LABS_IQ_BYTES_PER_SF size
if (recPlay->nbSamplesBlocks <= device->openair0_cfg->recplay_conf->u_sf_max &&
recPlay->maxSizeBytes >= (recPlay->currentPtr-(uint8_t *)recPlay->ms_sample) +
sizeof(iqrec_t) + BELL_LABS_IQ_BYTES_PER_SF) {
iqrec_t *hdr=(iqrec_t *)recPlay->currentPtr;
struct timespec trec;
(void) clock_gettime(CLOCK_REALTIME, &trec);
hdr->header = BELL_LABS_IQ_HEADER;
hdr->ts = *ptimestamp;
hdr->nbBytes=nsamps*4;
hdr->nbBytes=nsamps*4; // real number of samples bytes
hdr->tv_sec = trec.tv_sec; // record secs
hdr->tv_usec = trec.tv_nsec/1000; // record µsecs
memcpy(hdr+1, buff[0], nsamps*4);
recPlay->currentPtr+=sizeof(iqrec_t)+nsamps*4;
recPlay->currentPtr+=sizeof(iqrec_t)+BELL_LABS_IQ_BYTES_PER_SF; // record size is constant (BELL_LABS_IQ_BYTES_PER_SF)
recPlay->nbSamplesBlocks++;
#if 0 // BMC: this is too verbose
LOG_D(HW,"recorded %d samples, for TS %lu, shift in buffer %ld\n", nsamps, hdr->ts, recPlay->currentPtr-(uint8_t *)recPlay->ms_sample);
#endif
LOG_D(HW,"recorded %d samples, for TS %lu, shift in buffer %ld nbBytes %d nbSamplesBlocks %d\n", nsamps, hdr->ts, recPlay->currentPtr-(uint8_t *)recPlay->ms_sample, (int)hdr->nbBytes, (int)recPlay->nbSamplesBlocks);
} else
exit_function(__FILE__, __FUNCTION__, __LINE__,"Recording reaches max iq limit\n");
exit_function(__FILE__, __FUNCTION__, __LINE__, "Recording reaches max iq limit\n", EXIT_NORMAL);
}
read_count++;
LOG_D(HW,"usrp_lib: returning %d samples at ts %lu read_count %d\n", samples_received, *ptimestamp, read_count);
return samples_received;
}