mirror of https://github.com/drowe67/librtlsdr.git
specify number of seconds to run
parent
748e4564e9
commit
b09c635885
23
src/rtl_fm.c
23
src/rtl_fm.c
|
@ -121,6 +121,10 @@ static int32_t prev_if_band_center_freq = 0;
|
|||
enum trigExpr { crit_IN =0, crit_OUT, crit_LT, crit_GT };
|
||||
char * aCritStr[] = { "in", "out", "<", ">" };
|
||||
|
||||
time_t stop_time;
|
||||
int duration = 0;
|
||||
|
||||
|
||||
struct cmd_state
|
||||
{
|
||||
const char * filename;
|
||||
|
@ -296,6 +300,7 @@ void usage(void)
|
|||
#endif
|
||||
"\t[-o oversampling (default: 1, 4 recommended)]\n"
|
||||
"\t[-p ppm_error (default: 0)]\n"
|
||||
"\t[-R run_seconds] specify number of seconds to run\n"
|
||||
"\t[-E enable_option (default: none)]\n"
|
||||
"\t use multiple -E to enable multiple options\n"
|
||||
"\t edge: enable lower edge tuning\n"
|
||||
|
@ -1300,11 +1305,18 @@ static void rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx)
|
|||
unsigned char sampleMax;
|
||||
uint32_t sampleP, samplePowSum = 0.0;
|
||||
int samplePowCount = 0, step = 2;
|
||||
time_t rawtime;
|
||||
|
||||
if (do_exit) {
|
||||
return;}
|
||||
if (!ctx) {
|
||||
return;}
|
||||
time(&rawtime);
|
||||
if (duration > 0 && rawtime >= stop_time) {
|
||||
do_exit = 1;
|
||||
fprintf(stderr, "Time expired, exiting!\n");
|
||||
rtlsdr_cancel_async(dongle.dev);
|
||||
}
|
||||
if (s->mute) {
|
||||
if(muteLen > (int)len)
|
||||
muteLen = len;
|
||||
|
@ -1797,7 +1809,7 @@ int main(int argc, char **argv)
|
|||
controller_init(&controller);
|
||||
cmd_init(&cmd);
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:E:O:F:A:M:hTC:B:m:L:q:c:w:W:D:nHv")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:f:g:s:b:l:o:t:r:p:R:E:O:F:A:M:hTC:B:m:L:q:c:w:W:D:nHv")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
dongle.dev_index = verbose_device_search(optarg);
|
||||
|
@ -1861,6 +1873,15 @@ int main(int argc, char **argv)
|
|||
dongle.ppm_error = atoi(optarg);
|
||||
custom_ppm = 1;
|
||||
break;
|
||||
case 'R':
|
||||
time(&stop_time);
|
||||
duration = atoi(optarg);
|
||||
if (duration < 1) {
|
||||
fprintf(stderr, "Duration '%s' was not positive integer; will continue indefinitely\n", optarg);
|
||||
} else {
|
||||
stop_time += duration;
|
||||
}
|
||||
break;
|
||||
case 'E':
|
||||
if (strcmp("edge", optarg) == 0) {
|
||||
controller.edge = 1;}
|
||||
|
|
Loading…
Reference in New Issue