Code: Select all
# Create receive buffer
bytes_per_sample = 4
buf = bytearray(1024*bytes_per_sample)
num_samples_read = 0
# Tell TX thread to begin
if( tx_start != None ):
tx_start.set()
# 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
device.sync_rx(buf, num)
num_samples_read += num
# Write to file
outfile.write(buf[:num*bytes_per_sample])
So, how can I receive a signal from the bladeRF and write it to a npy file in python? Additionally, how do I save the metadata into the npy file? I know I'll need to use bladerf format SC16_Q11_META in device.sync_config, but again, I don't know how to properly save it into the npy file.
Thanks!