这两天又想折腾接收飞机的1090M信号玩了,之前弄过N次,这次把天线扔到一个不怎么起眼的地方,希望能够长期接收。主机当然用树莓派,
安装源里其实就有编译好的dump1090可以直接安装,不过做为喜欢折腾的人可不愿意用现成的(其实后面看来自己折腾就是浪费生命),上github查了下,dump1090现在有以下几个版本:
pi@raspberrypi:~/dump1090-orig/dump1090-master $ make
cc -g -o dump1090 dump1090.o anet.o -L -lrtlsdr -lpthread -lm
/usr/bin/ld: dump1090.o: in function `modesInitRTLSDR':
/home/pi/dump1090-orig/dump1090-master/dump1090.c:342: undefined reference to `rtlsdr_get_device_count'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:350: undefined reference to `rtlsdr_get_device_usb_strings'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:355: undefined reference to `rtlsdr_open'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:362: undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:374: undefined reference to `rtlsdr_set_tuner_gain'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:379: undefined reference to `rtlsdr_set_freq_correction'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:381: undefined reference to `rtlsdr_set_center_freq'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:382: undefined reference to `rtlsdr_set_sample_rate'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:383: undefined reference to `rtlsdr_reset_buffer'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:385: undefined reference to `rtlsdr_get_tuner_gain'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:380: undefined reference to `rtlsdr_set_agc_mode'
/usr/bin/ld: /home/pi/dump1090-orig/dump1090-master/dump1090.c:370: undefined reference to `rtlsdr_get_tuner_gains'
/usr/bin/ld: dump1090.o: in function `readerThreadEntryPoint':
/home/pi/dump1090-orig/dump1090-master/dump1090.c:472: undefined reference to `rtlsdr_read_async'
/usr/bin/ld: dump1090.o: in function `main':
/home/pi/dump1090-orig/dump1090-master/dump1090.c:2655: undefined reference to `rtlsdr_close'
collect2: error: ld returned 1 exit status
make: *** [Makefile:12: dump1090] Error 1
刚开始看到这里我还是比较崩溃的,因为编译都已经过了,连接出了问题,说函数找不到定义,看了看Makefile
pi@raspberrypi:~/dump1090-orig/dump1090-master $ cat Makefile
CFLAGS?=-O2 -g -Wall -W $(shell pkg-config --cflags librtlsdr)
LDLIBS+=$(shell pkg-config --libs librtlsdr) -lpthread -lm
CC?=gcc
PROGNAME=dump1090
all: dump1090
%.o: %.c
$(CC) $(CFLAGS) -c $<
dump1090: dump1090.o anet.o
$(CC) -g -o dump1090 dump1090.o anet.o $(LDFLAGS) $(LDLIBS)
clean:
rm -f *.o dump1090
看起来也没啥,很简单,但有shell取值,手工运行了一下。
pi@raspberrypi:~/dump1090-orig/dump1090-master $ pkg-config --libs librtlsdr
-L -lrtlsdr
这个百度了一下,涉及到2个参数[^1],
pi@raspberrypi:~/dump1090-orig/dump1090-master $ dpkg -L librtlsdr-dev
/.
/usr
/usr/include
/usr/include/rtl-sdr.h
/usr/include/rtl-sdr_export.h
/usr/lib
/usr/lib/arm-linux-gnueabihf
/usr/lib/arm-linux-gnueabihf/cmake
/usr/lib/arm-linux-gnueabihf/cmake/rtlsdr
/usr/lib/arm-linux-gnueabihf/cmake/rtlsdr/rtlsdrConfig.cmake
/usr/lib/arm-linux-gnueabihf/cmake/rtlsdr/rtlsdrConfigVersion.cmake
/usr/lib/arm-linux-gnueabihf/cmake/rtlsdr/rtlsdrTargets-relwithdebinfo.cmake
/usr/lib/arm-linux-gnueabihf/cmake/rtlsdr/rtlsdrTargets.cmake
/usr/lib/arm-linux-gnueabihf/librtlsdr.a
/usr/lib/arm-linux-gnueabihf/pkgconfig
/usr/lib/arm-linux-gnueabihf/pkgconfig/librtlsdr.pc
/usr/share
/usr/share/doc
/usr/share/doc/librtlsdr-dev
/usr/share/doc/librtlsdr-dev/README.Debian
/usr/share/doc/librtlsdr-dev/changelog.Debian.gz
/usr/share/doc/librtlsdr-dev/copyright
/usr/lib/arm-linux-gnueabihf/librtlsdr.so
貌似/usr/lib/arm-linux-gnueabihf/librtlsdr.so这个路径还真不像系统标准路径。不管那么多,直接给/usr/lib/arm-linux-gnueabihf/这个路径加到Makefile里,然后再make就通过了,运行也一切正常。
最后成功了收到的飞机效果图如下: