Simultaneous Reading from Both Rx Channels with Python Script

Follow our development of DSP and SDR tutorials
Post Reply
Dm_Yarem
Posts: 1
Joined: Sat Feb 03, 2024 2:46 am

Simultaneous Reading from Both Rx Channels with Python Script

Post by Dm_Yarem »

Greetings,

I'm currently delving into the realm of BladeRF SDR and I've been using the Python script provided in the BladeRF repository as a reference. Specifically, I'm referring to the script available at the following link: https://github.com/Nuand/bladeRF/blob/m ... rx/txrx.py

However, my focus is solely on receiving data at the moment, and thus, I have simplified the receiving function to better suit my needs. Here's the simplified function:

Code: Select all

def receive(device, channel : int, freq : int, rate : int, gain : int,
            rxfile : str = '', num_samples : int = 1024):

    status = 0

    if( device == None ):
        print( "RX: Invalid device handle." )
        return -1

    if( channel == None ):
        print( "RX: Invalid channel." )
        return -1

    # Configure BladeRF
    ch             = device.Channel(channel)
    ch.frequency   = freq
    ch.sample_rate = rate
    ch.gain        = gain

    # Setup synchronous stream
    device.sync_config(layout         = _bladerf.ChannelLayout.RX_X1,
                       fmt            = _bladerf.Format.SC16_Q11,
                       num_buffers    = 16,
                       buffer_size    = 8192,
                       num_transfers  = 8,
                       stream_timeout = 3500)

    # Enable module
    print( "RX: Start" )
    ch.enable = True

    # Create receive buffer
    bytes_per_sample = 4
    buf = bytearray(1024*bytes_per_sample)
    num_samples_read = 0

    # Save the samples
    with open(rxfile, 'wb') as outfile:
        while True:
            if num_samples > 0 and num_samples_read == num_samples:
                break
            elif num_samples > 0:
                num = min(len(buf)//bytes_per_sample,
                          num_samples-num_samples_read)
            else:
                num = len(buf)//bytes_per_sample

            # Read into buffer
            num = int(num)
            if num != 1024:
                print(num)
            device.sync_rx(buf, num)
            num_samples_read += num

            # Write to file
            outfile.write(buf[:num*bytes_per_sample])

    # Disable module
    print( "RX: Stop" )
    ch.enable = False

    print( "RX: Done" )

    return 0
My inquiry pertains to the possibility of simultaneously receiving data from both Rx channels. I've tinkered with various parameters, but unfortunately, I haven't been successful in achieving this.

Could you kindly provide me with any tips or advice on how to achieve simultaneous reading from both Rx channels using the Python script?

Thank you in advance for your assistance.
doja
Posts: 3
Joined: Mon Dec 11, 2023 11:18 pm

Re: Simultaneous Reading from Both Rx Channels with Python Script

Post by doja »

.
Vidal Sauer
Posts: 1
Joined: Thu Mar 21, 2024 5:45 am

Re: Simultaneous Reading from Both Rx Channels with Python Script

Post by Vidal Sauer »

JavaScript and SQL are two powerful programming languages that play a crucial role in digital marketingslope game
ulnaoperating
Posts: 1
Joined: Mon Mar 25, 2024 8:55 pm

Re: Simultaneous Reading from Both Rx Channels with Python Script

Post by ulnaoperating »

There are two powerful programming languages that are used in the digital marketing slope game, and those languages are JavaScript and SQL.
Post Reply