summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2012-05-06 00:34:13 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2012-05-06 00:34:13 +0200
commit9167a01248cdc28f5145cd1b2c5abfdc57a099bf (patch)
tree56af3668b3984b06e95bc061e0c24fa476a11119
parente9251da6e238a64018d3a4b64d4d4593aa7acbfb (diff)
consolidate program arguments
-rw-r--r--include/Makefile.am2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/rtl_sdr.c (renamed from src/main.c)10
-rw-r--r--src/rtl_tcp.c29
5 files changed, 23 insertions, 23 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 1fcc60c..c4ed41d 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -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)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6d23607..e84c303 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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}
diff --git a/src/Makefile.am b/src/Makefile.am
index f8cc5d6..8dce817 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/main.c b/src/rtl_sdr.c
index 9cdf2da..232ab77 100644
--- a/src/main.c
+++ b/src/rtl_sdr.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
diff --git a/src/rtl_tcp.c b/src/rtl_tcp.c
index 89019c0..2fb1b34 100644
--- a/src/rtl_tcp.c
+++ b/src/rtl_tcp.c
@@ -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);