mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-11-10 12:47:40 +01:00
allow user to select sync mode
Patch provided by 'airwave', Thanks! Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
7e6d2f55ee
commit
a58def7f58
16
src/main.c
16
src/main.c
@ -44,6 +44,7 @@ void usage(void)
|
||||
"\t[-d device_index (default: 0)]\n"
|
||||
"\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\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -67,6 +68,7 @@ int main(int argc, char **argv)
|
||||
int n_read;
|
||||
int r, opt;
|
||||
int i, gain = 0;
|
||||
int sync_mode = 0;
|
||||
FILE *file;
|
||||
uint8_t *buffer;
|
||||
uint32_t dev_index = 0;
|
||||
@ -74,8 +76,7 @@ int main(int argc, char **argv)
|
||||
uint32_t samp_rate = DEFAULT_SAMPLE_RATE;
|
||||
uint32_t out_block_size = DEFAULT_BUF_LENGTH;
|
||||
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:f:g:s:b:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:f:g:s:b:S::")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
dev_index = atoi(optarg);
|
||||
@ -92,6 +93,9 @@ int main(int argc, char **argv)
|
||||
case 'b':
|
||||
out_block_size = (uint32_t)atof(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
sync_mode = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
@ -177,7 +181,8 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "WARNING: Failed to reset buffers.\n");
|
||||
|
||||
fprintf(stderr, "Reading samples...\n");
|
||||
#if 0
|
||||
|
||||
if (sync_mode) {
|
||||
while (!do_exit) {
|
||||
r = rtlsdr_read_sync(dev, buffer, out_block_size, &n_read);
|
||||
if (r < 0)
|
||||
@ -190,10 +195,11 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
} else {
|
||||
rtlsdr_read_async(dev, rtlsdr_callback, (void *)file,
|
||||
DEFAULT_ASYNC_BUF_NUMBER, out_block_size);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (do_exit)
|
||||
fprintf(stderr, "\nUser cancel, exiting...\n");
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user