Skip to content

Format enum in bladerf python bindings does not match bladerf_format enumeration as declared in libbladeRF.h -- causes invalid metadata to be returned. #1038

Description

@jeremytrimble

Impact

  • The values of the Format enumeration in the bladerf Python bindings are incorrect, causing confusing behavior and breaking applications that worked on previous versions of libbladeRF.
  • This bug affects the current release candidate: 2025.05-rc2

Background

Commit 79cae1e introduced a new value to the bladerf_format enumeration: BLADERF_FORMAT_SC16_Q11_PACKED (see here).

This caused values declared later in the enumeration to increment by 1, effectively changing the ABI of libbladeRF.

Root Cause

However, it appears that the host/libraries/libbladeRF_bindings/python/bladerf/_cdef.py file used by the bladerf python bindings was not updated.
Since the Format(enum.Enum) enumeration in _bladerf.py references these enumeration values as loaded from _cdef.py (see here), Format.SC16_Q11_META and all subsequent values in the Format enum have the incorrect values.

This causes confusing behavior when users are, for instance, trying to receive data with timestamps using the SC16_Q11_META format, since the data returned by sync_rx() and friends is not in the expected format.

Actions to remedy:

  • Run the import_header.py script to update the _cdef.py file and commit the result.
    • Currently, the version_change_checklist.md file suggests running this before cutting a new release, but it seems this was not run for the release candidate.
    • It would probably be a better idea to automatically run import_header.py to generate _cdef.py every time as part of the libbladerf build process (and maybe not have _cdef.py committed in the repository at all) as this would make it less likely for _cdef.py and libbladeRF.h to get out-of-sync.
  • Additionally, the new BLADERF_FORMAT_SC16_Q11_PACKED value should have been added to the python Format(enum.Enum) enumeration in _bladerf.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions