consolidate program arguments

master
Dimitri Stolnikov 13 years ago
parent e9251da6e2
commit 9167a01248
  1. 2
      include/Makefile.am
  2. 2
      src/CMakeLists.txt
  3. 3
      src/Makefile.am
  4. 10
      src/rtl_sdr.c
  5. 29
      src/rtl_tcp.c

@ -1,5 +1,5 @@
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)

@ -57,7 +57,7 @@ endif()
########################################################################
# Build utility
########################################################################
add_executable(rtl_sdr main.c)
add_executable(rtl_sdr rtl_sdr.c)
add_executable(rtl_tcp rtl_tcp.c)
target_link_libraries(rtl_sdr rtlsdr_static
${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)
bin_PROGRAMS = rtl_sdr rtl_tcp
rtl_sdr_SOURCES = main.c
rtl_sdr_SOURCES = rtl_sdr.c
rtl_sdr_LDADD = librtlsdr.la
rtl_tcp_SOURCES = rtl_tcp.c

@ -45,7 +45,7 @@ void usage(void)
#ifdef _WIN32
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] "
"[gain] [frequency in hz] [filename]\n");
"[gain] [frequency in Hz] [filename]\n");
#else
fprintf(stderr,
"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[-b output_block_size (default: 16 * 16384)]\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
exit(1);
}
@ -118,10 +118,10 @@ int main(int argc, char **argv)
frequency = (uint32_t)atof(optarg);
break;
case 'g':
gain = atoi(optarg);
gain = (int)atof(optarg) * 10;
break;
case 's':
samp_rate = (int)atof(optarg);
samp_rate = (uint32_t)atof(optarg);
break;
case 'b':
out_block_size = (uint32_t)atof(optarg);
@ -145,7 +145,7 @@ int main(int argc, char **argv)
usage();
dev_index = atoi(argv[1]);
samp_rate = atoi(argv[2])*1000;
gain=atoi(argv[3]);
gain=(int)atof(argv[3]) * 10;
frequency = atoi(argv[4]);
filename = argv[5];
#endif

@ -79,15 +79,14 @@ void usage(void)
#ifdef _WIN32
printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
"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
printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n"
"Usage:\t -a listen address\n"
"\t[-p listen port (default: 1234)\n"
"\t -f frequency to tune to [Hz]\n"
"\t[-s samplerate in kHz (default: 2048 kHz)]\n"
"\t[-d device index (default: 0)]\n"
"\toutput filename\n");
"\t[-s samplerate in Hz (default: 2048000 Hz)]\n"
"\t[-d device index (default: 0)]\n");
#endif
exit(1);
}
@ -277,12 +276,13 @@ static void *command_worker(void *arg)
}
switch(cmd.cmd) {
case 0x01:
printf("set freq %d\n", cmd.param);
rtlsdr_set_center_freq(dev, cmd.param);
break;
printf("set freq %d\n", cmd.param);
rtlsdr_set_center_freq(dev, cmd.param);
break;
case 0x04:
rtlsdr_set_tuner_gain(dev, cmd.param);
break;
printf("set gain %d\n", cmd.param);
rtlsdr_set_tuner_gain(dev, cmd.param);
break;
default:
break;
}
@ -315,11 +315,14 @@ int main(int argc, char **argv)
struct sigaction sigact;
while ((opt = getopt(argc, argv, "a:p:f:s:d:")) != -1) {
switch (opt) {
case 'd':
dev_index = atoi(optarg);
break;
case 'f':
frequency = atoi(optarg);
frequency = (uint32_t)atof(optarg);
break;
case 's':
samp_rate = atoi(optarg)*1000;
samp_rate = (uint32_t)atof(optarg);
break;
case 'a':
addr = optarg;
@ -327,9 +330,6 @@ int main(int argc, char **argv)
case 'p':
port = atoi(optarg);
break;
case 'd':
dev_index = atoi(optarg);
break;
default:
usage();
break;
@ -398,7 +398,6 @@ int main(int argc, char **argv)
if (r < 0)
fprintf(stderr, "WARNING: Failed to reset buffers.\n");
pthread_mutex_init(&exit_cond_lock, NULL);
pthread_mutex_init(&ll_mutex, NULL);
pthread_mutex_init(&exit_cond_lock, NULL);

Loading…
Cancel
Save