aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-03-16 18:06:45 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-05-15 21:46:26 +0200
commit1445ca2facfebfb175ff6234a3ab27b21123d2d7 (patch)
treee683aec25bec0f69cff165731c5ce6eedf6d7812 /src/common
parent369bda87a9d08969b52a2323da4f4a699ee94800 (diff)
SDR: Add option to send (previously recorded) IQ data instead of TX data
Diffstat (limited to 'src/common')
-rw-r--r--src/common/main_common.c11
-rw-r--r--src/common/sdr.c28
-rw-r--r--src/common/sdr.h2
3 files changed, 34 insertions, 7 deletions
diff --git a/src/common/main_common.c b/src/common/main_common.c
index 634e94c..4d74685 100644
--- a/src/common/main_common.c
+++ b/src/common/main_common.c
@@ -68,6 +68,7 @@ double sdr_rx_gain = 0, sdr_tx_gain = 0;
const char *write_iq_rx_wave = NULL;
const char *write_iq_tx_wave = NULL;
const char *read_iq_rx_wave = NULL;
+const char *read_iq_tx_wave = NULL;
void print_help_common(const char *arg0, const char *ext_usage)
{
printf("Usage: %s -k <kanal/channel> %s[options] [station-id]\n", arg0, ext_usage);
@@ -148,6 +149,8 @@ void print_help_common(const char *arg0, const char *ext_usage)
printf(" Write transmitted IQ data to given wave file.\n");
printf(" --read-iq-rx-wave <file>\n");
printf(" Replace received IQ data by given wave file.\n");
+ printf(" --read-iq-tx-wave <file>\n");
+ printf(" Replace transmitted IQ data by given wave file.\n");
#endif
printf("\nNetwork specific options:\n");
}
@@ -174,6 +177,7 @@ void print_hotkeys_common(void)
#define OPT_WRITE_IQ_RX_WAVE 1105
#define OPT_WRITE_IQ_TX_WAVE 1106
#define OPT_READ_IQ_RX_WAVE 1107
+#define OPT_READ_IQ_TX_WAVE 1108
static struct option long_options_common[] = {
{"help", 0, 0, 'h'},
@@ -204,6 +208,7 @@ static struct option long_options_common[] = {
{"write-iq-rx-wave", 1, 0, OPT_WRITE_IQ_RX_WAVE},
{"write-iq-tx-wave", 1, 0, OPT_WRITE_IQ_TX_WAVE},
{"read-iq-rx-wave", 1, 0, OPT_READ_IQ_RX_WAVE},
+ {"read-iq-tx-wave", 1, 0, OPT_READ_IQ_TX_WAVE},
{0, 0, 0, 0}
};
@@ -379,6 +384,10 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
read_iq_rx_wave = strdup(optarg);
*skip_args += 2;
break;
+ case OPT_READ_IQ_TX_WAVE:
+ read_iq_tx_wave = strdup(optarg);
+ *skip_args += 2;
+ break;
default:
exit (0);
}
@@ -461,7 +470,7 @@ void main_common(int *quit, int latency, int interval, void (*myhandler)(void),
#endif
#ifdef HAVE_SDR
- rc = sdr_init(sdr_uhd, sdr_soapy, sdr_args, sdr_rx_gain, sdr_tx_gain, write_iq_rx_wave, write_iq_tx_wave, read_iq_rx_wave);
+ rc = sdr_init(sdr_uhd, sdr_soapy, sdr_args, sdr_rx_gain, sdr_tx_gain, write_iq_rx_wave, write_iq_tx_wave, read_iq_rx_wave, read_iq_tx_wave);
if (rc < 0)
return;
#endif
diff --git a/src/common/sdr.c b/src/common/sdr.c
index 372824d..dfb1614 100644
--- a/src/common/sdr.c
+++ b/src/common/sdr.c
@@ -52,14 +52,15 @@ typedef struct sdr {
wave_rec_t wave_rx_rec;
wave_rec_t wave_tx_rec;
wave_play_t wave_rx_play;
+ wave_play_t wave_tx_play;
} sdr_t;
static int sdr_use_uhd, sdr_use_soapy;
static const char *sdr_device_args;
static double sdr_rx_gain, sdr_tx_gain;
-const char *sdr_write_iq_rx_wave, *sdr_write_iq_tx_wave, *sdr_read_iq_rx_wave;
+const char *sdr_write_iq_rx_wave, *sdr_write_iq_tx_wave, *sdr_read_iq_rx_wave, *sdr_read_iq_tx_wave;
-int sdr_init(int sdr_uhd, int sdr_soapy, const char *device_args, double rx_gain, double tx_gain, const char *write_iq_rx_wave, const char *write_iq_tx_wave, const char *read_iq_rx_wave)
+int sdr_init(int sdr_uhd, int sdr_soapy, const char *device_args, double rx_gain, double tx_gain, const char *write_iq_rx_wave, const char *write_iq_tx_wave, const char *read_iq_rx_wave, const char *read_iq_tx_wave)
{
sdr_use_uhd = sdr_uhd;
sdr_use_soapy = sdr_soapy;
@@ -69,6 +70,7 @@ int sdr_init(int sdr_uhd, int sdr_soapy, const char *device_args, double rx_gain
sdr_write_iq_rx_wave = write_iq_rx_wave;
sdr_write_iq_tx_wave = write_iq_tx_wave;
sdr_read_iq_rx_wave = read_iq_rx_wave;
+ sdr_read_iq_tx_wave = read_iq_tx_wave;
return 0;
}
@@ -186,21 +188,28 @@ void *sdr_open(const char __attribute__((__unused__)) *audiodev, double *tx_freq
if (sdr_write_iq_rx_wave) {
rc = wave_create_record(&sdr->wave_rx_rec, sdr_write_iq_rx_wave, sdr->samplerate, 2, 1.0);
if (rc < 0) {
- PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
+ PDEBUG(DSDR, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto error;
}
}
if (sdr_write_iq_tx_wave) {
rc = wave_create_record(&sdr->wave_tx_rec, sdr_write_iq_tx_wave, sdr->samplerate, 2, 1.0);
if (rc < 0) {
- PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
+ PDEBUG(DSDR, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto error;
}
}
if (sdr_read_iq_rx_wave) {
rc = wave_create_playback(&sdr->wave_rx_play, sdr_read_iq_rx_wave, sdr->samplerate, 2, 1.0);
if (rc < 0) {
- PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
+ PDEBUG(DSDR, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
+ goto error;
+ }
+ }
+ if (sdr_read_iq_tx_wave) {
+ rc = wave_create_playback(&sdr->wave_tx_play, sdr_read_iq_tx_wave, sdr->samplerate, 2, 1.0);
+ if (rc < 0) {
+ PDEBUG(DSDR, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
goto error;
}
}
@@ -262,6 +271,7 @@ void sdr_close(void *inst)
wave_destroy_record(&sdr->wave_rx_rec);
wave_destroy_record(&sdr->wave_tx_rec);
wave_destroy_playback(&sdr->wave_rx_play);
+ wave_destroy_playback(&sdr->wave_tx_play);
free(sdr->chan);
free(sdr);
sdr = NULL;
@@ -298,6 +308,14 @@ int sdr_write(void *inst, sample_t **samples, int num, enum paging_signal __attr
}
wave_write(&sdr->wave_tx_rec, spl_list, num);
}
+ if (sdr->wave_tx_play.fp) {
+ sample_t spl[2][num], *spl_list[2] = { spl[0], spl[1] };
+ wave_read(&sdr->wave_tx_play, spl_list, num);
+ for (s = 0, ss = 0; s < num; s++) {
+ buff[ss++] = spl[0][s];
+ buff[ss++] = spl[1][s];
+ }
+ }
#ifdef HAVE_UHD
if (sdr_use_uhd)
diff --git a/src/common/sdr.h b/src/common/sdr.h
index 0d02e0f..e1bbd65 100644
--- a/src/common/sdr.h
+++ b/src/common/sdr.h
@@ -1,5 +1,5 @@
-int sdr_init(int sdr_uhd, int sdr_soapy, const char *device_args, double rx_gain, double tx_gain, const char *write_iq_rx_wave, const char *write_iq_tx_wave, const char *read_iq_rx_wave);
+int sdr_init(int sdr_uhd, int sdr_soapy, const char *device_args, double rx_gain, double tx_gain, const char *write_iq_rx_wave, const char *write_iq_tx_wave, const char *read_iq_rx_wave, const char *read_iq_tx_wave);
int sdr_start(void *inst);
void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, double paging_frequency, int samplerate, double bandwidth, double sample_deviation);
void sdr_close(void *inst);