From eccf2ee7463b6122370483be163e25719723ee1f Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 8 Oct 2021 10:14:38 +0200 Subject: [PATCH] temporarily prevent a problem with the DMA, which occurs when using petalinux 2018.3, the ezdma and when switching from tx to rx transfer mode. --- .../adapters/ad9361_fpga_signal_source.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index cc13a0667..0d10cda6a 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -626,7 +626,23 @@ void Ad9361FpgaSignalSource::run_DMA_process(const std::string &filename0, const int num_transferred_bytes; // Open DMA device - const int tx_fd = open("/dev/loop_tx", O_WRONLY); + int tx_fd = open("/dev/loop_tx", O_WRONLY); + if (tx_fd < 0) + { + std::cerr << "Cannot open loop device\n"; + // stop the receiver + queue->push(pmt::make_any(command_event_make(200, 0))); + return; + } + // note: a problem was identified with the DMA: when switching from tx to rx or rx to tx mode + // the DMA transmission may hang. This problem will be fixed soon. + // for the moment this problem can be avoided by closing and opening the DMA a second time + if (close(tx_fd) < 0) + { + std::cerr << "Error closing loop device " << '\n'; + } + // open the DMA a second time + tx_fd = open("/dev/loop_tx", O_WRONLY); if (tx_fd < 0) { std::cerr << "Cannot open loop device\n";