Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.14k stars 455 forks source link

Hit stall for buffer error occurs while reading RX1 continuously #864

Closed SerjSSL closed 1 year ago

SerjSSL commented 2 years ago

Hi. I am using BladeRF via Python but each time I try reading RX1 continuously I get this error after some time spent:

[ERROR @ host/libraries/libbladeRF/src/backend/usb/libusb.c:1071] Hit stall for buffer 000001AB9DF003E0

Here is a code I am using to get the RX data (self.rx_samples_num = 2048):

    self.device.sync_config(layout         = _bladerf.ChannelLayout.RX_X1,
                       fmt            = _bladerf.Format.SC16_Q11,
                       num_buffers    = 2,
                       buffer_size    = 2048,
                       num_transfers  = 1,
                       stream_timeout = 3500)

    # Enable module
    self.postMessage( "RX: Start" )
    self.rx_ch.enable = True

    # Get the samples
    num = self.rx_samples_num
    while _thread.isRunning():
        # Read into buffer
        time.sleep(0.04)
        self.lock.acquire()
        try:
            self.device.sync_rx(self.rx_buf, num)
        except _bladerf.BladeRFError:
            self.postMessage( "RX error.")
        self.lock.release()

        # Draw the data
        if self._drawn:
            _thread._draw_signal.update.emit()
            self._drawn = False

    # Disable module
    self.postMessage( "RX: Stop" )
    self.rx_ch.enable = False
    self.rx_ch = None

This code is being executed by a separate thread.

IMPORTANT: The error occurs not instantly but some time after start. It disables the device and "try: except" section does not help in catching of it.

rghilduta commented 1 year ago

Does this happen with bladeRF-cli? This is likely related to the host PC power setting and Linux performance governor. One option to consider is setting the governor to performance mode with cpupower: https://askubuntu.com/questions/1021748/set-cpu-governor-to-performance-in-18-04 .