Raspberry Piでstr2strを起動時に動かす方法について調べてみました。
str2strって?
私自身よく理解はしていないのですが、GNSSを使ったRTK測位で、基準局のデータなどを配信する場合に使うもののようです。別に基準局でもなく移動局のデータでも構いません。つまりこれを使うことでRTK測位用のデータをIP配信することが出来るということです。
Raspiで2つのデータを配信するための設定方法です。
目次
systemdで起動するために
str2str2.serviceとstr2str3.serviceという2つのファイルを作り
/lib/systemd/system/
にコピーします。
2つのserviceの中は以下のようになっています。
str2str2.service
[Unit] Description=str2str2 [Service] Type=simple ExecStart=/home/pi/str2str2.sh Restart=Always [Install] WantedBy=multi-user.target
str2str3.service
[Unit] Description=str2str2 [Service] Type=simple ExecStart=/home/pi/str2str3.sh Restart=Always [Install] WantedBy=multi-user.target
ホーム(/home/pi)に作ったスクリプトは簡単ですが
str2str2.sh とstr2str3.sh です。
str2str2.sh
#!/bin/sh
/home/pi/myRTKLIB/RTKLIB/app/str2str/gcc/str2str -in serial://ttyACM0:115200#ubx -out tcpsvr://localhost:52001
str2str3.sh
#!/bin/sh
/home/pi/myRTKLIB/RTKLIB/app/str2str/gcc/str2str -in serial://ttyACM1:115200#ubx -out tcpsvr://localhost:52002
なお & を付けると起動できませんでした。ここら辺は、Linuxの素人なのでよく理解していません。
str2str2.serviceとstr2str3.serviceの起動の仕方
$ sudo systemctl start str2str2.serrvice $ sudo systemctl start str2str3.service $ sudo systemctl enable str2str2.service $ sudo systemctl enable str2str3.service
停止とdisable
$ sudo systemctl stop str2str2.service $ sudo systemctl stop str2str3.service $ sudo systemctl disable str2str2.service $ sudo systemctl disable str2str3.service
これで、Raspiを立ち上げると自動的にstr2strが起動して配信を行います。どこかに間違いがあるかもしれませんが、一応動いているのでよしとします。
これでRaspberry Piの初期のものを全てサーバ用として使い切ってしまいました。 次は、Raspberry Pi 3に進もうかな。
コメント