mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2025-01-13 11:47:21 +01:00
rtl_sdr, rtl_tcp: cleaned up gain handling
This commit is contained in:
parent
b290116ac7
commit
e042c36cb5
@ -52,7 +52,7 @@ void usage(void)
|
|||||||
"Usage:\t -f frequency_to_tune_to [Hz]\n"
|
"Usage:\t -f frequency_to_tune_to [Hz]\n"
|
||||||
"\t[-s samplerate (default: 2048000 Hz)]\n"
|
"\t[-s samplerate (default: 2048000 Hz)]\n"
|
||||||
"\t[-d device_index (default: 0)]\n"
|
"\t[-d device_index (default: 0)]\n"
|
||||||
"\t[-g tuner_gain (default: 0 dB)]\n"
|
"\t[-g tuner_gain (default: -1dB)]\n"
|
||||||
"\t[-b output_block_size (default: 16 * 16384)]\n"
|
"\t[-b output_block_size (default: 16 * 16384)]\n"
|
||||||
"\t[-S force sync output (default: async)]\n"
|
"\t[-S force sync output (default: async)]\n"
|
||||||
"\tfilename (a '-' dumps samples to stdout)\n\n");
|
"\tfilename (a '-' dumps samples to stdout)\n\n");
|
||||||
@ -99,12 +99,12 @@ 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 = 0;
|
int i, gain = -10; // tenths of a dB
|
||||||
int sync_mode = 0;
|
int sync_mode = 0;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
uint32_t dev_index = 0;
|
uint32_t dev_index = 0;
|
||||||
uint32_t frequency = 0;
|
uint32_t frequency = 100000000;
|
||||||
uint32_t samp_rate = DEFAULT_SAMPLE_RATE;
|
uint32_t samp_rate = DEFAULT_SAMPLE_RATE;
|
||||||
uint32_t out_block_size = DEFAULT_BUF_LENGTH;
|
uint32_t out_block_size = DEFAULT_BUF_LENGTH;
|
||||||
int device_count;
|
int device_count;
|
||||||
@ -118,7 +118,7 @@ int main(int argc, char **argv)
|
|||||||
frequency = (uint32_t)atof(optarg);
|
frequency = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
gain = (int)atof(optarg) * 10;
|
gain = (int)(atof(optarg) * 10);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
samp_rate = (uint32_t)atof(optarg);
|
samp_rate = (uint32_t)atof(optarg);
|
||||||
@ -145,7 +145,7 @@ int main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
dev_index = atoi(argv[1]);
|
dev_index = atoi(argv[1]);
|
||||||
samp_rate = atoi(argv[2])*1000;
|
samp_rate = atoi(argv[2])*1000;
|
||||||
gain=(int)atof(argv[3]) * 10;
|
gain=(int)(atof(argv[3]) * 10);
|
||||||
frequency = atoi(argv[4]);
|
frequency = atoi(argv[4]);
|
||||||
filename = argv[5];
|
filename = argv[5];
|
||||||
#endif
|
#endif
|
||||||
@ -210,7 +210,7 @@ int main(int argc, char **argv)
|
|||||||
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
|
||||||
fprintf(stderr, "Tuner gain set to %i dB.\n", gain);
|
fprintf(stderr, "Tuner gain set to %f dB.\n", gain/10.0);
|
||||||
|
|
||||||
if(strcmp(filename, "-") == 0) { /* Write samples to stdout */
|
if(strcmp(filename, "-") == 0) { /* Write samples to stdout */
|
||||||
file = stdout;
|
file = stdout;
|
||||||
|
@ -82,9 +82,10 @@ void usage(void)
|
|||||||
"[samplerate in kHz] [frequency in Hz] [device index]\n");
|
"[samplerate in kHz] [frequency in Hz] [device index]\n");
|
||||||
#else
|
#else
|
||||||
printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
|
printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
|
||||||
"Usage:\t -a listen address\n"
|
"Usage:\t[-a listen address]\n"
|
||||||
"\t[-p listen port (default: 1234)\n"
|
"\t[-p listen port (default: 1234)]\n"
|
||||||
"\t -f frequency to tune to [Hz]\n"
|
"\t[-f frequency to tune to [Hz]]\n"
|
||||||
|
"\t[-g tuner_gain (default: -1dB)]\n"
|
||||||
"\t[-s samplerate in Hz (default: 2048000 Hz)]\n"
|
"\t[-s samplerate in Hz (default: 2048000 Hz)]\n"
|
||||||
"\t[-d device index (default: 0)]\n");
|
"\t[-d device index (default: 0)]\n");
|
||||||
#endif
|
#endif
|
||||||
@ -307,10 +308,11 @@ int main(int argc, char **argv)
|
|||||||
int r, opt, i;
|
int r, opt, i;
|
||||||
char* addr = "127.0.0.1";
|
char* addr = "127.0.0.1";
|
||||||
int port = 1234;
|
int port = 1234;
|
||||||
uint32_t frequency = 0, samp_rate = 2048000;
|
uint32_t frequency = 100000000, samp_rate = 2048000;
|
||||||
struct sockaddr_in local, remote;
|
struct sockaddr_in local, remote;
|
||||||
int device_count;
|
int device_count;
|
||||||
uint32_t dev_index = 0, gain = -10;
|
uint32_t dev_index = 0;
|
||||||
|
int gain = -10; // tenths of a dB
|
||||||
struct llist *curelem,*prev;
|
struct llist *curelem,*prev;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
void *status;
|
void *status;
|
||||||
@ -325,7 +327,7 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
while ((opt = getopt(argc, argv, "a:p:f:s:d:")) != -1) {
|
while ((opt = getopt(argc, argv, "a:p:f:g:s:d:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
dev_index = atoi(optarg);
|
dev_index = atoi(optarg);
|
||||||
@ -333,6 +335,9 @@ int main(int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
frequency = (uint32_t)atof(optarg);
|
frequency = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'g':
|
||||||
|
gain = (int)(atof(optarg) * 10);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
samp_rate = (uint32_t)atof(optarg);
|
samp_rate = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
@ -403,7 +408,7 @@ int main(int argc, char **argv)
|
|||||||
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
|
||||||
fprintf(stderr, "Tuner gain set to %i dB.\n", gain);
|
fprintf(stderr, "Tuner gain set to %f dB.\n", gain/10.0);
|
||||||
|
|
||||||
/* Reset endpoint before we start reading from it (mandatory) */
|
/* Reset endpoint before we start reading from it (mandatory) */
|
||||||
r = rtlsdr_reset_buffer(dev);
|
r = rtlsdr_reset_buffer(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user