Simultaneous Reading from Both Rx Channels with Python Script
Posted: Sat Feb 03, 2024 3:16 am
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:
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.
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
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.