From 513a11d45427c83361081e69db9e969a66a101f5 Mon Sep 17 00:00:00 2001 From: Chris Osborn Date: Wed, 13 Apr 2016 12:02:33 -0700 Subject: [PATCH] Limit carrier/idle generation for input with delays For non-interactive output (writing to an audio file), generate the idle output carrier for same duration that the input is idle. Makes this case generate an output .wav file of just over 1 second duration: { echo hello; sleep 1; echo world; } | minimodem --tx -f /tmp/xx.wav 300 --- src/minimodem.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/minimodem.c b/src/minimodem.c index 7f3e9a9..4b1a036 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -163,6 +163,14 @@ static void fsk_transmit_stdin( FD_ZERO(&fdset); FD_SET(fd, &fdset); struct timeval tv_idletimeout = { 0, 0 }; + + if ( !tx_interactive ) { + // When stdin blocks we "emit idle tone", for a duration of + // idle_carrier_usec. If !tx_interactive (i.e. writing to an + // audio file) make the select timeout the same duration. + tv_idletimeout.tv_usec = idle_carrier_usec; + } + if( block_input || select(fd+1, &fdset, NULL, NULL, &tv_idletimeout) ) { n_read = read(fd, &buf, sizeof(buf));