From c32ed2866ef4e316f769bf0f217cabb736aaab4d Mon Sep 17 00:00:00 2001 From: Gluttton Date: Thu, 30 Jul 2020 23:22:15 +0300 Subject: [PATCH] limesdr: add ability to set normalized gain Add ability to set the combined normalized gain via command line options. By default the gain is equal to 0.75. Test: connect LimeSDR device, try to set different gain and check logs: $ ./dump1090 --device-type limesdr --limesdr-gain 0.01 $ ./dump1090 --device-type limesdr --limesdr-gain 0.5 $ ./dump1090 --device-type limesdr --limesdr-gain 0.99 Signed-off-by: Gluttton --- sdr_limesdr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdr_limesdr.c b/sdr_limesdr.c index 770edba..757fbae 100644 --- a/sdr_limesdr.c +++ b/sdr_limesdr.c @@ -59,6 +59,7 @@ static struct { bool is_stop; char verbosity; size_t oversample; + float gain; lms_info_str_t serial; int bytes_in_sample; iq_convert_fn converter; @@ -100,6 +101,7 @@ void limesdrInitConfig() LimeSDR.is_stop = false; LimeSDR.verbosity = LMS_LOG_INFO; LimeSDR.oversample = 0; // default oversample + LimeSDR.gain = 0.75; LimeSDR.serial[0] = '\0'; LimeSDR.bytes_in_sample = 2 * sizeof(int16_t); // hardcoded for LMS_FMT_I16 @@ -114,6 +116,7 @@ void limesdrShowHelp() printf("--limesdr-serial serial number of desired device\n"); printf("--limesdr-channel set number of an RX channel\n"); printf("--limesdr-oversample set RF oversampling ratio\n"); + printf("--limesdr-gain set normalized gain\n"); printf("\n"); } @@ -130,6 +133,8 @@ bool limesdrHandleOption(int argc, char **argv, int *jptr) LimeSDR.stream.channel = atoi(argv[++j]); } else if (!strcmp(argv[j], "--limesdr-oversample") && more) { LimeSDR.oversample = atoi(argv[++j]); + } else if (!strcmp(argv[j], "--limesdr-gain") && more) { + LimeSDR.gain = atof(argv[++j]); } else { return false; } @@ -208,7 +213,7 @@ bool limesdrOpen(void) goto error; } - if (LMS_SetNormalizedGain(LimeSDR.dev, LMS_CH_RX, LimeSDR.stream.channel, 0.85)) { + if (LMS_SetNormalizedGain(LimeSDR.dev, LMS_CH_RX, LimeSDR.stream.channel, LimeSDR.gain)) { limesdrLogHandler(LMS_LOG_ERROR, "unable to set gain"); goto error; }