RTL-SDR support

I was wondering how much effort would take to port the rtl-sdr libraries? Requirements are quite sparse, namely: libusb, cmake, ninja – all of them are present in Haiku. I’m no developer and haven’t touched code in years but I’m willing to give it a go, unless someone with more experience can chime in (and do it in 1/3 time it’ll take me).

This may possibly open an entire category of usage scenarios, starting with SDR apps, and random things like DAB receiving or astronomic/weather observation. All things that resonate well with a media-centric OS like Haiku, methinks.

Opinions, everyone?

5 Likes

That sounds great! Go for it!

I will have to investigate the links you gave to understand what SDR actually is…

SDR=Software Defined Radio? RTL=RunTime LIbrary? DAB=Digital Audio Broadcasting? Please define terms before assuming everybody knows what you’re talking about.

4 Likes

No need for such hostility. Besides, that’s why I linked those terms.

rtl-sdr is a widely deployed library/tool to enable cheap DVB-T receivers like this one, to be repurposed as way more capable/costly SDR receivers. These dongles are EXTREMELY popular in the amateur radio world (and even commercially), and useful for many purposes – like the links I wrote about.

Software-defined radio is exactly what the name implies, a radio receiver implemented almost entirely in code, with a minimum of actual radio hardware. Such code can be a PC program, an FPGA implementation, etc. For people interested, this link does a far better job than me explaining all the in-and-outs.

rtl-sdr is available for every major OS from Linux to macOS, Windows, Android, *BSD etc. I believe Haiku would greatly benefit from having it, too.

1 Like

I didn’t mean to be perceived as hostile. I just ventured a few guesses of what it might stand for. I have an uncle with an SDR set that he’s never used. I was just wondering if that is what you were talking about.

1 Like

I think you having experience with this sort of hardware and likely owning it will be help, if you want to port it then go for it!

I’d be interested in this on Haiku for sure. I have a RTL-2832U to do testing.

1 Like

I followed that link and it’s really interesting. :slight_smile: Thanks

For me, SDR stands for Special Drawing Right, and RTL is a French or German broadcaster. Like you, Mr Crow, I had absolutely no idea what the original poster (OP) was talking about.
When people start a topic on a relatively arcane subject, it’s always a good idea to spell things out in full, and then use initials subsequently.
And when, Mr OP, people ask for clarification, please don’t assume hostility. SamuraiCrow was simply trying to understand.
BTW, sounds like a good project. Good luck.

Radio Television Luxemburg

should be nice to have flightradar24 :slight_smile:

3 Likes

Are you sure it’s not Lesotho?

That much is true, I should’ve done that. But again, that’s why I left some links for clarification on the subject. It was lacking and that’s on me :slight_smile:

I’ll try! For now I’m familiarizing myself with haikuporter, and found this guide to be an excelent intro. Let’s see what I can do.

As a quick test I installed libusb_examples, which contains some tools to poke at USB devices.

~/Dev/rtl-sdr/build> libusb-test-libusb 
..
.. <snip>
..
Dev (bus 5, device 101): 0000 - 0000 speed: Unknown
  Manufacturer:              HAIKU Inc.
  Product:                   EHCI RootHub
Dev (bus 5, device 1): 0BDA - 2838 speed: Unknown
  Manufacturer:              Realtek
  Product:                   RTL2838UHIDIR
~/Dev/rtl-sdr/build> libusb-example-xusb -i 0bda:2838
Using libusb v1.0.26.11724

Opening device 0BDA:2838...
             speed: Unknown

Reading device descriptor:
            length: 18
      device class: 0
               S/N: 3
           VID:PID: 0BDA:2838
         bcdDevice: 0100
   iMan:iProd:iSer: 1:2:3
          nb confs: 1

libusb: error [Do] failed control transfer
libusb: error [haiku_handle_transfer_completion] error in transfer
libusb: error [libusb_get_bos_descriptor] failed to read BOS (-1)
Reading BOS descriptor: no descriptor

Reading first configuration descriptor:
              total length: 34
         descriptor length: 9
             nb interfaces: 2
              interface[0]: id = 0
interface[0].altsetting[0]: num endpoints = 1
   Class.SubClass.Protocol: FF.FF.FF
       endpoint[0].address: 81
           max packet size: 0200
          polling interval: 00
              interface[1]: id = 1
interface[1].altsetting[0]: num endpoints = 0
   Class.SubClass.Protocol: FF.FF.FF

Kernel driver attached for interface 0: -12

Claiming interface 0...

Kernel driver attached for interface 1: -12

Claiming interface 1...

Reading string descriptors:
   String (0x01): "Realtek"
   String (0x02): "RTL2838UHIDIR"
   String (0x03): "00000001"

libusb: error [Do] failed control transfer
libusb: error [haiku_handle_transfer_completion] error in transfer
Reading OS string descriptor: no descriptor

Releasing interface 0...
Releasing interface 1...
Closing device...

Seems libusb picks the dongle just fine. But I wonder about those transfer errors…

2 Likes

Hello,

My experience with libusb is that there is some bug in the Haiku backend making it a bit unreliable. However, despite hours of looking over the code and fixing some bugs, I still didn’t find exactly why.

The Haiku provided “USB Kit” has a generally similar API, and works without any problems. But adjusting apps to it requires rewriting some code.

4 Likes

That looks doable, seeing as rtl-sdr can also work with WinUSB and libusbK on Windows, apart from libusb-win32. But let’s see how far we can push Haiku’s libusb without patching code 1st.

I’m playing with a recipe for x86_64, iterating whenever I find errors (soooo many :face_with_peeking_eye:) and missing dependencies. I’m at a point where most of them are met, the devenv gets correctly setup (?) and code begins to compile… just begins though. Seems to be choking on “undefined” references.

~/Dev/haikuports/net-wireless/rtl_sdr> haikuporter -S rtl_sdr-0.6.0
Checking if any dependency-infos need to be updated ...
        updating dependency infos of rtl_sdr-0.6.0
Looking for stale dependency-infos ...
----------------------------------------------------------------------
net-wireless::rtl_sdr-0.6.0
        /boot/home/Dev/haikuports/net-wireless/rtl_sdr/rtl_sdr-0.6.0.recipe
----------------------------------------------------------------------

Downloading: https://github.com/osmocom/rtl-sdr/archive/142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz ...
--2023-01-24 01:52:04--  https://github.com/osmocom/rtl-sdr/archive/142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz
Resolviendo github.com... 20.201.28.151
Conectando con github.com[20.201.28.151]:443... conectado.
Petición HTTP enviada, esperando respuesta... 302 Found
Localización: https://codeload.github.com/osmocom/rtl-sdr/tar.gz/142325a93c6ad70f851f43434acfdf75e12dfe03 [siguiendo]
--2023-01-24 01:52:04--  https://codeload.github.com/osmocom/rtl-sdr/tar.gz/142325a93c6ad70f851f43434acfdf75e12dfe03
Resolviendo codeload.github.com... 20.201.28.149
Conectando con codeload.github.com[20.201.28.149]:443... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: no especificado [application/x-gzip]
Grabando a: «/boot/home/Dev/haikuports/net-wireless/rtl_sdr/download/142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz»
     0K ..                                                     531K=0,2s
2023-01-24 01:52:05 (531 KB/s) - «/boot/home/Dev/haikuports/net-wireless/rtl_sdr/download/142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz» guardado [134261]
Validating checksum of 142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz
Unpacking source of 142325a93c6ad70f851f43434acfdf75e12dfe03.tar.gz
Inicializado repositorio Git vacío en /boot/home/Dev/haikuports/net-wireless/rtl_sdr/work-0.6.0/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/.git/
chroot has these packages active:
        /boot/system/packages/autoconf-2.71-1-x86_64.hpkg
        /boot/system/packages/automake-1.16.5-1-x86_64.hpkg
        /boot/system/packages/bash-5.1.016-1-x86_64.hpkg
        /boot/system/packages/binutils-2.31.1-2-x86_64.hpkg
        /boot/system/packages/bzip2-1.0.8-2-x86_64.hpkg
        /boot/system/packages/ca_root_certificates-2022_10_11-1-any.hpkg
        /boot/system/packages/coreutils-9.1-1-x86_64.hpkg
        /boot/system/packages/diffutils-3.8-1-x86_64.hpkg
        /boot/system/packages/expat-2.5.0-2-x86_64.hpkg
        /boot/system/packages/findutils-4.9.0-1-x86_64.hpkg
        /boot/system/packages/fontconfig-2.13.96-1-x86_64.hpkg
        /boot/system/packages/freetype-2.12.1-3-x86_64.hpkg
        /boot/system/packages/gcc-11.2.0_2021_07_28-8-x86_64.hpkg
        /boot/system/packages/gcc_syslibs-11.2.0_2021_07_28-8-x86_64.hpkg
        /boot/system/packages/gettext_libintl-0.21.1-2-x86_64.hpkg
        /boot/system/packages/gmp-6.2.1-3-x86_64.hpkg
        /boot/system/packages/graphite2-1.3.14-1-x86_64.hpkg
        /boot/system/packages/grep-3.8-1-x86_64.hpkg
        /boot/system/packages/gzip-1.12-1-x86_64.hpkg
        /boot/system/packages/haiku-r1~beta4_hrev56578_65-1-x86_64.hpkg
        /boot/system/packages/haiku_devel-r1~beta4_hrev56578_65-1-x86_64.hpkg
        /boot/system/packages/harfbuzz-4.0.0-3-x86_64.hpkg
        /boot/system/packages/icu66-66.1-3-x86_64.hpkg
        /boot/system/packages/intel_wifi_firmwares-2022_01_11-3-any.hpkg
        /boot/system/packages/libedit-20210910_3.1-3-x86_64.hpkg
        /boot/system/packages/libiconv-1.17-3-x86_64.hpkg
        /boot/system/packages/libpcre-8.45-3-x86_64.hpkg
        /boot/system/packages/libpng16-1.6.38-2-x86_64.hpkg
        /boot/system/packages/libsolv-0.3.0_haiku_2014_12_22-3-x86_64.hpkg
        /boot/system/packages/libtool-2.4.6-2-x86_64.hpkg
        /boot/system/packages/libtool_libltdl-2.4.6-2-x86_64.hpkg
        /boot/system/packages/libusb-1.0.26-2-x86_64.hpkg
        /boot/system/packages/libusb_devel-1.0.26-2-x86_64.hpkg
        /boot/system/packages/libxml2-2.9.13-4-x86_64.hpkg
        /boot/system/packages/m4-1.4.19-1-x86_64.hpkg
        /boot/system/packages/make-4.1-5-x86_64.hpkg
        /boot/system/packages/mawk-1.3.4_20171017-1-x86_64.hpkg
        /boot/system/packages/mpc-1.2.1-1-x86_64.hpkg
        /boot/system/packages/mpfr-4.2.0-2-x86_64.hpkg
        /boot/system/packages/ncurses6-6.3-2-x86_64.hpkg
        /boot/system/packages/noto-20200106-1-any.hpkg
        /boot/system/packages/noto_sans_cjk_jp-1.004-2-any.hpkg
        /boot/system/packages/openssl-1.1.1s-2-x86_64.hpkg
        /boot/system/packages/perl-5.32.1-1-x86_64.hpkg
        /boot/system/packages/pkgconfig-0.29.2-4-x86_64.hpkg
        /boot/system/packages/ralink_wifi_firmwares-2015_02_11-2-any.hpkg
        /boot/system/packages/readline-8.1.002-1-x86_64.hpkg
        /boot/system/packages/realtek_wifi_firmwares-2019_01_02-1-any.hpkg
        /boot/system/packages/sed-4.8-1-x86_64.hpkg
        /boot/system/packages/tar-1.34-1-x86_64.hpkg
        /boot/system/packages/unzip-6.10c23-4-x86_64.hpkg
        /boot/system/packages/which-2.21-6-x86_64.hpkg
        /boot/system/packages/zlib-1.2.13-2-x86_64.hpkg
        /boot/system/packages/zstd-1.5.2-3-x86_64.hpkg
----- Package Info ----------------
header size:                     80
heap size:                      972
TOC size:                        41
package attributes size:       1370
total size:                    1052
-----------------------------------
waiting for build package rtl_sdr-0.6.0-1 to be activated
Building ...
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:16: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:16: You should run autoupdate.
m4/libtool.m4:99: AC_PROG_LIBTOOL is expanded from...
configure.ac:16: the top level
configure.ac:28: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:28: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:28: the top level
configure.ac:93: warning: The macro `AC_TRY_COMPILE' is obsolete.
configure.ac:93: You should run autoupdate.
./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from...
configure.ac:93: the top level
configure.ac:111: warning: The macro `AC_CONFIG_HEADER' is obsolete.
configure.ac:111: You should run autoupdate.
./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from...
configure.ac:111: the top level
configure.ac:113: warning: AC_OUTPUT should be used without arguments.
configure.ac:113: You should run autoupdate.
configure.ac:12: installing './compile'
configure.ac:15: installing './config.guess'
configure.ac:15: installing './config.sub'
configure.ac:5: installing './install-sh'
configure.ac:5: installing './missing'
Makefile.am:4: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am:6: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/Makefile.am: installing './depcomp'
configure: WARNING: unrecognized options: --disable-ldconfig
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make sets $(MAKE)... (cached) yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking build system type... x86_64-unknown-haiku
checking host system type... x86_64-unknown-haiku
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /boot/system/develop/tools/x86_64-unknown-haiku/bin/ld
checking if the linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /bin/nm -B
checking the name lister (/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 65536
checking how to convert x86_64-unknown-haiku file names to x86_64-unknown-haiku format... func_convert_file_noop
checking how to convert x86_64-unknown-haiku file names to toolchain format... func_convert_file_noop
checking for /boot/system/develop/tools/x86_64-unknown-haiku/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC...  -DPIC
checking if gcc PIC flag  -DPIC works... yes
checking if gcc static flag  works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/boot/system/develop/tools/x86_64-unknown-haiku/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... haiku runtime_loader
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libusb-1.0 >= 1.0... yes
checking for doxygen... false
checking for egrep... (cached) /bin/grep -E
checking for sys/types.h... (cached) yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for atan2 in -lm... yes
checking for sqrt in -lm... yes
checking for atan2 in -lm... (cached) yes
checking for clock_gettime in -lrt... no
checking if gcc supports -fvisibility=hidden... yes
checking whether compiler understands -Wall... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating librtlsdr.pc
config.status: creating include/Makefile
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating Doxyfile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
configure: WARNING: unrecognized options: --disable-ldconfig
echo UNKNOWN > .version-t && mv .version-t .version
make  all-recursive
make[1]: Entering directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03'
Making all in include
make[2]: Entering directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/include'
Making all in src
make[2]: Entering directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src'
  CC       rtl_sdr.o
  CC       librtlsdr.lo
  CC       tuner_e4k.lo
  CC       tuner_fc0012.lo
  CC       tuner_fc0013.lo
  CC       tuner_fc2580.lo
  CC       tuner_r82xx.lo
librtlsdr.c: In function 'rtlsdr_open':
librtlsdr.c:1447:24: warning: integer overflow in expression '-2147483648' of type 'int' results in '-2147483648' [-Woverflow]
 1447 |                 return -ENOMEM;
      |                        ^
librtlsdr.c: In function '_rtlsdr_alloc_async_buffers':
librtlsdr.c:1798:40: warning: integer overflow in expression '-2147483648' of type 'int' results in '-2147483648' [-Woverflow]
 1798 |                                 return -ENOMEM;
      |                                        ^
  CC       rtl_tcp.o
  CC       rtl_test.o
  CC       rtl_fm.o
  CC       rtl_eeprom.o
  CC       rtl_adsb.o
  CC       rtl_power.o
  CC       convenience/convenience.o
  CCLD     librtlsdr.la
  CCLD     rtl_sdr
  CCLD     rtl_tcp
  CCLD     rtl_test
  CCLD     rtl_fm
  CCLD     rtl_eeprom
  CCLD     rtl_adsb
  CCLD     rtl_power
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: rtl_tcp.o: in function `tcp_worker':
/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:240: undefined reference to `send'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: rtl_tcp.o: in function `command_worker':
/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:305: undefined reference to `recv'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: rtl_tcp.o: in function `main':
/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:539: undefined reference to `getaddrinfo'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:557: undefined reference to `socket'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:562: undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:563: undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:565: undefined reference to `bind'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:551: undefined reference to `getnameinfo'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:585: undefined reference to `listen'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:597: undefined reference to `accept'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:602: undefined reference to `setsockopt'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:604: undefined reference to `getnameinfo'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:620: undefined reference to `send'
/boot/system/develop/tools/bin/../lib/gcc/x86_64-unknown-haiku/11.2.0/../../../../x86_64-unknown-haiku/bin/ld: /sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src/rtl_tcp.c:544: undefined reference to `gai_strerror'
collect2: error: ld returned 1 exit status
Makefile:554: recipe for target 'rtl_tcp' failed
make[2]: *** [rtl_tcp] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03/src'
Makefile:494: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/sources/rtl-sdr-142325a93c6ad70f851f43434acfdf75e12dfe03'
Makefile:380: recipe for target 'all' failed
make: *** [all] Error 2
Warning: Command '['bash', '-c', '. /wrapper-script']' returned non-zero exit status 2.
Error: Build has failed - stopping.
~/Dev/haikuports/net-wireless/rtl_sdr>

And that’s where I left before sleep last night.

You need to link to -lnetwork to use the network APIs. There are probably several examples of patches doing this in other haikuports recipes.

From the warning messages about overflows, you will also likely need to enable the “POSIX error mapper”. This is due to a difference between Haiku and the current POSIX spec, we use negative values for errno error codes, which is not allowed by POSIX. So, there is a compatibility library to fix that.

2 Likes

Actually, in cases like these, we do not need to enable the error mapper, I think. Note carefully what the message is saying:

warning: integer overflow in expression ‘-2147483648’ of type ‘int’ results in ‘-2147483648’

The two numbers are exactly the same; the error number is not being transformed at all. The program wants a negative error number internally, and it gets that anyway. This is a bit dangerous, and the sources should probably be patched anyway to not try to “double-negative” such errors, but it should work anyway, I think.

rtlsdr_rtl-test

Recipe build: success :v:
Headache level: ibuprofen plz.

What I need now is a way to pipe raw audio samples to the soundcard, basically the equivalent of Linux sox’s play command for Haiku – I’ve installed sox from the Depot, but Haiku’s play command (which serves another purpose) seems to take precedence… where do I look for sox one?

sndfile-play doesn’t work either: “Playing sound not supported on this platform. Please feel free to submit a patch”… while I’m listening some MP3s, heh.

This is the example commonly given for Linux:

rtl_fm -M wbfm -f 88.9M | play -r 32k -t raw -e s -b 16 -c 1 -V1 -

I’m sooo close to actually listen to FM radio! (rock/prog preferred)

3 Likes

For the “play” command, it looks like there is a conflict so the “sox” one will not be visible. I think we could remove the “play” command from Haiku since it seems quite useless (for playing audio CDs using direct request to the CD drive, which will probably not work at all on modern hardware).

1 Like

Cool, I’ll open a ticket for that.

Re: negative error codes. From libusb docs: “libusb functions typically return 0 on success or a negative error code on failure. These negative error codes relate to LIBUSB_ERROR constants which are listed on the miscellaneous documentation page”.

Actual values are below. They seem to be within Haiku spec, right?

libusb_error { 
  LIBUSB_SUCCESS = 0 , LIBUSB_ERROR_IO = -1 , LIBUSB_ERROR_INVALID_PARAM = -2 , LIBUSB_ERROR_ACCESS = -3 , 
  LIBUSB_ERROR_NO_DEVICE = -4 , LIBUSB_ERROR_NOT_FOUND = -5 , LIBUSB_ERROR_BUSY = -6 , LIBUSB_ERROR_TIMEOUT = -7 , 
  LIBUSB_ERROR_OVERFLOW = -8 , LIBUSB_ERROR_PIPE = -9 , LIBUSB_ERROR_INTERRUPTED = -10 , LIBUSB_ERROR_NO_MEM = -11 , 
  LIBUSB_ERROR_NOT_SUPPORTED = -12 , LIBUSB_ERROR_OTHER = -99 
}

How they end being in the -2147483648 ballpark, is something I’m afraid cannot debug with my limited knowledge… In the meanwhile I’ll clean the recipe a bit, and see what degree of functionality the other rtl-sdr commands have.