From 21634f5ac48bbb73394b61d4c6010e2465400d65 Mon Sep 17 00:00:00 2001 From: Timothy Mullican <18095326+tjmullicani@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:13:36 -0600 Subject: [PATCH] fix bladerf error fix "An unexpected error occurred" errors --- sdr_ubladerf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sdr_ubladerf.c b/sdr_ubladerf.c index 43e92a0f..ffe13686 100644 --- a/sdr_ubladerf.c +++ b/sdr_ubladerf.c @@ -221,6 +221,13 @@ bool ubladeRFOpen() { goto error; } + // Close and re-open the bladeRF, otherwise we get "An unexpected error occurred" in later calls. + bladerf_close(uBladeRF.device); + if ((status = bladerf_open(&uBladeRF.device, Modes.dev_name)) < 0) { + fprintf(stderr, "Failed to open bladeRF: %s\n", bladerf_strerror(status)); + goto error; + } + if ((status = bladerf_set_sample_rate(uBladeRF.device, BLADERF_MODULE_RX, Modes.sample_rate * uBladeRF.decimation, NULL)) < 0) { fprintf(stderr, "bladerf_set_sample_rate failed: %s\n", bladerf_strerror(status)); goto error;