From b4ea51a36bb1baef6925fe3d76574ff1b73b98f4 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Mon, 9 Nov 2020 09:43:40 -0800 Subject: [PATCH] add 10ms sleep after stop This seems to stop consumers that are doing quick back to back stop/start (eg gqrx changing decode mode / filter bandwidth) from hanging the device. I now don't have any weird hangs on hackrf with gqrx/freebsd/libusb! When things hang it isn't erroring out in any way; it just doesn't start receive. It doesn't look like a libusb issue; I'd have to get some USB bus sniffing to see what's going on behind the scenes. --- host/libhackrf/src/hackrf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 564a1f24..feda181b 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -25,6 +25,9 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI #include #include +#ifndef _WIN32 +#include +#endif #include #ifdef _WIN32 @@ -1688,6 +1691,11 @@ int ADDCALL hackrf_stop_rx(hackrf_device* device) return result; } result = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF); +#ifdef _WIN32 + Sleep(10); +#else + usleep(10 * 1000); +#endif return result; } @@ -1717,6 +1725,11 @@ int ADDCALL hackrf_stop_tx(hackrf_device* device) return result; } result = hackrf_set_transceiver_mode(device, HACKRF_TRANSCEIVER_MODE_OFF); +#ifdef _WIN32 + Sleep(10); +#else + usleep(10 * 1000); +#endif return result; }