2020年4月19日日曜日

Raspberry Pi 4 + DVB-T + Ubuntu 18.04 server で ADS-B 受信機を作成 ( Flightradar24、FlightAware、RadarBox )

Raspberry Pi 4 で、ようやく ADS-B フィーダーを動かすことができました。
Ubuntu 19.10 server では、dump1090-fa が、なぜかすぐに落ちました。結局、解決できずしばらく放置してたのですが、
Raspberry Pi 4 用 Ubuntu Server 18.04.4 64-bit が出ていので試したところ、動くようになりました。

■ 環境

HardwareRaspberry Pi 4 Model B / 4 GB
OSUbuntu Server 18.04.4 64-bit
SDSanDisk Ultra micro SDHC 32GB Class10 A1
DVB-TR820T2 & SDR+SMD X-tal 10PPM [DVB-T+FM+DAB/RTL-SDR][RTL2832U+R820T2][High quality USB-CN][広帯域受信用]Blue

1. Ubuntu Server 18.04.4 イメージを micro SD に書き込む

Ubuntu のサイト からイメージを取得。micro SD に書き込む。

$ sudo apt install gddrescue xz-utils
$ unxz ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img.xz
$ sudo ddrescue -D --force ubuntu-18.04.4-preinstalled-server-arm64+raspi3.img /dev/mmcblk0

GNU ddrescue 1.23
Press Ctrl-C to interrupt
     ipos:    4539 MB, non-trimmed:        0 B,  current rate:  14417 kB/s
     opos:    4539 MB, non-scraped:        0 B,  average rate:  14834 kB/s
non-tried:  460714 kB,  bad-sector:        0 B,    error rate:       0 B/s
  rescued:    4539 MB,   bad areas:        0,        run time:      5m  6s
pct rescued:   90.78%, read errors:        0,  remaining time:         32s
                              time since last successful read:          0s
Copying non-tried blocks... Pass 1 (forwards)

2. Ubuntu Server 18.04.4 諸設定

デフォルトユーザのログインは、User: ubuntu, Password ubuntu で。
パスワード変えるのと、adduser でユーザ作りました。
SSHd は、最初から入ってました。
あとはお好みで。

$ sudo apt update
$ sudo apt upgrade

NTP をインストールする。
$ sudo apt remove ntpdate
$ sudo systemctl stop systemd-timesyncd.service
$ sudo systemctl disable systemd-timesyncd.service
$ sudo apt install ntp
$ sudo systemctl enable ntp
$ sudo systemctl start ntp

3. FlightAware

(参考)
https://ja.flightaware.com/adsb/piaware/install
https://discussions.flightaware.com/t/piaware-v-3-7-1-on-debian-10-0-buster-amd64-intel-pc/52414

■ Piaware

$ sudo apt install -y git devscripts build-essential debhelper tcl8.6-dev autoconf python3-dev python3-venv virtualenv \
dh-systemd zlib1g-dev tclx8.4 tcllib tcl-tls itcl3 net-tools libboost-system-dev libboost-program-options-dev \
libboost-regex-dev libboost-filesystem-dev 

$ git clone https://github.com/flightaware/piaware_builder.git
$ cd  piaware_builder
$ ./sensible-build.sh buster

$ cd package-buster
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../ 
$ sudo dpkg -i piaware_3.8.1_arm64.deb piaware-dbgsym_3.8.1_arm64.ddeb

piaware ユーザを手動で作成

$ sudo useradd --system piaware

$ sudo touch /etc/piaware.conf

既に feeder id がある場合は、下記を設定。

$ sudo piaware-config feeder-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 

$ sudo piaware-config allow-auto-updates yes 
$ sudo piaware-config allow-manual-updates yes 

$ sudo systemctl restart piaware

自動起動を有効化

$ sudo systemctl enable piaware

■ dump1090-fa

$ sudo apt install -y git lighttpd build-essential debhelper dh-systemd \
libboost-system-dev libboost-program-options-dev libboost-regex-dev \
libboost-filesystem-dev libsoapysdr-dev soapysdr-module-rtlsdr \
debhelper dh-systemd librtlsdr-dev libusb-1.0-0-dev \
git pkg-config libncurses5-dev lighttpd libbladerf-dev

$ git clone https://github.com/flightaware/dump1090.git dump1090-fa 
$ cd dump1090-fa
$ sudo dpkg-buildpackage -b --no-sign

$ cd ../
$ sudo dpkg -i dump1090-fa_3.8.1_arm64.deb dump1090-fa-dbgsym_3.8.1_arm64.ddeb

$ sudo systemctl restart dump1090-fa

しばらくしたら、下記リンクで Piaware と FlightAware のアカウントを関連付ける。
同じルータ配下の別 PC からブラウザでアクセスすれば OK。 https://flightaware.com/adsb/piaware/claim
更に、MY ADS-B のリンクから、アンテナ設置場所の緯度、経度、高度を設定すれば OK。

4. Flightradar24

tcl-tls のバージョンが古いので、インストールできないと言われた。パッケージの依存関係が壊れた?

$ sudo apt --fix-broken install
$ sudo apt install libssl-dev tcl-dev chrpath

$ git clone http://github.com/flightaware/tcltls-rebuild.git
$ cd tcltls-rebuild  
$ ./prepare-build.sh buster  
$ cd package-buster  
$ sudo dpkg-buildpackage -b --no-sign
$ cd ../  
$ sudo dpkg -i tcl-tls_*.deb 
$ cd ..

$ sudo dpkg --add-architecture armhf
$ sudo dpkg --print-foreign-architectures
armhf

$ sudo bash -c "$(wget -O - https://repo-feed.flightradar24.com/install_fr24_rpi.sh)"

______  _  _         _      _                    _              _____    ___ 
|  ___|| |(_)       | |    | |                  | |            / __  \  /   |
| |_   | | _   __ _ | |__  | |_  _ __  __ _   __| |  __ _  _ __`' / /' / /| |
|  _|  | || | / _` || '_ \ | __|| '__|/ _` | / _` | / _` || '__| / /  / /_| |
| |    | || || (_| || | | || |_ | |  | (_| || (_| || (_| || |  ./ /___\___  |
\_|    |_||_| \__, ||_| |_| \__||_|   \__,_| \__,_| \__,_||_|  \_____/    |_/
               __/ |                                                         
              |___/                                                          
[main][i]FR24 Feeder/Decoder
[main][i]Version: 1.0.25-3/generic
[main][i]Built on Apr  8 2020 07:06:55 (HEAD-5e8ef0c.git/Linux/static_armel)
[main][i]Running on: ubuntu18.04
[main][i]Local IP(s): 192.168.10.10
[main][i]Copyright 2012-2020 Flightradar24 AB
[main][i]https://www.flightradar24.com
[main][i]DNS mode: PING

Welcome to the FR24 Decoder/Feeder sign up wizard!

Before you continue please make sure that:

 1 - Your ADS-B receiver is connected to this computer or is accessible over network
 2 - You know your antenna's latitude/longitude up to 4 decimal points and the altitude in feet
 3 - You have a working email address that will be used to contact you
 4 - fr24feed service is stopped. If not, please run: sudo systemctl stop fr24feed

To terminate - press Ctrl+C at any point


Step 1.1 - Enter your email address (username@domain.tld)
$:●Flightradar24 に登録しているメールアドレスを入力

Step 1.2 - If you used to feed FR24 with ADS-B data before enter your sharing key.
If you don't remember your sharing key, pelase use the retrival form:
https://feed.flightradar24.com/forgotten_key.php

Otherwise leave this field empty and continue.
$:●新規登録であれば、メールで送られてきた sharing key を入力。または既存のものを入力

Verifying sharing key...OK



Step 1.3 - Would you like to participate in MLAT calculations? (yes/no)$:yes

IMPORTANT: For MLAT calculations the antenna's location should be entered very precise!

Step 3.A - Enter antenna's latitude (DD.DDDD)
$:●設置場所の緯度を入力

Step 3.B - Enter antenna's longitude (DDD.DDDD)
$:●設置場所の経度を入力

Step 3.C - Enter antenna's altitude above the sea level (in feet)
$:●設置場所の高度を入力

Using latitude: XX.XXXX, longitude: XXX.XXXX, altitude: XXft above sea level

We have detected that you already have a dump1090 instance running. We can therefore automatically configure the FR24 feeder to use existing receiver configuration, or you can manually configure all the parameters.

Would you like to use autoconfig (*yes*/no)$:● yes を入力

Step 6A - Please select desired logfile mode:
 0 -  Disabled
 1 -  48 hour, 24h rotation
 2 -  72 hour, 24h rotation
Select logfile mode (0-2)$:● 2 を入力

Step 6B - Please enter desired logfile path (/var/log/fr24feed):
$:●何も入力せずに Enter

Submitting form data...OK

Congratulations! You are now registered and ready to share ADS-D data with Flightradar24.
+ Your radar id is T-RJFF33, please include it in all email communication with us.
+ Please make sure to start sharing data within one month from now as otherwise your ID/KEY will be deleted.

Thank you for supporting Flightradar24! We hope that you will enjoy our Premium services that will be available to you when you become an active feeder.

To start sending data now please execute:
sudo systemctl start fr24feed

Saving settings to /etc/fr24feed.ini...OK
Settings saved, please run "sudo systemctl restart fr24feed" to use new configuration.

fr24feed を再起動。

$ sudo systemctl restart fr24feed

5. RadarBox

続いて RadarBox。
RadarBox のアカウントに紐付ける方法は、忘れてしまいました。
通常は、下記を実行するだけなのですが、スクリプト内の lsb_release -c コマンドで、コードネームが bionic となってしまい、
スクリプトが停止してしまいます。
ちょっと修正して、buster と同じ流れにすれば OK。

$ sudo apt install libc6-dev-armhf-cross
$ sudo bash -c "$(wget -O - http://apt.rb24.com/inst_rbfeeder.sh)"
Don't know how to install for a distribution named で止まってしまう、、、。

inst_rbfeeder.sh を取得して、スクリプトを修正、実行します。

$ wget http://apt.rb24.com/inst_rbfeeder.sh
$ vi inst_rbfeeder.sh
case 文の buster) となっている部分に bionic を追記。
(変更前)
    buster)
(変更後)
    buster|bionic)

$ sudo sh inst_rbfeeder.sh

■2020/05/04 追記。
buster だと、パッケージの依存関係が解消できずに、rbfeeder をインストールできなくなりました。
stretch に変更するとインストールできました。かなり無理クリ。

$ wget http://apt.rb24.com/inst_rbfeeder.sh
$ vi inst_rbfeeder.sh
case 文の stretch) となっている部分に bionic を追記。
(変更前)
    stretch)
(変更後)
    stretch|bionic)

$ sudo sh inst_rbfeeder.sh

mlat-client をソースからインストール。

$ sudo apt install python-minimal
$ wget https://github.com/mutability/mlat-client/archive/v0.2.11.tar.gz
$ tar zxvf v0.2.11.tar.gz
$ cd mlat-client-0.2.11/
$ sudo dpkg-buildpackage -b --no-sign
$ sudo dpkg -i ../mlat-client_0.2.11_arm64.deb
$ sudo ./setup.py install

(再起動)
$ sudo init 6

設定ファイルのメモを残しておきます。

$ cat /etc/rbfeeder.ini
[client]
network_mode=true
log_file=/var/log/rbfeeder.log

key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

sn=XXXXXXXXXXXX

[network]
mode=raw
external_port=30005
external_host=127.0.0.1

[mlat]

6. graphs1090

dump1090-fa の受信状況をグラフで表示。
http://192.168.x.x/graphs1090/ にアクセス。

$ sudo bash -c "$(wget -q -O - https://raw.githubusercontent.com/wiedehopf/graphs1090/master/install.sh)"

■ 2020/05/08 追記

FR24 の MLAT が有効にならない。
fr24feed の起動を遅らせると良いらしい。
参考: https://gato.intaa.net/archives/21762

$ sudo systemctl disable fr24feed

$ sudo vi /etc/sytemd/system/fr24feed.service
(下記を変更)
#After=network-online.target
After=rc-local.service

(LimitCORE=infinity の次の行に下記を追加)
ExecStartPre=/bin/sleep 90

$ sudo systemctl enable fr24feed
$ sudo init 6

■ 備考

ADS-B feeder を設置すると、下記プランが無料で利用可能になります。
年間、$ 1 = 108 円 換算で、$ 499.99 + ($ 89.95 × 12) + $399.50 = $ 1,978.89 = 213,720 円 お得です♪

ServicePlan$ / month$ / year
Flightradar24Business$ 49.99$ 499.99
FlightAwareEnterprise$ 89.95$ -
RadarBoxBUSINESS$ 39.95$ 399.50

dump1090 の受信状況は下記コマンドで確認できる。

$ nc 127.0.0.1 30002
$ nc 127.0.0.1 30003

● Raspberry Pi 3, raspi3, raspi, DVB-T, Ubuntu MATE 18.04, ADS-B, Flightradar24, FlightAware RadarBox, dump1090-fa

0 件のコメント: