Treat the magic agc setting as just another gain step.

The legacy -10 value is still supported for compatbility with old
configs, but new configs should just select an appropriate gain e.g.
60dB.

rtlsdr default gain continues to be the highest regular gain step (~ 49.6dB)
This commit is contained in:
Oliver Jowett 2021-07-19 17:32:51 +08:00
parent d4b3b03fe0
commit f3e498a62a
4 changed files with 11 additions and 8 deletions

View File

@ -102,6 +102,9 @@ if [ "${EXTRAS_NET_RO_INTERVAL:-1300}" != "0.2" ]; then EXTRA_OPTIONS="$EXTRA_OP
# special case for device index 0 (the default) # special case for device index 0 (the default)
if [ "${RECEIVER_SERIAL}" = "0" ]; then RECEIVER_SERIAL=""; fi if [ "${RECEIVER_SERIAL}" = "0" ]; then RECEIVER_SERIAL=""; fi
# special case for gain -10 -> gain 60
if [ "${RECEIVER_GAIN}" = "-10" ]; then RECEIVER_GAIN="60"; fi
# special case for ports set to zero (new config uses a blank entry for that) # special case for ports set to zero (new config uses a blank entry for that)
if [ "${NET_RAW_INPUT_PORTS}" = "0" ]; then NET_RAW_INPUT_PORTS=""; fi if [ "${NET_RAW_INPUT_PORTS}" = "0" ]; then NET_RAW_INPUT_PORTS=""; fi
if [ "${NET_RAW_OUTPUT_PORTS}" = "0" ]; then NET_RAW_OUTPUT_PORTS=""; fi if [ "${NET_RAW_OUTPUT_PORTS}" = "0" ]; then NET_RAW_OUTPUT_PORTS=""; fi

View File

@ -110,7 +110,7 @@ static void modesInitConfig(void) {
memset(&Modes, 0, sizeof(Modes)); memset(&Modes, 0, sizeof(Modes));
// Now initialise things that should not be 0/NULL to their defaults // Now initialise things that should not be 0/NULL to their defaults
Modes.gain = MODES_MAX_GAIN; Modes.gain = MODES_DEFAULT_GAIN;
Modes.freq = MODES_DEFAULT_FREQ; Modes.freq = MODES_DEFAULT_FREQ;
Modes.check_crc = 1; Modes.check_crc = 1;
Modes.fix_df = 1; Modes.fix_df = 1;
@ -340,7 +340,7 @@ static void showHelp(void)
" Decoder settings\n" " Decoder settings\n"
"\n" "\n"
// ------ 80 char limit ----------------------------------------------------------| // ------ 80 char limit ----------------------------------------------------------|
"--gain <db> Set gain (default: max gain. Use -10 for auto-gain)\n" "--gain <db> Set gain in dB (default: varies by SDR type)\n"
"--freq <hz> Set frequency (default: 1090 Mhz)\n" "--freq <hz> Set frequency (default: 1090 Mhz)\n"
"--fix Enable single-bit error correction using CRC\n" "--fix Enable single-bit error correction using CRC\n"
"--fix-2bit Enable two-bit error correction using CRC\n" "--fix-2bit Enable two-bit error correction using CRC\n"

View File

@ -92,8 +92,8 @@
#define MODES_RTL_BUF_SIZE (16*16384) // 256k #define MODES_RTL_BUF_SIZE (16*16384) // 256k
#define MODES_MAG_BUF_SAMPLES (MODES_RTL_BUF_SIZE / 2) // Each sample is 2 bytes #define MODES_MAG_BUF_SAMPLES (MODES_RTL_BUF_SIZE / 2) // Each sample is 2 bytes
#define MODES_MAG_BUFFERS 12 // Number of magnitude buffers (should be smaller than RTL_BUFFERS for flowcontrol to work) #define MODES_MAG_BUFFERS 12 // Number of magnitude buffers (should be smaller than RTL_BUFFERS for flowcontrol to work)
#define MODES_AUTO_GAIN -10 // Use automatic gain #define MODES_LEGACY_AUTO_GAIN -10 // old gain value for "use automatic gain"
#define MODES_MAX_GAIN 999999 // Use max available gain #define MODES_DEFAULT_GAIN 999999 // Use default SDR gain
#define MODES_MSG_SQUELCH_DB 4.0 // Minimum SNR, in dB #define MODES_MSG_SQUELCH_DB 4.0 // Minimum SNR, in dB
#define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors #define MODES_MSG_ENCODER_ERRS 3 // Maximum number of encoding errors

View File

@ -255,12 +255,12 @@ bool rtlsdrOpen(void)
RTLSDR.gains = gains; RTLSDR.gains = gains;
int selected = -1; int selected = -1;
if (Modes.gain == MODES_AUTO_GAIN) { if (Modes.gain == MODES_LEGACY_AUTO_GAIN) {
selected = numgains; selected = numgains;
} else if (Modes.gain == MODES_MAX_GAIN) { } else if (Modes.gain == MODES_DEFAULT_GAIN) {
selected = numgains - 1; selected = numgains - 1;
} else { } else {
for (int i = 0; i < numgains; ++i) { for (int i = 0; i <= numgains; ++i) {
if (selected == -1 || fabs(gains[i]/10.0 - Modes.gain) < fabs(gains[selected]/10.0 - Modes.gain)) if (selected == -1 || fabs(gains[i]/10.0 - Modes.gain) < fabs(gains[selected]/10.0 - Modes.gain))
selected = i; selected = i;
} }