diff --git a/dump1090.c b/dump1090.c index 8e84a60ac..7dc83339a 100644 --- a/dump1090.c +++ b/dump1090.c @@ -139,6 +139,7 @@ struct { /* RTLSDR */ int dev_index; + char* serial; int gain; int enable_agc; rtlsdr_dev_t *dev; @@ -260,6 +261,7 @@ static long long mstime(void) { void modesInitConfig(void) { Modes.gain = MODES_MAX_GAIN; Modes.dev_index = 0; + Modes.serial = NULL; Modes.enable_agc = 0; Modes.freq = MODES_DEFAULT_FREQ; Modes.filename = NULL; @@ -344,6 +346,10 @@ void modesInitRTLSDR(void) { fprintf(stderr, "No supported RTLSDR devices found.\n"); exit(1); } + if(Modes.serial != NULL){ + Modes.dev_index = rtlsdr_get_index_by_serial(Modes.serial); + printf("Found device with serial %s; selecting device index %d\n",Modes.serial,Modes.dev_index); + } fprintf(stderr, "Found %d device(s):\n", device_count); for (j = 0; j < device_count; j++) { @@ -2439,6 +2445,7 @@ int getTermRows() { void showHelp(void) { printf( "--device-index Select RTL device (default: 0).\n" +"--device-serial Select RTL device by USB serial number.\n" "--gain Set gain (default: max gain. Use -100 for auto-gain).\n" "--enable-agc Enable the Automatic Gain Control (default: off).\n" "--freq Set frequency (default: 1090 Mhz).\n" @@ -2507,6 +2514,8 @@ int main(int argc, char **argv) { if (!strcmp(argv[j],"--device-index") && more) { Modes.dev_index = atoi(argv[++j]); + } else if (!strcmp(argv[j],"--device-serial") && more) { + Modes.serial = argv[++j]; } else if (!strcmp(argv[j],"--gain") && more) { Modes.gain = atof(argv[++j])*10; /* Gain is in tens of DBs */ } else if (!strcmp(argv[j],"--enable-agc")) {