Acquiring data and metadata with python

Discussions related to embedded firmware, driver, and user mode application software development
Post Reply
SalvoP
Posts: 1
Joined: Wed Jul 24, 2024 3:27 am

Acquiring data and metadata with python

Post by SalvoP »

Hi everyone, I'm writing a python script with which I would like to acquire the metadata of the data read by my bladeRF 2.0 xA4, however when in the sync_config I want to set a fmt=SC16_Q11_META I get an error telling me that module 'bladerf' has no attribute 'SC16_Q11_META', where I'm doing it wrong? here is an excerpt of the code:

-------------------------------------
import bladerf
import time

CHANNEL = 0
NUM_SAMPLES = 10000
TIMEOUT_MS = 10000

try:
dev = bladerf.BladeRF()
dev.set_frequency(bladerf.CHANNEL_RX(CHANNEL), 915e6)
dev.set_sample_rate(bladerf.CHANNEL_RX(CHANNEL), 10e6)
dev.set_bandwidth(bladerf.CHANNEL_RX(CHANNEL), 10e6)
dev.set_gain(bladerf.CHANNEL_RX(CHANNEL), 30)
dev.sync_config(
bladerf.CHANNEL_RX(CHANNEL),
fmt=bladerf.SC16_Q11_META,
num_buffers=16,
buffer_size=8192,
num_transfers=8,
stream_timeout=TIMEOUT_MS
)

dev.enable_module(bladerf.CHANNEL_RX(CHANNEL))
samples = dev.sync_rx(NUM_SAMPLES)
dev.disable_module(bladerf.CHANNEL_RX(CHANNEL))

except Exception as e:
print(e)
-------------------------------------

here is the version of my libs:
libbladeRF version: 2.5.0-git-f24abc35
Firmware version: 2.4.0-git-a3d5c55f
FPGA version: 0.15.3 (configured from SPI flash)


Thank you in advance.
Regards

Salvo
ghbjakef3
Posts: 7
Joined: Fri Dec 01, 2023 11:34 am

Re: Acquiring data and metadata with python

Post by ghbjakef3 »

SalvoP wrote: Wed Jul 24, 2024 3:42 am Hi everyone, I'm writing a python script with which I would like to acquire the metadata of the data read by my bladeRF 2.0 xA4, however when in the sync_config I want to set a fmt=SC16_Q11_META I get an error telling me that module 'bladerf' has no attribute 'SC16_Q11_META', where I'm doing it wrong? here is an excerpt of the code:

-------------------------------------
import bladerf
import time

CHANNEL = 0
NUM_SAMPLES = 10000
TIMEOUT_MS = 10000

try:
dev = bladerf.BladeRF()
dev.set_frequency(bladerf.CHANNEL_RX(CHANNEL), 915e6)
dev.set_sample_rate(bladerf.CHANNEL_RX(CHANNEL), 10e6)
dev.set_bandwidth(bladerf.CHANNEL_RX(CHANNEL), 10e6)
dev.set_gain(bladerf.CHANNEL_RX(CHANNEL), 30)
dev.sync_config(
bladerf.CHANNEL_RX(CHANNEL),
fmt=bladerf.SC16_Q11_META,
num_buffers=16,
buffer_size=8192,
num_transfers=8,
stream_timeout=TIMEOUT_MS
)

dev.enable_module(bladerf.CHANNEL_RX(CHANNEL))
samples = dev.sync_rx(NUM_SAMPLES)
dev.disable_module(bladerf.CHANNEL_RX(CHANNEL))

except Exception as e:
print(e)
-------------------------------------

here is the version of my libs:
libbladeRF version: 2.5.0-git-f24abc35
Firmware version: 2.4.0-git-a3d5c55f
FPGA version: 0.15.3 (configured from SPI flash)


Thank you in advance.
Regards

Salvo
Have a look at the `_bladerf.py` file. I think you meant to use `bladerf.Format.SC16_Q11_META`.
geldill
Posts: 2
Joined: Tue Aug 20, 2024 10:23 am

Re: Acquiring data and metadata with python

Post by geldill »

The error you're encountering is due to the SC16_Q11_META format not being available or recognized in the bladerf Python module that you're usingplanet clicker. The bladerf Python bindings might not include this specific format, or it might be named differently.
Replace the line in your script:
dev.sync_config(bladerf.CHANNEL_RX(CHANNEL), fmt=bladerf.SC16_Q11_META, num_buffers=16, buffer_size=8192, num_transfers=8, stream_timeout=TIMEOUT_MS)
Post Reply