webioPiはその名の通り、webからRasPiのIOに触れる事ができるライブラリです。
verは0.7系で止まってますが、RasPi3系では動きます。
ちょっとした試作であればCODESYSみたいなゴツのを導入したり、
あるいは自前のオラオラ系を作るよりスマートかも。
実際のところ
公式から圧縮ファイル(執筆時点でWebIOPi-0.7.1.tar.gz)を導入し、
解答&インストラー起動。
お手軽ですね。
$ tar xvzf WebIOPi-0.7.1.tar.gz $ cd WebIOPi-x.y.z $ sudo ./setup.sh
しばらく待って、こんなコマンドが実行できていれば成功。
$ sudo webiopi [-h] [-c config] [-l log] [-s script] [-d] [port] Options: -h, --help Display this help -c, --config file Load config from file -l, --log file Log to file -s, --script file Load script from file -d, --debug Enable DEBUG Arguments: port Port to bind the HTTP Server
自動実行の準備
周辺機器に触れる関係でsudoでの実行が前提です。
本体起動時に自動実行して欲しい場合、systemdに先に登録しときます。
……クソザコなので意識してなかったのですが、Jessieからsystemdが推奨になってたんですね……。
$ cd /etc/systemd/system/ $ sudo cat <<EOS > webiopi.service [Unit] Description=WebIOPI After=syslog.target [Service] Type=simple WorkingDirectory=/usr/share/webiopi/htdocs ExecStart=/usr/bin/python3 -m webiopi -l /var/log/webiopi -c /etc/webiopi/config TimeoutStopSec=5 StandardOutput=null [Install] WantedBy = multi-user.target EOS
で、起動&登録。
$ sudo systemctl start webiopi $ sudo systemctl enable webiopi