|
|
@ -44,6 +44,7 @@ void usage(void) |
|
|
|
"\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: 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" |
|
|
|
"\toutput filename\n"); |
|
|
|
"\toutput filename\n"); |
|
|
|
exit(1); |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
} |
|
|
@ -67,6 +68,7 @@ int main(int argc, char **argv) |
|
|
|
int n_read; |
|
|
|
int n_read; |
|
|
|
int r, opt; |
|
|
|
int r, opt; |
|
|
|
int i, gain = 0; |
|
|
|
int i, gain = 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; |
|
|
@ -74,8 +76,7 @@ int main(int argc, char **argv) |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "d:f:g:s:b:S::")) != -1) { |
|
|
|
while ((opt = getopt(argc, argv, "d:f:g:s:b:")) != -1) { |
|
|
|
|
|
|
|
switch (opt) { |
|
|
|
switch (opt) { |
|
|
|
case 'd': |
|
|
|
case 'd': |
|
|
|
dev_index = atoi(optarg); |
|
|
|
dev_index = atoi(optarg); |
|
|
@ -92,6 +93,9 @@ int main(int argc, char **argv) |
|
|
|
case 'b': |
|
|
|
case 'b': |
|
|
|
out_block_size = (uint32_t)atof(optarg); |
|
|
|
out_block_size = (uint32_t)atof(optarg); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'S': |
|
|
|
|
|
|
|
sync_mode = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
usage(); |
|
|
|
usage(); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -177,7 +181,8 @@ int main(int argc, char **argv) |
|
|
|
fprintf(stderr, "WARNING: Failed to reset buffers.\n"); |
|
|
|
fprintf(stderr, "WARNING: Failed to reset buffers.\n"); |
|
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "Reading samples...\n"); |
|
|
|
fprintf(stderr, "Reading samples...\n"); |
|
|
|
#if 0 |
|
|
|
|
|
|
|
|
|
|
|
if (sync_mode) { |
|
|
|
while (!do_exit) { |
|
|
|
while (!do_exit) { |
|
|
|
r = rtlsdr_read_sync(dev, buffer, out_block_size, &n_read); |
|
|
|
r = rtlsdr_read_sync(dev, buffer, out_block_size, &n_read); |
|
|
|
if (r < 0) |
|
|
|
if (r < 0) |
|
|
@ -190,10 +195,11 @@ int main(int argc, char **argv) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
} else { |
|
|
|
rtlsdr_read_async(dev, rtlsdr_callback, (void *)file, |
|
|
|
rtlsdr_read_async(dev, rtlsdr_callback, (void *)file, |
|
|
|
DEFAULT_ASYNC_BUF_NUMBER, out_block_size); |
|
|
|
DEFAULT_ASYNC_BUF_NUMBER, out_block_size); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (do_exit) |
|
|
|
if (do_exit) |
|
|
|
fprintf(stderr, "\nUser cancel, exiting...\n"); |
|
|
|
fprintf(stderr, "\nUser cancel, exiting...\n"); |
|
|
|
else |
|
|
|
else |
|
|
|