Skip to content

Commit

Permalink
add direct sampling to rtl_sdr
Browse files Browse the repository at this point in the history
  • Loading branch information
rtlsdrblog committed Aug 24, 2023
1 parent 3662ef4 commit f3673e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/rtl_sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void usage(void)
"\t[-b output_block_size (default: 16 * 16384)]\n"
"\t[-n number of samples to read (default: 0, infinite)]\n"
"\t[-S force sync output (default: async)]\n"
"\t[-D enable direct sampling (default: off)]\n"
"\tfilename (a '-' dumps samples to stdout)\n\n");
exit(1);
}
Expand Down Expand Up @@ -113,6 +114,7 @@ int main(int argc, char **argv)
int r, opt;
int gain = 0;
int ppm_error = 0;
int direct_sampling = 0;
int sync_mode = 0;
FILE *file;
uint8_t *buffer;
Expand All @@ -122,7 +124,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:n:p:S")) != -1) {
while ((opt = getopt(argc, argv, "d:f:g:s:b:n:p:SD")) != -1) {
switch (opt) {
case 'd':
dev_index = verbose_device_search(optarg);
Expand All @@ -149,6 +151,9 @@ int main(int argc, char **argv)
case 'S':
sync_mode = 1;
break;
case 'D':
direct_sampling = 1;
break;
default:
usage();
break;
Expand Down Expand Up @@ -198,6 +203,11 @@ int main(int argc, char **argv)
#else
SetConsoleCtrlHandler( (PHANDLER_ROUTINE) sighandler, TRUE );
#endif

/* Set direct sampling */
if (direct_sampling)
verbose_direct_sampling(dev, 2);

/* Set the sample rate */
verbose_set_sample_rate(dev, samp_rate);

Expand Down
3 changes: 1 addition & 2 deletions src/rtl_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,8 @@ int main(int argc, char **argv)
#endif

/* Set direct sampling */
if (direct_sampling) {
if (direct_sampling)
verbose_direct_sampling(dev, 2);
}

/* Set the tuner error */
verbose_ppm_set(dev, ppm_error);
Expand Down

0 comments on commit f3673e7

Please sign in to comment.