Skip to content

Update format enum for libbladeRF 2.6.0 and fix bytes-per-sample - #1

Open
wormuz wants to merge 1 commit into
GvozdevLeonid:mainfrom
wormuz:fix/libbladerf-2.6.0-formats
Open

Update format enum for libbladeRF 2.6.0 and fix bytes-per-sample#1
wormuz wants to merge 1 commit into
GvozdevLeonid:mainfrom
wormuz:fix/libbladerf-2.6.0-formats

Conversation

@wormuz

@wormuz wormuz commented Aug 18, 2026

Copy link
Copy Markdown

libbladeRF 2.6.0 inserted BLADERF_FORMAT_SC16_Q11_PACKED right after BLADERF_FORMAT_SC16_Q11, shifting every value after it. Since cbladerf.pxd declares the enum without explicit values, Cython numbers it positionally, so PYBLADERF_FORMAT_SC16_Q11_META silently became 1 — which in 2.6.0 is SC16_Q11_PACKED, a format without metadata.

The failure is silent: bladerf_sync_config() accepts the value, sync_rx() returns samples, and only the metadata timestamps give it away by never advancing.

Verified on a bladeRF 2.0 micro xA4 (FX3 2.6.0, FPGA 0.16.0), same device and request size:

format 1 (PACKED)  ac=32768, ts stuck at 133592988592904
format 2 (META)    ac=32768, ts=[61, 32829, 65597], step exactly 32768

Changes:

  • add BLADERF_FORMAT_SC16_Q11_PACKED to the enum so the values line up again
  • expose PYBLADERF_FORMAT_SC16_Q11_PACKED and PYBLADERF_FORMAT_PACKET_META
  • add the missing BLADERF_IMAGE_TYPE_GAIN_CAL
  • fix bytes_per_sample: it treated every format except SC16_Q11 as 2 bytes, but SC16_Q11_META carries 16-bit I and Q like SC16_Q11. Only the SC8_Q7 formats are 2 bytes.

Note this makes the enum match 2.6.0; against 2.5.0 the values differ, since that is where the ABI changed.

libbladeRF 2.6.0 inserted BLADERF_FORMAT_SC16_Q11_PACKED right after
BLADERF_FORMAT_SC16_Q11, shifting every value after it. Since the .pxd
declares the enum without explicit values, Cython numbers it positionally
and PYBLADERF_FORMAT_SC16_Q11_META silently became 1 - which is now
SC16_Q11_PACKED, a format without metadata.

The failure is silent: bladerf_sync_config() accepts the value, sync_rx()
returns samples, and only the metadata timestamps give it away by never
advancing. Verified on a bladeRF 2.0 micro xA4 (FX3 2.6.0, FPGA 0.16.0):

  format 1 (PACKED)  ac=32768, ts stuck at 133592988592904
  format 2 (META)    ac=32768, ts=[61, 32829, 65597], step exactly 32768

Also adds the missing BLADERF_IMAGE_TYPE_GAIN_CAL, and exposes
SC16_Q11_PACKED and PACKET_META.

Separately, bytes_per_sample treated every format except SC16_Q11 as
2 bytes, which is wrong for SC16_Q11_META: it carries 16-bit I and Q like
SC16_Q11. Only the SC8_Q7 formats are 2 bytes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant