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 <gluttton@ukr.net>
This commit is contained in:
Gluttton 2020-07-30 23:22:15 +03:00
parent da1aeeeea6
commit c32ed2866e
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}