receive ADS-B on macosx

投稿日:

飛行機の位置情報(ADS-B)をmac(OS X El Capitan)で受信する。

0. ADS-B受信用のUSBの無線チューナーを購入

ADS-Bを受信するために、USBの受信機を購入。
通常は、FMラジオやアメリカでTVを受信するためのもの。

税込み 1,580円。安い!

これ以外でも、Realtek RTL2832がベースになったものなら、きっと大丈夫。

1. libusb をhomebrewでinstall

% brew update
% brew install libusb
% brew install cmake
% xcode-select  --install

2. RTL2832のドライバをinstall

% mkdir ads-b
% cd ads-b/
% git clone git://git.osmocom.org/rtl-sdr.git
% cd rtl-sdr

cmake でmakeするため、「build」directoryで行う。

% mkdir build
% cd build/
% cmake ..
% cd ..
% make
Scanning dependencies of target convenience_static
[  3%] Building C object src/CMakeFiles/convenience_static.dir/convenience/convenience.c.o
[  6%] Linking C static library libconvenience_static.a
[  6%] Built target convenience_static
Scanning dependencies of target rtlsdr_shared
[ 10%] Building C object src/CMakeFiles/rtlsdr_shared.dir/librtlsdr.c.o
% make install
[  6%] Built target convenience_static
[ 30%] Built target rtlsdr_shared
[ 36%] Built target rtl_adsb
[ 43%] Built target rtl_eeprom
[ 50%] Built target rtl_fm
[ 56%] Built target rtl_power
[ 63%] Built target rtl_sdr
[ 70%] Built target rtl_tcp
[ 76%] Built target rtl_test
[100%] Built target rtlsdr_static
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/pkgconfig/librtlsdr.pc
-- Installing: /usr/local/include/rtl-sdr.h
-- Installing: /usr/local/include/rtl-sdr_export.h
-- Installing: /usr/local/lib/librtlsdr.0.5git.dylib

3. 受信ソフト dump1090 をinstall

% cd ads-b/
% git clone https://github.com/MalcolmRobb/dump1090.git
% cd dump1090/
% make
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c dump1090.c
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c anet.c
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c interactive.c
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c mode_ac.c
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c mode_s.c
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c net_io.c
gcc -g -o dump1090 dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o `pkg-config --libs librtlsdr` -lpthread -lm 
gcc -O2 -g -Wall -W `pkg-config --cflags librtlsdr`  -c view1090.c
gcc -g -o view1090 view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o `pkg-config --libs librtlsdr` -lpthread -lm 

4. 受信ソフトを実行

% ./dump1090 
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
Found Rafael Micro R820T tuner
Max available gain is: 49.60
Setting gain to: 49.60
Exact sample rate is: 2000000.052982 Hz
Gain reported by device: 49.60
*5d71bd341b31cb;
CRC: 000000 (ok)
DF 11: All Call Reply.
  Capability  : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is airborne))
  ICAO Address: 71bd34
  IID         : II-00

バラバラと受信情報が出力されればOK。

web画面でみるためには、以下のように起動

% ./dump1090 --aggressive --ppm 50 --net --quiet 
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
Found Rafael Micro R820T tuner
Max available gain is: 49.60
Setting gain to: 49.60
Exact sample rate is: 2000000.052982 Hz
Gain reported by device: 49.60

これで、8080にhttpd機能が上がるので、以下のURLにアクセス

http://localhost:8080/

飛行機が飛んでる1

新宿でアンテナを立てると、埼玉から川崎まで見える。

飛行機が飛んでる2

フライトの内容もわかる。

フライト表