|
|
@ -60,6 +60,7 @@ |
|
|
|
#define MINIMAL_BUF_LENGTH 512 |
|
|
|
#define MINIMAL_BUF_LENGTH 512 |
|
|
|
#define MAXIMAL_BUF_LENGTH (256 * 16384) |
|
|
|
#define MAXIMAL_BUF_LENGTH (256 * 16384) |
|
|
|
#define CONSEQ_SQUELCH 4 |
|
|
|
#define CONSEQ_SQUELCH 4 |
|
|
|
|
|
|
|
#define AUTO_GAIN -100 |
|
|
|
|
|
|
|
|
|
|
|
static pthread_t demod_thread; |
|
|
|
static pthread_t demod_thread; |
|
|
|
static sem_t data_ready; |
|
|
|
static sem_t data_ready; |
|
|
@ -103,7 +104,7 @@ void usage(void) |
|
|
|
"\t (use multiple -f for scanning)\n" |
|
|
|
"\t (use multiple -f for scanning)\n" |
|
|
|
"\t[-s samplerate (default: 24000 Hz)]\n" |
|
|
|
"\t[-s samplerate (default: 24000 Hz)]\n" |
|
|
|
"\t[-d device_index (default: 0)]\n" |
|
|
|
"\t[-d device_index (default: 0)]\n" |
|
|
|
"\t[-g tuner_gain (default: -1dB)]\n" |
|
|
|
"\t[-g tuner_gain (default: automatic)]\n" |
|
|
|
"\t[-l squelch_level (default: 150)]\n" |
|
|
|
"\t[-l squelch_level (default: 150)]\n" |
|
|
|
"\t[-E freq sets lower edge (default: center)]\n" |
|
|
|
"\t[-E freq sets lower edge (default: center)]\n" |
|
|
|
"\tfilename (a '-' dumps samples to stdout)\n\n" |
|
|
|
"\tfilename (a '-' dumps samples to stdout)\n\n" |
|
|
@ -439,7 +440,7 @@ int main(int argc, char **argv) |
|
|
|
char *filename = NULL; |
|
|
|
char *filename = NULL; |
|
|
|
int n_read; |
|
|
|
int n_read; |
|
|
|
int r, opt; |
|
|
|
int r, opt; |
|
|
|
int i, gain = -10; // tenths of a dB
|
|
|
|
int i, gain = AUTO_GAIN; // tenths of a dB
|
|
|
|
uint8_t *buffer; |
|
|
|
uint8_t *buffer; |
|
|
|
uint32_t dev_index = 0; |
|
|
|
uint32_t dev_index = 0; |
|
|
|
int device_count; |
|
|
|
int device_count; |
|
|
@ -538,11 +539,19 @@ int main(int argc, char **argv) |
|
|
|
build_fir(&fm); |
|
|
|
build_fir(&fm); |
|
|
|
|
|
|
|
|
|
|
|
/* Set the tuner gain */ |
|
|
|
/* Set the tuner gain */ |
|
|
|
|
|
|
|
if (gain == AUTO_GAIN) { |
|
|
|
|
|
|
|
r = rtlsdr_set_tuner_gain_mode(dev, 0); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
r = rtlsdr_set_tuner_gain_mode(dev, 1); |
|
|
|
r = rtlsdr_set_tuner_gain(dev, gain); |
|
|
|
r = rtlsdr_set_tuner_gain(dev, gain); |
|
|
|
if (r < 0) |
|
|
|
} |
|
|
|
|
|
|
|
if (r != 0) { |
|
|
|
fprintf(stderr, "WARNING: Failed to set tuner gain.\n"); |
|
|
|
fprintf(stderr, "WARNING: Failed to set tuner gain.\n"); |
|
|
|
else |
|
|
|
} else if (gain == AUTO_GAIN) { |
|
|
|
|
|
|
|
fprintf(stderr, "Tuner gain set to automatic.\n"); |
|
|
|
|
|
|
|
} else { |
|
|
|
fprintf(stderr, "Tuner gain set to %0.2f dB.\n", gain/10.0); |
|
|
|
fprintf(stderr, "Tuner gain set to %0.2f dB.\n", gain/10.0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(strcmp(filename, "-") == 0) { /* Write samples to stdout */ |
|
|
|
if(strcmp(filename, "-") == 0) { /* Write samples to stdout */ |
|
|
|
fm.file = stdout; |
|
|
|
fm.file = stdout; |
|
|
|