Merge pull request #1139 from martinling/tx-flush

Support flushing the device TX buffer before ending transmission
This commit is contained in:
Michael Ossmann
2022-09-14 05:45:40 -04:00
committed by GitHub
3 changed files with 91 additions and 2 deletions

View File

@@ -322,6 +322,7 @@ char* u64toa(uint64_t val, t_u64toa* str)
}
static volatile bool do_exit = false;
static volatile bool interrupted = false;
#ifdef _WIN32
static HANDLE interrupt_handle;
#endif
@@ -642,6 +643,7 @@ static hackrf_device* device = NULL;
BOOL WINAPI sighandler(int signum)
{
if (CTRL_C_EVENT == signum) {
interrupted = true;
fprintf(stderr, "Caught signal %d\n", signum);
stop_main_loop();
return TRUE;
@@ -651,6 +653,7 @@ BOOL WINAPI sighandler(int signum)
#else
void sigint_callback_handler(int signum)
{
interrupted = true;
fprintf(stderr, "Caught signal %d\n", signum);
do_exit = true;
}
@@ -1176,6 +1179,7 @@ int main(int argc, char** argv)
result |= hackrf_start_rx(device, rx_callback, NULL);
} else {
result = hackrf_set_txvga_gain(device, txvga_gain);
result |= hackrf_enable_tx_flush(device, 1);
result |= hackrf_start_tx(device, tx_callback, NULL);
}
if (result != HACKRF_SUCCESS) {
@@ -1403,6 +1407,10 @@ int main(int argc, char** argv)
interval_timer.it_value.tv_sec = 0;
setitimer(ITIMER_REAL, &interval_timer, NULL);
#endif
if ((transmit || signalsource) && !interrupted) {
// Wait for TX to finish.
hackrf_await_tx_flush(device);
}
result = hackrf_is_streaming(device);
if (do_exit) {