From 90afc43af716bee14031c97a3c20392a7c115976 Mon Sep 17 00:00:00 2001 From: muttoni Date: Sat, 24 Sep 2016 23:44:17 -0300 Subject: [PATCH] Added option '-w' to rtl_sdr that allows setting the tuner bandwidth. --- src/rtl_sdr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rtl_sdr.c b/src/rtl_sdr.c index e6537ca..1ec64c3 100644 --- a/src/rtl_sdr.c +++ b/src/rtl_sdr.c @@ -35,6 +35,7 @@ #include "convenience/convenience.h" #define DEFAULT_SAMPLE_RATE 2048000 +#define DEFAULT_BANDWIDTH 0 /* automatic bandwidth */ #define DEFAULT_BUF_LENGTH (16 * 16384) #define MINIMAL_BUF_LENGTH 512 #define MAXIMAL_BUF_LENGTH (256 * 16384) @@ -49,6 +50,7 @@ void usage(void) "rtl_sdr, an I/Q recorder for RTL2832 based DVB-T receivers\n\n" "Usage:\t -f frequency_to_tune_to [Hz]\n" "\t[-s samplerate (default: 2048000 Hz)]\n" + "\t[-w tuner_bandwidth (default: automatic)]\n" "\t[-d device_index (default: 0)]\n" "\t[-g gain (default: 0 for auto)]\n" "\t[-p ppm_error (default: 0)]\n" @@ -118,10 +120,11 @@ int main(int argc, char **argv) int dev_index = 0; int dev_given = 0; uint32_t frequency = 100000000; + uint32_t bandwidth = DEFAULT_BANDWIDTH; uint32_t samp_rate = DEFAULT_SAMPLE_RATE; uint32_t out_block_size = DEFAULT_BUF_LENGTH; - while ((opt = getopt(argc, argv, "d:f:g:s:b:n:p:S")) != -1) { + while ((opt = getopt(argc, argv, "d:f:g:s:w:b:n:p:S")) != -1) { switch (opt) { case 'd': dev_index = verbose_device_search(optarg); @@ -136,6 +139,9 @@ int main(int argc, char **argv) case 's': samp_rate = (uint32_t)atofs(optarg); break; + case 'w': + bandwidth = (uint32_t)atofs(optarg); + break; case 'p': ppm_error = atoi(optarg); break; @@ -200,6 +206,9 @@ int main(int argc, char **argv) /* Set the sample rate */ verbose_set_sample_rate(dev, samp_rate); + /* Set the tuner bandwidth */ + verbose_set_bandwidth(dev, bandwidth); + /* Set the frequency */ verbose_set_frequency(dev, frequency);