SDR: Allow direct IQ TX and RX instead of fm modulating a list of channels

This is performed by reading and writing IQ data to "sample" pointer with
channel number set to 0.
This commit is contained in:
Andreas Eversberg
2017-03-20 20:07:11 +01:00
parent 65694f3b80
commit fbdb9ece01

View File

@@ -305,23 +305,28 @@ void sdr_close(void *inst)
int sdr_write(void *inst, sample_t **samples, int num, enum paging_signal __attribute__((unused)) *paging_signal, int *on, int channels) int sdr_write(void *inst, sample_t **samples, int num, enum paging_signal __attribute__((unused)) *paging_signal, int *on, int channels)
{ {
sdr_t *sdr = (sdr_t *)inst; sdr_t *sdr = (sdr_t *)inst;
float buff[num * 2]; float buffer[num * 2], *buff = NULL;
int c, s, ss; int c, s, ss;
int sent = 0; int sent = 0;
if (channels != sdr->channels) { if (channels != sdr->channels && channels != 0) {
PDEBUG(DSDR, DEBUG_ERROR, "Invalid number of channels, please fix!\n"); PDEBUG(DSDR, DEBUG_ERROR, "Invalid number of channels, please fix!\n");
abort(); abort();
} }
/* process all channels */ /* process all channels */
memset(buff, 0, sizeof(buff)); if (channels) {
for (c = 0; c < channels; c++) { memset(buffer, 0, sizeof(buffer));
/* switch to paging channel, if requested */ buff = buffer;
if (on[c] && sdr->paging_channel) for (c = 0; c < channels; c++) {
fm_modulate(&sdr->chan[sdr->paging_channel].mod, samples[c], num, buff); /* switch to paging channel, if requested */
else if (on[c] && sdr->paging_channel)
fm_modulate(&sdr->chan[c].mod, samples[c], num, buff); fm_modulate(&sdr->chan[sdr->paging_channel].mod, samples[c], num, buff);
else
fm_modulate(&sdr->chan[c].mod, samples[c], num, buff);
}
} else {
buff = (float *)samples;
} }
if (sdr->wave_tx_rec.fp) { if (sdr->wave_tx_rec.fp) {
@@ -358,10 +363,16 @@ int sdr_write(void *inst, sample_t **samples, int num, enum paging_signal __attr
int sdr_read(void *inst, sample_t **samples, int num, int channels) int sdr_read(void *inst, sample_t **samples, int num, int channels)
{ {
sdr_t *sdr = (sdr_t *)inst; sdr_t *sdr = (sdr_t *)inst;
float buff[num * 2]; float buffer[num * 2], *buff = NULL;
int count = 0; int count = 0;
int c, s, ss; int c, s, ss;
if (channels) {
buff = buffer;
} else {
buff = (float *)samples;
}
#ifdef HAVE_UHD #ifdef HAVE_UHD
if (sdr_use_uhd) if (sdr_use_uhd)
count = uhd_receive(buff, num); count = uhd_receive(buff, num);
@@ -392,8 +403,9 @@ int sdr_read(void *inst, sample_t **samples, int num, int channels)
display_iq(buff, count); display_iq(buff, count);
display_spectrum(buff, count); display_spectrum(buff, count);
for (c = 0; c < channels; c++) { if (channels) {
fm_demodulate(&sdr->chan[c].demod, samples[c], count, buff); for (c = 0; c < channels; c++)
fm_demodulate(&sdr->chan[c].demod, samples[c], count, buff);
} }
return count; return count;