diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2017-03-18 09:30:26 +0100 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2017-05-15 21:46:27 +0200 |
commit | 9dda9e1efc2ff5b820438524c666900f93fe3a72 (patch) | |
tree | e43aa8afb434e394ded1b5ff7198fc103dd7e641 /src/common/uhd.c | |
parent | 1445ca2facfebfb175ff6234a3ab27b21123d2d7 (diff) |
SDR: Add option to set IF bandwidth. If not defined, sampling rate is used.
Diffstat (limited to 'src/common/uhd.c')
-rw-r--r-- | src/common/uhd.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/common/uhd.c b/src/common/uhd.c index 1423703..dcbc390 100644 --- a/src/common/uhd.c +++ b/src/common/uhd.c @@ -45,10 +45,10 @@ static time_t tx_time_secs = 0; static double tx_time_fract_sec = 0.0; static int rx_gap = 0; /* if we missed samples, we fill our rx data with zeroes */ -int uhd_open(const char *device_args, double tx_frequency, double rx_frequency, double rate, double rx_gain, double tx_gain) +int uhd_open(const char *device_args, double tx_frequency, double rx_frequency, double rate, double rx_gain, double tx_gain, double bandwidth) { uhd_error error; - double got_frequency, got_rate, got_gain; + double got_frequency, got_rate, got_gain, got_bandwidth; size_t channel = 0; samplerate = rate; @@ -202,6 +202,42 @@ int uhd_open(const char *device_args, double tx_frequency, double rx_frequency, return -EINVAL; } + /* set bandwidth */ + if (uhd_usrp_set_tx_bandwidth(usrp, bandwidth, channel) != 0) { + PDEBUG(DUHD, DEBUG_ERROR, "Failed to set TX bandwidth to %.0f Hz\n", bandwidth); + uhd_close(); + return -EIO; + } + if (uhd_usrp_set_rx_bandwidth(usrp, bandwidth, channel) != 0) { + PDEBUG(DUHD, DEBUG_ERROR, "Failed to set RX bandwidth to %.0f Hz\n", bandwidth); + uhd_close(); + return -EIO; + } + + /* see what bandwidth actually is */ + error = uhd_usrp_get_tx_bandwidth(usrp, channel, &got_bandwidth); + if (error) { + PDEBUG(DUHD, DEBUG_ERROR, "Failed to get TX bandwidth\n"); + uhd_close(); + return -EIO; + } + if (got_bandwidth != bandwidth) { + PDEBUG(DUHD, DEBUG_ERROR, "Given TX bandwidth %.0f Hz is not supported, try %0.f Hz\n", bandwidth, got_bandwidth); + uhd_close(); + return -EINVAL; + } + error = uhd_usrp_get_rx_bandwidth(usrp, channel, &got_bandwidth); + if (error) { + PDEBUG(DUHD, DEBUG_ERROR, "Failed to get TX bandwidth\n"); + uhd_close(); + return -EIO; + } + if (got_bandwidth != bandwidth) { + PDEBUG(DUHD, DEBUG_ERROR, "Given RX bandwidth %.0f Hz is not supported, try %0.f Hz\n", bandwidth, got_bandwidth); + uhd_close(); + return -EINVAL; + } + /* set up streamer */ memset(&stream_args, 0, sizeof(stream_args)); stream_args.cpu_format = "fc32"; |