mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-11-12 21:42:52 +01:00
consolidate program arguments
This commit is contained in:
parent
e9251da6e2
commit
9167a01248
@ -1,5 +1,5 @@
|
|||||||
rtlsdr_HEADERS = rtl-sdr.h rtl-sdr_export.h
|
rtlsdr_HEADERS = rtl-sdr.h rtl-sdr_export.h
|
||||||
|
|
||||||
noinst_HEADERS = rtlsdr_i2c.h tuner_e4k.h tuner_fc0012.h tuner_fc0013.h tuner_fc2580.h
|
noinst_HEADERS = reg_field.h rtlsdr_i2c.h tuner_e4k.h tuner_fc0012.h tuner_fc0013.h tuner_fc2580.h
|
||||||
|
|
||||||
rtlsdrdir = $(includedir)
|
rtlsdrdir = $(includedir)
|
||||||
|
@ -57,7 +57,7 @@ endif()
|
|||||||
########################################################################
|
########################################################################
|
||||||
# Build utility
|
# Build utility
|
||||||
########################################################################
|
########################################################################
|
||||||
add_executable(rtl_sdr main.c)
|
add_executable(rtl_sdr rtl_sdr.c)
|
||||||
add_executable(rtl_tcp rtl_tcp.c)
|
add_executable(rtl_tcp rtl_tcp.c)
|
||||||
target_link_libraries(rtl_sdr rtlsdr_static
|
target_link_libraries(rtl_sdr rtlsdr_static
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
|
@ -11,7 +11,8 @@ librtlsdr_la_SOURCES = rtl-sdr.c tuner_e4k.c tuner_fc0012.c tuner_fc0013.c tuner
|
|||||||
librtlsdr_la_LDFALGS = -version-info $(LIBVERSION)
|
librtlsdr_la_LDFALGS = -version-info $(LIBVERSION)
|
||||||
|
|
||||||
bin_PROGRAMS = rtl_sdr rtl_tcp
|
bin_PROGRAMS = rtl_sdr rtl_tcp
|
||||||
rtl_sdr_SOURCES = main.c
|
|
||||||
|
rtl_sdr_SOURCES = rtl_sdr.c
|
||||||
rtl_sdr_LDADD = librtlsdr.la
|
rtl_sdr_LDADD = librtlsdr.la
|
||||||
|
|
||||||
rtl_tcp_SOURCES = rtl_tcp.c
|
rtl_tcp_SOURCES = rtl_tcp.c
|
||||||
|
@ -45,7 +45,7 @@ void usage(void)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fprintf(stderr,"rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
|
fprintf(stderr,"rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
|
||||||
"Usage:\t rtl-sdr-win.exe [device_index] [samplerate in kHz] "
|
"Usage:\t rtl-sdr-win.exe [device_index] [samplerate in kHz] "
|
||||||
"[gain] [frequency in hz] [filename]\n");
|
"[gain] [frequency in Hz] [filename]\n");
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"rtl-sdr, an I/Q recorder for RTL2832 based DVB-T receivers\n\n"
|
"rtl-sdr, an I/Q recorder for RTL2832 based DVB-T receivers\n\n"
|
||||||
@ -55,7 +55,7 @@ void usage(void)
|
|||||||
"\t[-g tuner_gain (default: 0 dB)]\n"
|
"\t[-g tuner_gain (default: 0 dB)]\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"
|
||||||
"\toutput_filename (a '-' dumps samples to stdout)\n\n");
|
"\tfilename (a '-' dumps samples to stdout)\n\n");
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -118,10 +118,10 @@ int main(int argc, char **argv)
|
|||||||
frequency = (uint32_t)atof(optarg);
|
frequency = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
gain = atoi(optarg);
|
gain = (int)atof(optarg) * 10;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
samp_rate = (int)atof(optarg);
|
samp_rate = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
out_block_size = (uint32_t)atof(optarg);
|
out_block_size = (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=atoi(argv[3]);
|
gain=(int)atof(argv[3]) * 10;
|
||||||
frequency = atoi(argv[4]);
|
frequency = atoi(argv[4]);
|
||||||
filename = argv[5];
|
filename = argv[5];
|
||||||
#endif
|
#endif
|
@ -79,15 +79,14 @@ void usage(void)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
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 rtl-sdr-win.exe [listen addr] [listen port] "
|
"Usage:\t rtl-sdr-win.exe [listen addr] [listen port] "
|
||||||
"[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[-s samplerate in kHz (default: 2048 kHz)]\n"
|
"\t[-s samplerate in Hz (default: 2048000 Hz)]\n"
|
||||||
"\t[-d device index (default: 0)]\n"
|
"\t[-d device index (default: 0)]\n");
|
||||||
"\toutput filename\n");
|
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -277,12 +276,13 @@ static void *command_worker(void *arg)
|
|||||||
}
|
}
|
||||||
switch(cmd.cmd) {
|
switch(cmd.cmd) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
printf("set freq %d\n", cmd.param);
|
printf("set freq %d\n", cmd.param);
|
||||||
rtlsdr_set_center_freq(dev, cmd.param);
|
rtlsdr_set_center_freq(dev, cmd.param);
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
rtlsdr_set_tuner_gain(dev, cmd.param);
|
printf("set gain %d\n", cmd.param);
|
||||||
break;
|
rtlsdr_set_tuner_gain(dev, cmd.param);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -315,11 +315,14 @@ int main(int argc, char **argv)
|
|||||||
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:s:d:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'd':
|
||||||
|
dev_index = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
frequency = atoi(optarg);
|
frequency = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
samp_rate = atoi(optarg)*1000;
|
samp_rate = (uint32_t)atof(optarg);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
addr = optarg;
|
addr = optarg;
|
||||||
@ -327,9 +330,6 @@ int main(int argc, char **argv)
|
|||||||
case 'p':
|
case 'p':
|
||||||
port = atoi(optarg);
|
port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
|
||||||
dev_index = atoi(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
@ -398,7 +398,6 @@ int main(int argc, char **argv)
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
fprintf(stderr, "WARNING: Failed to reset buffers.\n");
|
fprintf(stderr, "WARNING: Failed to reset buffers.\n");
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_init(&exit_cond_lock, NULL);
|
pthread_mutex_init(&exit_cond_lock, NULL);
|
||||||
pthread_mutex_init(&ll_mutex, NULL);
|
pthread_mutex_init(&ll_mutex, NULL);
|
||||||
pthread_mutex_init(&exit_cond_lock, NULL);
|
pthread_mutex_init(&exit_cond_lock, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user