aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-03-20 20:07:11 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-05-15 21:46:29 +0200
commitfbdb9ece01c3778e0acb2aa6b55137d3f6c653d0 (patch)
treea22a627204fbb01252f742cb76dfec29a70b8fff /src/common
parent65694f3b809c3ada5d5a273d0dad7d9be45abd3e (diff)
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.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/sdr.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/common/sdr.c b/src/common/sdr.c
index d1b53fb..4205c21 100644
--- a/src/common/sdr.c
+++ b/src/common/sdr.c
@@ -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)
{
sdr_t *sdr = (sdr_t *)inst;
- float buff[num * 2];
+ float buffer[num * 2], *buff = NULL;
int c, s, ss;
int sent = 0;
- if (channels != sdr->channels) {
+ if (channels != sdr->channels && channels != 0) {
PDEBUG(DSDR, DEBUG_ERROR, "Invalid number of channels, please fix!\n");
abort();
}
/* process all channels */
- memset(buff, 0, sizeof(buff));
- for (c = 0; c < channels; c++) {
- /* switch to paging channel, if requested */
- if (on[c] && sdr->paging_channel)
- fm_modulate(&sdr->chan[sdr->paging_channel].mod, samples[c], num, buff);
- else
- fm_modulate(&sdr->chan[c].mod, samples[c], num, buff);
+ if (channels) {
+ memset(buffer, 0, sizeof(buffer));
+ buff = buffer;
+ for (c = 0; c < channels; c++) {
+ /* switch to paging channel, if requested */
+ if (on[c] && sdr->paging_channel)
+ 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) {
@@ -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)
{
sdr_t *sdr = (sdr_t *)inst;
- float buff[num * 2];
+ float buffer[num * 2], *buff = NULL;
int count = 0;
int c, s, ss;
+ if (channels) {
+ buff = buffer;
+ } else {
+ buff = (float *)samples;
+ }
+
#ifdef HAVE_UHD
if (sdr_use_uhd)
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_spectrum(buff, count);
- for (c = 0; c < channels; c++) {
- fm_demodulate(&sdr->chan[c].demod, samples[c], count, buff);
+ if (channels) {
+ for (c = 0; c < channels; c++)
+ fm_demodulate(&sdr->chan[c].demod, samples[c], count, buff);
}
return count;