jopohl / urh

Universal Radio Hacker: Investigate Wireless Protocols Like A Boss
GNU General Public License v3.0
10.99k stars 874 forks source link

Compile error: bladerf_get_frequency() parameter 3 type mismatch #936

Closed nospam2000 closed 2 years ago

nospam2000 commented 2 years ago
Expected Behavior

Build and installation should work on MacOS.

Actual Behavior

The build fails because the datatypes of the parameter 3 for bladerf_get_frequency() doesn't match the prototype in the header /opt/local/include/libbladeRF.h.

The type of bladerf_frequency should be unsigned long long * but it actually is unsigned int *

Probably the following lines (from here) do not work like intended and it chooses the ELSE path instead of the IF path:

IF BLADERF_API_VERSION >= 1.91:
  ctypedef uint64_t bladerf_frequency
ELSE:
  ctypedef unsigned int bladerf_frequency

In /opt/local/include/libbladeRF.h LIBBLADERF_API_VERSION is defined as int32:

* This value is defined as follows:
 *      `(major << 24) | (minor << 16) | (patch << 8) | (reserved << 0)`
 */
#define LIBBLADERF_API_VERSION (0x02040100)

The version 2.4.1 should be detected as newer than 1.9.1. I haven't understood where that floating point number gets derived from the original integer number. Maybe the problem is, that 1.91 is not the same as 1.9.1 or that the mechanism for creating the floating point version number doesn't work correctly.

Steps To Reproduce
  1. install urh via pip3.9
  2. See compile error
Screenshots
      building 'urh.dev.native.lib.bladerf' extension
      src/urh/dev/native/lib/bladerf.cpp:4257:17: error: no matching function for call to 'bladerf_get_frequency'
        __pyx_v_err = bladerf_get_frequency(__pyx_v_3urh_3dev_6native_3lib_7bladerf__c_device, __pyx_f_3urh_3dev_6native_3lib_7bladerf_get_current_bladerf_channel(0), (&__pyx_v_result));
                      ^~~~~~~~~~~~~~~~~~~~~
      /opt/local/include/libbladeRF.h:1300:15: note: candidate function not viable: no known conversion from '__pyx_t_3urh_3dev_6native_3lib_8cbladerf_bladerf_frequency *' (aka 'unsigned int *') to 'bladerf_frequency *' (aka 'unsigned long long *') for 3rd argument
      int CALL_CONV bladerf_get_frequency(struct bladerf *dev,
                    ^
      src/urh/dev/native/lib/bladerf.cpp:4381:13: error: no matching function for call to 'bladerf_sync_config'
        __pyx_r = bladerf_sync_config(__pyx_v_3urh_3dev_6native_3lib_7bladerf__c_device, __pyx_f_3urh_3dev_6native_3lib_7bladerf_get_current_channel_layout(0), BLADERF_FORMAT_SC16_Q11, 32, 0x800, 16, 0x64);
                  ^~~~~~~~~~~~~~~~~~~
      /opt/local/include/libbladeRF.h:2624:15: note: candidate function not viable: no known conversion from 'bladerf_module' (aka 'int') to 'bladerf_channel_layout' for 2nd argument
      int CALL_CONV bladerf_sync_config(struct bladerf *dev,
                    ^
      2 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
Platform Specifications
nospam2000 commented 2 years ago

using the following command, the installation succeeds:

sudo -H BLADERF_API_VERSION=2.41 SDRPLAY_API_VERSION=2.13 pip-3.10 install urh

For a user of pip is it not really intuitive to set the API versions of the components as environment variables, the versions should be automatically be detected from the installed header files.