Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use correct type for bladerf_get_frequency #22

Closed
wants to merge 1 commit into from

Conversation

larsks
Copy link

@larsks larsks commented Aug 28, 2018

Building against ubuntu bionic (amd64) resulted in the following error:

    sdr_bladerf.c: In function 'show_config':
    sdr_bladerf.c:116:76: error: passing argument 3 of 'bladerf_get_frequency' from incompatible pointer type [-Werror=incompatible-pointer-types]
             (status = bladerf_get_frequency(BladeRF.device, BLADERF_MODULE_RX, &freq)) < 0 ||
                                                                                ^
    In file included from sdr_bladerf.c:23:0:
    /usr/include/libbladeRF.h:1117:15: note: expected 'bladerf_frequency * {aka long unsigned int *}' but argument is of type 'unsigned int *'
     int CALL_CONV bladerf_get_frequency(struct bladerf *dev,
^~~~~~~~~~~~~~~~~~~~~

This commit uses the correct type for the freq variable.

@mutability
Copy link

This is, unfortunately, an incompatible change in the upstream headers and will break the build on e.g. jessie.

@mutability
Copy link

You should probably be using bladerf_frequency not long unsigned here.

You can probably wrap this in an #if conditional that looks at LIBBLADERF_API_VERSION

Building against ubuntu bionic (amd64) and current bladeRF sources (4bcdd6ec)
resulted in the following error:

```
    sdr_bladerf.c: In function 'show_config':
    sdr_bladerf.c:116:76: error: passing argument 3 of 'bladerf_get_frequency' from incompatible pointer type [-Werror=incompatible-pointer-types]
             (status = bladerf_get_frequency(BladeRF.device, BLADERF_MODULE_RX, &freq)) < 0 ||
                                                                                ^
    In file included from sdr_bladerf.c:23:0:
    /usr/include/libbladeRF.h:1117:15: note: expected 'bladerf_frequency * {aka long unsigned int *}' but argument is of type 'unsigned int *'
     int CALL_CONV bladerf_get_frequency(struct bladerf *dev,
^~~~~~~~~~~~~~~~~~~~~
```

This commit uses the correct type (`bladerf_frequency`) for the `freq`
variable.
@larsks larsks changed the title use long unsigned int for bladerf_get_frequency use correct type for bladerf_get_frequency Aug 28, 2018
@larsks
Copy link
Author

larsks commented Aug 28, 2018

Good catch, thanks.

I've updated the pr to use bladerf_frequency. I'll take a look at the version conditional later.

@larsks
Copy link
Author

larsks commented Aug 28, 2018

Actually, the current version of the pr seems to build fine on debian jessie.

@mutability
Copy link

Breaks for me:

sdr_bladerf.c:105:5: error: unknown type name 'bladerf_frequency'
     bladerf_frequency freq;
     ^
sdr_bladerf.c:116:76: error: pointer targets in passing argument 3 of 'bladerf_get_frequency' differ in signedness [-Werror=pointer-sign]
         (status = bladerf_get_frequency(BladeRF.device, BLADERF_MODULE_RX, &freq)) < 0 ||
                                                                            ^
In file included from sdr_bladerf.c:23:0:
/usr/include/libbladeRF.h:1261:15: note: expected 'unsigned int *' but argument is of type 'int *'
 int CALL_CONV bladerf_get_frequency(struct bladerf *dev,
               ^
cc1: all warnings being treated as errors
Makefile:41: recipe for target 'sdr_bladerf.o' failed
make[2]: *** [sdr_bladerf.o] Error 1

@mutability
Copy link

Not working in the current form, reopen if needed

@jprochazka
Copy link

jprochazka commented Apr 4, 2019

You have this closed but I was able to work out a fix. On top of changing unsigned freq to bladerf_frequency freq in sdr_bladerf.c a couple further changes are needed as well.

You need to modify the LIBS variable in the file MakeFile by adding -pthread before -lpthread. This will fix the error dump1090.o: undefined reference to symbol 'pthread_join@@GLIBC_2.2.5' you will receive if you try to build the package with only the variable fixed.

Being that building bladeRF from the master branch of their repository builds bladeRF2 you will need to modify Debian/control as well changing libbladerf1 (>= 0.2016.06) to libbladerf2 in the dump1090-fa Depends line. Or better yet libbladerf1 (>= 0.2016.06) | libbladerf2 to depend on either or?

Tested and working on Unbuntu 19.04 Disco Dingo.
I have to step out now but If you wish I will submit a pull request reflecting these changes tonight.

@mutability
Copy link

mutability commented Apr 5, 2019 via email

@jprochazka
Copy link

Just need to test that changes to the Debian control file work with both libbladerf1 as well as libbladerf2. I have never done a | aka or for dependencies in a control file but from what I read it should work. I just want to make sure before submitting a pull request.

I just tried to upgrade my test machine from Ubuntu 16.04 to 19.04 and apparently the firmware does not play nice with the newer kernels. As soon as I am back up and running I will test the changes out and submit a pull request.

@mutability
Copy link

mutability commented Apr 16, 2019

FWIW I just took a look at this on my bionic machine here and I can't reproduce the original build problem.

$ apt-cache policy libbladerf-dev
libbladerf-dev:
  Installed: 0.2016.06-2
  Candidate: 0.2016.06-2
  Version table:
 *** 0.2016.06-2 500
        500 http:https://gb.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        100 /var/lib/dpkg/status

I can entirely believe that there's an API change here but I don't see it with vanilla bionic.

@mutability
Copy link

mutability commented Apr 17, 2019

I can't reproduce this against ubuntu disco amd64 either.

(note that there is a packaging bug in librtlsdr-dev on disco; I just committed a workaround for that; see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=925916 and 34bfe10)

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.

None yet

3 participants