Rasbian_jessie – matoken's blog https://matoken.org/blog Is there no plan B? Sat, 23 Dec 2017 08:02:36 +0000 ja hourly 1 https://wordpress.org/?v=7.0 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Rasbian_jessie – matoken's blog https://matoken.org/blog 32 32 Linux ARM版Vivaldiを入れてみた https://matoken.org/blog/2017/12/07/i-put-the-linux-arm-version-vivaldi/ https://matoken.org/blog/2017/12/07/i-put-the-linux-arm-version-vivaldi/#comments Wed, 06 Dec 2017 21:32:30 +0000 http://matoken.org/blog/?p=1721 20171207_01:12:04-24154

Operaの共同創設者でCEOだったJon Stephenson von Tetzchnerによって設立されたVivaldi Technologiesによって開発されているウェブブラウザがあります.
これまでx86/x64プラットホームのWindows/macOS/Linux版が提供されていましたが,2017/12/05にLinux ARM版(armhf)がリリースされました.

Raspberry PiのRaspbianがメインのようですが,他のARM環境でも試したら普通に動きました :)

といってもやはりRAM512MBのようなマシンでは辛いですね.RAM2GBのマシンだと今のところいい感じそうです.Midoriやqutebrowserでうまく表示できないMastodonやgmail/Google+なども問題なく表示できますし,Chromeの拡張機能も使えます.

Linux ARM版Vivaldiの入手と確認

deb pkgダウンロード

$ wget https://downloads.vivaldi.com/stable/vivaldi-stable_1.13.1008.34-1_armhf.deb

hash

hashとか見当たらないけど手元ではこんな感じだった

$ md5sum vivaldi-stable_1.13.1008.34-1_armhf.deb 
7515f51385a9a264ad5bb7612438aeda  vivaldi-stable_1.13.1008.34-1_armhf.deb
$ sha1sum vivaldi-stable_1.13.1008.34-1_armhf.deb 
6b103d205f6aa7a5f3b394ba8d32dc9ca87bf0cd  vivaldi-stable_1.13.1008.34-1_armhf.deb
$ sha256sum vivaldi-stable_1.13.1008.34-1_armhf.deb 
e7af5d021bf0c2968fcf0271e8f741552e34bcf2d032318eb8ea95356067297d  vivaldi-stable_1.13.1008.34-1_armhf.deb
$ sha512sum vivaldi-stable_1.13.1008.34-1_armhf.deb 
f47f2d26e8045af9ba680129feca765cf3f9dc7ea76930071e9688ef50aa78a482b40ba5747fb4470d30520177bda371ec79e5a210a93dcf2e49251425001c6d  vivaldi-stable_1.13.1008.34-1_armhf.deb

パッケージ情報確認

$ dpkg-deb -I ./vivaldi-stable_1.13.1008.34-1_armhf.deb
 新形式 debian パッケージ、バージョン 2.0。
 サイズ 45154158 バイト: コントロールアーカイブ = 9840 バイト。
    1269 バイト、   16 行      control              
   15872 バイト、  442 行   *  postinst             #!/bin/sh
   12544 バイト、  324 行   *  postrm               #!/bin/sh
    1220 バイト、   42 行   *  prerm                #!/bin/sh
 Package: vivaldi-stable
 Version: 1.13.1008.34-1
 Architecture: armhf
 Maintainer: Vivaldi Package Composer <packager@vivaldi.com>
 Installed-Size: 131921
 Pre-Depends: dpkg (>= 1.14.0)
 Depends: gconf-service, libasound2 (>= 1.0.16), libatk1.0-0 (>= 1.12.4), libc6 (>= 2.16), libcairo2 (>= 1.6.0), libcups2 (>= 1.4.0), libdbus-1-3 (>= 1.2.14), libexpat1 (>= 2.0.1), libfontconfig1 (>= 2.8.0), libgcc1 (>= 1:4.4.0), libgconf-2-4 (>= 3.2.5), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.28.0), libgtk-3-0 (>= 3.9.10), libnspr4 (>= 2:4.9-2~), libpango-1.0-0 (>= 1.14.0), libpangocairo-1.0-0 (>= 1.14.0), libx11-6 (>= 2:1.4.99.1), libx11-xcb1, libxcb1 (>= 1.6), libxcomposite1 (>= 1:0.3-1), libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxi6 (>= 2:1.2.99.4), libxrandr2 (>= 2:1.2.99.3), libxrender1, libxss1, libxtst6, ca-certificates, fonts-liberation, libnss3 (>= 3.26), xdg-utils (>= 1.0.2), wget
 Recommends: adobe-flashplugin, chromium-codecs-ffmpeg-extra
 Conflicts: vivaldi-beta, vivaldi-preview
 Replaces: vivaldi-beta, vivaldi-preview
 Provides: www-browser
 Section: web
 Priority: optional
 Homepage: https://vivaldi.com
 Description: A new browser for our friends
  Vivaldi browser is made with power users in mind by people who love the Web.

導入

とりあえずDebian jessie armhf/Ubuntu 16.04 LTS aarch64で動いている.

Debian/Ubuntu等

$ sudo dpkg -i ./vivaldi-stable_1.13.1008.34-1_armhf.deb

以下のように依存パッケージが足りない場合は,

dpkg: 依存関係の問題により vivaldi-stable:armhf の設定ができません:
 vivaldi-stable:armhf は以下に依存 (depends) します: libnss3 (>= 3.26)...しかし:
  パッケージ libnss3:armhf はまだインストールされていません。

dpkg: パッケージ vivaldi-stable:armhf の処理中にエラーが発生しました (--install):
 依存関係の問題 - 設定を見送ります

こんな感じで足りないpkgが入るはず.その後見送られていたvivaldi-stableの設定の続きも実行される.

$ sudo apt install -f

64bit ARM環境

バージョン情報_009

aarch64でも試した.
既にadd archtecture armhfして色々入れていた環境に入れてクリーンな環境で検証していないけど多分こんな感じ.

$ sudo dpkg --add-architecture armhf
$ sudo apt update
$ sudo dpkg -i ./vivaldi-stable_1.13.1008.34-1_armhf.deb
$ sudo apt install -f

—-追記—-
クリーンなDragonBoard 410cにDebian stretch aarch64(lonaro)を入れた環境でも確認したがこの手順でokだった :)
—-追記終わり—-

.debが使えない環境

deb以外の環境ではこんな感じで適当な場所に展開して動かせた.

$ mkdir -p ~/opt/vivaldi
$ ar p vivaldi-stable_1.13.1008.34-1_armhf.deb data.tar.xz | tar xJ -C ~/opt/vivaldi
$ rm vivaldi-stable_1.13.1008.34-1_armhf.deb
$ ~/opt/vivaldi/opt/vivaldi/vivaldi

Slackwareだと以下のsctiptが使えそう(未確認)

問題

sandbox

もし,こんなエラーが出たら

$ ~/opt/vivaldi/opt/vivaldi/vivaldi
[13021:13021:1205/215600.516642:FATAL:setuid_sandbox_host.cc(157)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /home/matoken/opt/vivaldi/opt/vivaldi/vivaldi-sandbox is owned by root and has mode 4755.
Aborted[This script will find the latest Vivaldi binary package, download it and repackage it into Slackware format.](https://gist.github.com/ruario/dcbba70da900dac68fcc883542ff7ace "This script will find the latest Vivaldi binary package, download it and repackage it into Slackware format.")

こんな感じでオーナーとパーミッションを設定したらok.

$ chmod 4755 ~/opt/vivaldi/opt/vivaldi/vivaldi-sandbox
$ sudo chown root.root ~/opt/vivaldi/opt/vivaldi/vivaldi-sandbox

若しくは --no-sandbox option

$ ~/opt/vivaldi/opt/vivaldi/vivaldi --no-sandbox

日本語豆腐問題

20171206_06:12:20-506920171206_07:12:16-6600

とりあえず適当な日本語フォント(今回はVLゴシック)を入れて,Vivaldiを再起動で直った.(Dejavuが入っていたので指定してみたけど直らなかった)

$ sudo apt install fonts-vlgothic

関連

]]>
https://matoken.org/blog/2017/12/07/i-put-the-linux-arm-version-vivaldi/feed/ 3
Raspbian jessieのntp設定 https://matoken.org/blog/2017/10/25/raspbian-jessie-ntp-setting/ https://matoken.org/blog/2017/10/25/raspbian-jessie-ntp-setting/#respond Tue, 24 Oct 2017 17:47:45 +0000 http://matoken.org/blog/?p=1694 Raspbianにntpdやchronyやntpdateとか居ないけど何が面倒見てるんだろうてことで確認.
systemdが面倒見ててtimeatectlコマンドで確認設定ができるらしい.

$ dpkg -l|egrep -i "ntp|chrony"
$ systemctl -a | grep -i ntp

今の状態を確認

$ timedatectl status
      Local time: Wed 2017-10-25 02:01:14 JST
  Universal time: Tue 2017-10-24 17:01:14 UTC
        RTC time: n/a
       Time zone: Asia/Tokyo (JST, +0900)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

NTP同期を無効にしてみる

$ sudo timedatectl set-ntp false

無効になった( Network time on: no )
再起動すると NTP synchronizedno にもなる.

$ timedatectl status
      Local time: Wed 2017-10-25 02:01:39 JST
  Universal time: Tue 2017-10-24 17:01:39 UTC
        RTC time: n/a
       Time zone: Asia/Tokyo (JST, +0900)
 Network time on: no
NTP synchronized: yes
 RTC in local TZ: no

おまけ

タイムゾーンの確認

$ timedatectl list-timezones | grep -i tokyo
Asia/Tokyo

タイムゾーンの設定

$ sudo timedatectl set-timezone

任意のntp serverの指定

dhcpdから渡ってきたもの.

hdcpdに無い場合 /etc/systemd/timesyncd.conf
NTPFallbackNTP

環境

Raspbian stretch lite 2017-09-07(未update)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.1 (stretch)
Release:        9.1
Codename:       stretch
$ uname -a
Linux raspberrypi 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux

]]>
https://matoken.org/blog/2017/10/25/raspbian-jessie-ntp-setting/feed/ 0
/proc/cpuinfoのSerialを詐称する https://matoken.org/blog/2017/04/06/spoof-proc-cpuinfo-serial/ https://matoken.org/blog/2017/04/06/spoof-proc-cpuinfo-serial/#comments Thu, 06 Apr 2017 11:18:58 +0000 http://matoken.org/blog/?p=1593
$ cat /proc/cpuinfo | sed -e 's/Serial.*/Serial\t\t: 00000000deadbeef/' > /tmp/cpuinfo_fake
$ sudo chmod 444 /tmp/cpuinfo
$ sudo chown root.root /tmp/cpuinfo
$ sudo mount -o bind /tmp/cpuinfo_fake /proc/cpuinfo
$ tail /proc/cpuinfo
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 5

Hardware        : BCM2835
Revision        : a01041
Serial          : 00000000deadbeef

]]>
https://matoken.org/blog/2017/04/06/spoof-proc-cpuinfo-serial/feed/ 1
mosh 1.3.0をDropbear sshdで利用してみる https://matoken.org/blog/2017/03/28/try-dropbear-sshd-with-mosh-1-3-0/ https://matoken.org/blog/2017/03/28/try-dropbear-sshd-with-mosh-1-3-0/#respond Mon, 27 Mar 2017 22:49:07 +0000 http://matoken.org/blog/?p=1571 moshの1.3.0がリリースされました.

moshはsshを置き換えようとしているソフトウェアで,ネットワークが遅いときにローカルエコーを表示したり,ネットワークが切り替わってもローミングしたりと便利なソフトウェアです.(NotePCで接続してサスペンドして別のネットワークでレジュームしてもすぐに使っていた端末にアクセスできる)

1.3.0でなにかおもしろい機能が増えたりしていないかなと眺めていると

  * Add --no-ssh-pty option for Dropbear compatibility and other issues.

Dropbearで使えるようになるオプションが増えているようです.
DropbearはOpenSSHに比べて大分小さなsshdです.組み込みとかで使われているのを見ます.でも機能が物足りないなと思うことも.

mosh + Dropbearの組み合わせを試してみました.

試したのはこんな感じの環境です.

Host : Raspbian jessie(Raspberry Pi 2B)
Client : Debian sid amd64

dropbearの準備

HostにDropbearをパッケージで導入します

$ sudo apt install dropbear

dropbearのhost鍵を用意

$ mkdir /tmp/dropbear
$ dropbearkey -t ecdsa -s 521 -f /tmp/dropbear/dropbear_ecdsa_host_key
  • -t 鍵種類
  • -s 鍵長
  • -f 鍵ファイル

接続時に解りやすいようにバナーファイル作成

$ banner dropbear > /tmp/dropbear/banner

Dropbearを2222番ポートで起動

$ dropbear -r /tmp/dropbear/dropbear_ecdsa_host_key -p 2222 -b /tmp/dropbear/banner -E
  • -r host鍵を指定
  • -p sshポート番号
  • -b バナーファイル
  • -E 標準エラー出力にメッセージ出力

Dropbearにssh接続できるか確認

$ ssh pi@192.168.2.200 -i ~/.ssh/id_ecdsa -p 2222
Host key fingerprint is SHA256:G3u9pP4ZrkZ2kWs9e+ly9MkEtnO0f4ebvkBS0ObGJQQ
+---[ECDSA 521]---+
|          E+.    |
|           .+ .  |
|           +.+   |
|           .*o . |
|        S ..o++ .|
|         +o++oo= |
|        oo.o= *+=|
|         ..+ *o**|
|         o+o=.O=o|
+----[SHA256]-----+

 #####   #####    ####   #####   #####   ######    ##    #####
 #    #  #    #  #    #  #    #  #    #  #        #  #   #    #
 #    #  #    #  #    #  #    #  #####   #####   #    #  #    #
 #    #  #####   #    #  #####   #    #  #       ######  #####
 #    #  #   #   #    #  #       #    #  #       #    #  #   #
 #####   #    #   ####   #       #####   ######  #    #  #    #

Authenticated to 192.168.2.200 ([192.168.2.200]:2222).

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~ $ 

mosh 1.3.0の準備

server側はsourceからbuild

$ sudo apt-get build-dep mosh
$ wget https://mosh.org/mosh-1.3.0.tar.gz
$ sha256sum mosh-1.3.0.tar.gz
320e12f461e55d71566597976bd9440ba6c5265fa68fbf614c6f1c8401f93376  mosh-1.3.0.tar.gz

※hashとgpg署名は以下のメールに,鍵は https://mosh.org/ の一番下にある.

sourceを展開してbuild

$ tar tvf mosh-1.3.0.tar.gz
$ tar xf mosh-1.3.0.tar.gz
$ ./configure --prefix=${HOME}/usr/local
$ make
$ install

host側はDebian sid amd64のパッケージを利用した

$ sudo apt install mosh
$ dpkg-query -W mosh
mosh    1.3.0-1

ということでホスト側はこんな状態に

  • OpenSSH : 22番ポート
  • Dropbear : 2222番ポート
  • mosh 1.2.4a-1+b2(pkg) : /usr/bin/mosh-server
  • mosh 1.3.0 : ${HOME}/usr/local/bin/mosh-server

この状態でDropbearとmosh 1.3.0を利用するにはこんな感じ

$ mosh pi@192.168.2.200 --ssh="ssh -p 2222" --server='${HOME}'/usr/local/bin/mosh-server

でも実際に繋ごうとするとエラーになってしまう.

接続元のmoshではこんなエラー

/usr/bin/mosh: Did not find mosh server startup message. (Have you installed mosh on your server?)

接続先のDropbearではこんなエラー

[20390] Mar 28 06:37:20 Child connection from 192.168.2.205:32888
[20390] Mar 28 06:37:21 Pubkey auth attempt with unknown algo for 'pi' from 192.168.2.205:32888
[20390] Mar 28 06:37:21 Pubkey auth succeeded for 'pi' with key md5 0b:fb:21:45:d6:a0:7d:57:02:24:9b:d3:ed:c7:c6:23 from 192.168.2.205:32888
[20391] Mar 28 06:37:21 ioctl(TIOCSCTTY): Input/output error
[20391] Mar 28 06:37:21 /dev/pts/1: No such file or directory
[20391] Mar 28 06:37:21 open /dev/tty failed - could not set controlling tty: No such device or address
[20390] Mar 28 06:37:21 Exit (pi): Disconnect received

ということで,mosh 1.3.0で入った--no-ssh-ptyを付けてみます.

$ mosh pi@192.168.2.200 --ssh="ssh -p 2222" --server='${HOME}'/usr/local/bin/mosh-server --no-ssh-pty

asciicast

うまく繋がりました.
試しに回線を切断して再接続すると自動的に繋がるのも確認 ☺

--no-ssh-ptyを~/.ssh/configとかに書いとけるといいんですけどね.今のところ毎回指定するしかなさそう?

]]>
https://matoken.org/blog/2017/03/28/try-dropbear-sshd-with-mosh-1-3-0/feed/ 0
Raspberry Piでコンポジットで起動した後に解像度やディスプレイを変更する https://matoken.org/blog/2017/02/21/change-the-resolution-and-display-after-starting-with-composite-with-raspberry-pi/ https://matoken.org/blog/2017/02/21/change-the-resolution-and-display-after-starting-with-composite-with-raspberry-pi/#respond Tue, 21 Feb 2017 13:33:27 +0000 http://matoken.org/blog/?p=1525

コンポジット出力の解像度変更

Raspberry Piを起動するときにHDMIを接続した状態で起動すると高解像度で起動しますが,繋いでいないとコンポジット出力で起動してXの解像度が720×480になってちょっと手狭です.
xrandrで解像度を追加するとXの再起動もせずに高解像度に出来ます.

※xrandrコマンドは対象のX端末上か,DISPLAY変数を対象のものを指定して実行すること

  • 720x480しか選べない
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  • cvtコマンドで設定したい解像度を指定してModelineを調べる
$ cvt 1360 768
# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz
Modeline "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • xrandrのmodeを作成する
$ xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • modeが増えている
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  1360x768_60.00 (0x248) 84.750MHz
        h: width  1360 start 1432 end 1568 total 1776 skew    0 clock  47.72KHz
        v: height  768 start  771 end  781 total  798           clock  59.80Hz
  • modeをComposite-0に追加する
$ xrandr --addmode Composite-0 1368x768_60.00
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 設定したmodeに切り替える
$ xrandr --output Composite-0 --mode 1360x768_60.00

起動後にHDMIに切り替える

解像度の変更ではなく起動後にHDMI接続に切り替えるのもxrandrで出来ます.こちらもXの再起動は必要ありません.

  • HDMIケーブルを接続するとHDMI-0 connectedとなってmodeが選べるようになる
$ xrandr 
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 2048 x 2048
HDMI-0 connected 1366x768+0+0 (normal left inverted right x axis y axis) 580mm x 360mm
   1366x768      59.79*+
   1920x1080     60.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1280x1024     60.02  
   1152x864      75.00  
   1280x720      60.00    58.68    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x576i      50.00  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
Composite-0 unknown connection (normal left inverted right x axis y axis)
   720x480       62.69  
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 一度にコンポジットを無効にしてHDMIを有効にしようとするとエラーとなる
$ xrandr --output Composite-0 --off --output HDMI-0 --auto
xrandr: cannot find crtc for output HDMI-0
  • 一度に行うのではなく先にコンポジットを無効にしてからHDMIを有効にするとうまく行った
$ DISPLAY=:0 xrandr --output Composite-0 --off
$ DISPLAY=:0 xrandr --output HDMI-0 --auto
  • 逆にHDMIからコンポジットに切り替えることも出来る
$ xrandr --output HDMI-0 --off
$ xrandr --output Composite-0 --mode 1360x768_60.00

環境

  • HW : Raspberry Pi B 2
$ screenfetch 
    .',;:cc;,'.    .,;::c:,,.    pi@raspberrypi
   ,ooolcloooo:  'oooooccloo:    OS: Unknown 8.0 jessie
   .looooc;;:ol  :oc;;:ooooo'    Kernel: armv7l Linux 4.9.11-v7+
     ;oooooo:      ,ooooooc.     Uptime: 4h 28m
       .,:;'.       .;:;'.       Packages: 1541
       .... ..'''''. ....        Shell: 3362
     .''.   ..'''''.  ..''.      Resolution: 1368x768
     ..  .....    .....  ..      DE: LXDE lxpanel 0.7.2
    .  .'''''''  .''''''.  .     WM: OpenBox
  .'' .''''''''  .'''''''. ''.   GTK Theme: Clearlooks [GTK2], Not Found [GTK3]
  '''  '''''''    .''''''  '''   Icon Theme: nuoveXT2
  .'    ........... ...    .'.   Font: Sans 10
    ....    ''''''''.   .''.     CPU: ARMv7 rev 5 (v7l) @ 900MHz
    '''''.  ''''''''. .'''''     RAM: 258MB / 922MB
     '''''.  .'''''. .'''''.    
      ..''.     .    .''..      
            .'''''''            
             ......       

]]>
https://matoken.org/blog/2017/02/21/change-the-resolution-and-display-after-starting-with-composite-with-raspberry-pi/feed/ 0
RaspbianでUVCデバイスが認識できなくて困る https://matoken.org/blog/2016/06/07/usb-device-is-troubled-not-be-recognized-by-the-raspbian/ https://matoken.org/blog/2016/06/07/usb-device-is-troubled-not-be-recognized-by-the-raspbian/#respond Tue, 07 Jun 2016 12:38:06 +0000 http://matoken.org/blog/?p=1382

昨日の話なのですが,Rasbianの入ったRaspberry PiでUVCのWebCam(logitech c270)が認識しなくて困りました.
接続してdmesgやlsusbには該当のvid/pidは出てきます.でも/dev/video?などは出てこず.
手動でomdule を読みこませようとするとこんなエラー.

$ sudo modprobe uvcvideo
modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.9-v7+/modules.dep.bin'

apt update && apt upgradeでkernel更新したけど再起動して反映していない&Raspbianでは古いmoduleはupgraed時に消されるということだったようです.
再起動して新しいKernelにして解決でした.
通常のDebian等では残ってるのでちょっと嵌まりましたorz

]]>
https://matoken.org/blog/2016/06/07/usb-device-is-troubled-not-be-recognized-by-the-raspbian/feed/ 0
Raspbian jessieでもhiptextを試す https://matoken.org/blog/2016/06/01/try-hiptext-even-raspbian-jessie/ https://matoken.org/blog/2016/06/01/try-hiptext-even-raspbian-jessie/#respond Wed, 01 Jun 2016 08:41:32 +0000 http://matoken.org/blog/?p=1380

さっき

というのを書きましたが,なんとなくRaspberry Pi B+ の Raspbian jessie lite でも`hiptext`を試してみました.

$ sudo apt install build-essential libpng12-dev libjpeg-dev     libfreetype6-dev libgif-dev ragel libavformat-dev libavcodec-dev     libswscale-dev libgflags-dev libgoogle-glog-dev git
$ git clone https://github.com/jart/hiptext.git
$ cd hiptext
$ time make
   :
real    22m7.443s
user    21m53.190s
sys     0m8.910s

て感じでほぼREADMEのままmake一発でした.違ったのは導入パッケージに`git`が必要だったくらいです.
思いの外makeに時間が掛かりましたがRaspberry Pi B+で試しているので2Bや3Bだともっと速いでしょう.
Balls.pngやObama.jpgはうまく行き,さっきうまく行かなかったTux.pngは同じようにコケたので同じ動きのようです.

恐らく Debian jessie でも同様だと思います.

27293516472 deedbe97a4

]]>
https://matoken.org/blog/2016/06/01/try-hiptext-even-raspbian-jessie/feed/ 0
Radikoを自動的に録音してPodcast化してくれるradicastを試す https://matoken.org/blog/2016/03/09/try-the-automatically-recorded-me-turned-into-further-podcast-by-radicast-the-radiko/ https://matoken.org/blog/2016/03/09/try-the-automatically-recorded-me-turned-into-further-podcast-by-radicast-the-radiko/#respond Tue, 08 Mar 2016 23:26:15 +0000 http://matoken.org/blog/?p=1278

Radikoを自動的に録音してPodcast化してくれるradicastというものを見つけました.

昔はこんな感じで録音したりしていましたが仕様が変わって録音できなくなって対応というのが面倒で最近は録音していませんでした.たまに聞くときはAndroidのRazikoを使っています.でもradicastならお手軽に動かせてPodcastとして扱えるので便利そうということで試してみました.

試した環境はUbuntu 14.04 amd64/Debian stretch testing amd64/Rasbian jessieですが,Ubuntu環境では録音開始時に以下のようにコアダンプしてしまうようでうまく行っていません :-(

2016/03/09 05:20:00 [radiko] start record
2016/03/09 05:20:00 [radiko] GET http://radiko.jp/player/swf/player_3.0.0.01.swf
2016/03/09 05:20:04 [radiko] POST https://radiko.jp/v2/api/auth1_fms
Segmentation fault (コアダンプ)

dockerでも動きますが,今回は実機で動かしています.

必要なpkgの導入

$ sudo apt install libav-tools swftools rtmpdump golang-go

※Debian stretchの場合はlibav-toolsの代わりにffmpegを導入.

go getで導入

$ GOPATH=~/usr/local/go go get github.com/soh335/radicast

オプションはこんな感じでした.

$ ~/usr/local/go/bin/radicast -h
Usage of /home/mk/usr/local/go/bin/radicast:
  -bitrate string
        bitrate (default "64k")
  -buffer int
        buffer for recording (default 60)
  -config string
        path of config.json (default "config.json")
  -converter string
        ffmpeg or avconv. If not set this option, radicast search its automatically.
  -host string
        host (default "0.0.0.0")
  -output string
        output (default "output")
  -port string
        port (default "3355")
  -setup
        initialize json configuration
  -title string
        title (default "radicast")

設定ファイル作成

--setupオプションでスケルトンを作成して,

$ ~/usr/local/go/bin/radicast --setup > ~/usr/local/go/etc/radicast.json
$ cat ~/usr/local/go/etc/radicast.json
{
  "HOUSOU-DAIGAKU": [],
  "MBC": [],
  "RN1": [],
  "RN2": []
}

次のページを参考にcron形式で設定します.crontabと違い秒単位まで指定できるようです.

例えば"0 0 7 * * MON-FRI" だと月曜から金曜の07:00:00の番組を録音となります.
録音停止は自動的にされるようです.

$ cat ~/usr/local/go/etc/radicast.json
{
  "HOUSOU-DAIGAKU": [],
  "MBC": [
    "0 0 5 * * MON-FRI",
    "0 10 5 * * MON-FRI",
    "0 0 7 * * MON-FRI"
  ],
  "RN1": [],
  "RN2": []
}

実行

設定ファイルを指定して実行します.

$ ~/usr/local/go/bin/radicast -config=$HOME/usr/local/go/etc/radicast.json
2016/03/09 05:00:12 [radicast] station:MBC spec:0 0 5 * * MON-FRI
2016/03/09 05:00:12 [radicast] station:MBC spec:0 10 5 * * MON-FRI
2016/03/09 05:00:12 [radicast] station:MBC spec:0 0 7 * * MON-FRI
2016/03/09 05:00:12 [radicast] start new cron
2016/03/09 05:00:12 [server] start 0.0.0.0:3355

指定時刻になると,番組情報を取得して録音が始まり,番組終了時に録音が終了して次のジョブまで待機します.

2016/03/09 06:30:00 [radiko] start record
2016/03/09 06:30:00 [radiko] GET http://radiko.jp/player/swf/player_3.0.0.01.swf
2016/03/09 06:30:04 [radiko] POST https://radiko.jp/v2/api/auth1_fms
2016/03/09 06:30:05 [radiko] POST https://radiko.jp/v2/api/auth2_fms
2016/03/09 06:30:06 [radiko] GET http://radiko.jp/v2/api/program/today?area_id=JP46
2016/03/09 06:30:07 [radiko] start recording モーニング・スマイル
2016/03/09 06:30:07 [radiko] rtmpdump command: /usr/bin/rtmpdump --live --quiet -r rtmpe://f-radiko.smartstream.ne.jp --playpath simul-stream.stream --app MBC/_definst_ -W http://radiko.jp/player/swf/player_3.0.0.01.swf -C S:"" -C S:"" -C S:"" -C S:J_Rb9kLWN2Cb5XlcGqQjfw --stop 1853 -o -
2016/03/09 06:30:07 [radiko] converter command: /usr/bin/ffmpeg -y -i - -vn -acodec libmp3lame -ar 44100 -ab 64k -ac 2 /tmp/radiko240330221/radiko_0.mp3

データは以下のようにoutput以下に保存されています.

$ find output -ls
  6724248      0 drwxr-xr-x   1 mk       mk             36  3月  9 05:55 output
  6724778      0 drwxr-xr-x   1 mk       mk             44  3月  9 05:55 output/20160309053000_MBC
  6724327  10168 -rw-r--r--   1 mk       mk       10409132  3月  9 05:55 output/20160309053000_MBC/podcast.mp3
  6724779      4 -rw-r--r--   1 mk       mk            650  3月  9 05:55 output/20160309053000_MBC/podcast.xml

録音中のテンポラリファイルは/tmp以下に作られます.

$ ls -lA /tmp/radiko077215706/
合計 5184
-rw-r--r-- 1 mk mk 5223512  3月  9 07:10 radiko_0.mp3

録音したデータはPodcastとして配信されます.このURLは規定値ではlocalhostからしかアクセスできません.このURLをPodcast Aggregatorに指定してあげると普通にPodcastとして扱えます :)

$ xmllint http://localhost:3355/rss
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
    <channel>
        <title>radicast</title>
        <itunes:owner/>
        <itunes:image/>
        <itunes:category/>
        <item>
            <title>生島ヒロシのおはよう一直線 (2016-03-09 05:30:00 +0900 JST)</title>
            <itunes:author>生島ヒロシ</itunes:author>
            <itunes:summary> &lt;br /&gt;&lt;A href="http://www.mbc.co.jp/radio/" target="_blank"&gt;&lt;img src="http://www.mbc.co.jp/radio/radiko/bn/mbcradio_pr1410.png" alt="MBCradio" /&gt;&lt;/A&gt;&lt;br /&gt;&lt;br /&gt;twitterハッシュタグは「&lt;a href="http://twitter.com/#!/search/%23mbc1107"&gt;#mbc1107&lt;/a&gt;」</itunes:summary>
            <itunes:image/>
            <enclosure url="http://localhost:3355/podcast/20160309053000_MBC.mp3" length="10409132" type="audio/mpeg"/>
            <pubDate>Wed, 9 Mar 2016 05:55:45 +0900</pubDate>
        </item>
    </channel>
</rss>

Podcast Aggregatorとこのサーバが別の場合以下のように-hostオプションを指定してインターフェイスに割り当てたipを指定するとそのネットワークからアクセスできるようになります.

$ ~/usr/local/go/bin/radicast -config=$HOME/usr/local/go/etc/radicast.json -host 192.168.2.203
  :
2016/03/09 07:42:34 [server] start 192.168.2.203:3355

proxy

は使えない感じかな?

$ w3m -dump http://radiko.jp/area
document.write('<span class="JP46">KAGOSHIMA JAPAN</span>');
$ tsocks w3m -dump http://radiko.jp/area
document.write('<span class="JP13">TOKYO JAPAN</span>');
$ ALL_PROXY=socks5h://localhost:8080 ~/usr/local/go/bin/radicast -setup
2016/03/09 07:56:00 [radiko] GET http://radiko.jp/player/swf/player_3.0.0.01.swf
2016/03/09 07:56:01 [radiko] POST https://radiko.jp/v2/api/auth1_fms
2016/03/09 07:56:02 [radiko] POST https://radiko.jp/v2/api/auth2_fms
2016/03/09 07:56:02 [radiko] GET http://radiko.jp/v2/api/program/today?area_id=JP46
{
  "HOUSOU-DAIGAKU": [],
  "MBC": [],
  "RN1": [],
  "RN2": []
}
$ tsocks ~/usr/local/go/bin/radicast -setup
   :
  "MBC": [],
   :
$ tsocks ~/usr/local/go/bin/radicast -setup
   :
  "MBC": [],
   :
$ ALL_PROXY=http://localhost:8080 ~/usr/local/go/bin/radicast -setup
   :
  "MBC": [],
   :

]]>
https://matoken.org/blog/2016/03/09/try-the-automatically-recorded-me-turned-into-further-podcast-by-radicast-the-radiko/feed/ 0
rc-gui最新版のビルドメモ(20160226) https://matoken.org/blog/2016/02/26/rc-gui-latest-version-build-notes/ https://matoken.org/blog/2016/02/26/rc-gui-latest-version-build-notes/#respond Thu, 25 Feb 2016 22:47:37 +0000 http://matoken.org/blog/?p=1222

Rasbian jessieのGUIな設定ツールのrc-guiの言語ファイルの項目が増えているみたいなので試してみました.

Wi-FiのCountry Code辺りが増えてるみたいなんだけど画面上に見当たらないです.
対応デバイス繋がないと出ないのかな?

20160226_00:02:02-20553

訳はこんな感じ?

20160226_01:02:13-6226

とりあえずrc-guiはビルドに必要なパッケージ増えてたのでメモしておきます.
controlには未だ載ってないよう.

$ sudo apt-get build-dep rc-gui
$ git pull
$ ./configure --prefix=/opt/local
   :
configure: error: Package requirements ( gtk+-2.0 >= 2.18.0              libxml-2.0) were not met:
 
No package 'libxml-2.0' found
   :
$ sudo apt install libxml2-dev
$ ./configure --prefix=/opt/local
$ make
$ sudo make install

]]>
https://matoken.org/blog/2016/02/26/rc-gui-latest-version-build-notes/feed/ 0
cronに特化したPodcastアグリゲータ/ダウンローダのpodgetを試す https://matoken.org/blog/2016/02/19/try-podget-of-podcast-aggregator-downloader-that-specializes-in-cron/ https://matoken.org/blog/2016/02/19/try-podget-of-podcast-aggregator-downloader-that-specializes-in-cron/#respond Thu, 18 Feb 2016 23:01:18 +0000 http://matoken.org/blog/?p=1191

先日試したpodracerは何気に10年前のソフトでメンテナンスもされていないし,起動中に強制終了するとゴミが残って次から起動しなくなったりとかとか結構不満点が出てきました.

今は前処理を以下のようにして,

if [ $(pgrep podracer) ] ; then
  echo 'running podracer.'
  exit -1
fi
 
echo run podracer
if [ -f ~/.podracer/tempsub ] ; then
  rm ~/.podracer/tempsub
  echo 'rm tempsub'
fi

プレイリストもこんな感じで別に作ってます.

cd ~/podcasts
PODCASTLIST=($(cd ~/podcasts ; find . -mmin -$LISTTIME -type f -print0 | xargs -0n1 file | grep -i audio | cut -f1 -d:))
if [ ${#PODCASTLIST[@]} -eq 0 ] ; then
  echo 'podcast not found.'
  exit -1;
fi
 
echo num = ${#PODCASTLIST[@]}
ls -1tr ${PODCASTLIST[@]} > ~/podcasts/todayspodcast.m3u

後者はDebianの方にはバグ報告をしていますが音沙汰がない感じです.

他にないかなーと探して(apt-cache search podcast)podgetというものを見つけました.

$ apt show podget | grep -A99 Description:
 
Description: cron 用に最適化された Podcast アグリゲータ/ダウンローダ
 Podget はシンプルな podcast アグリゲータであり、定期的なバックグランドジョブ
 (すなわち cron) として起動するために最適化されています。RSS および XML フィード
 からの podcast のダウンロード、ファイルをソートしてフォルダやカテゴリごとに格納、
 iTunes PCAST ファイルおよび OPML リストからの URL のインポート、M3U および ASX
 プレイリストの自動生成、そして古くなったファイルの自動クリーンアップのサポート
 が特徴です。また、MS Windows サーバ上にホストされた podcast の UTF-16 自動変換も
 特徴です。
 podget を一旦起動すると、ユーザ設定ファイルを $HOME/.podget にインストール
 しますので、そのファイルをカスタマイズできます。

cronに特化していて便利そうなので試してみます.

導入

Debian stretch testing/Rasbian jessie/Ubuntu 14.04 で確認しました.

$ sudo apt install podget

初期化

$ podget -h
 
Usage /usr/bin/podget [options]
 
    -c --config <FILE>           Name of configuration file.
    -C --cleanup                 Skip downloading and only run cleanup loop.
    --cleanup_simulate           Skip downloading and simulate running
                                 cleanup loop.
                                 Display files to be deleted.
    --cleanup_days               Number of days to retain files.  Anything
                                 older will be removed.
    -d --dir_config <DIRECTORY>  Directory that configuration files are
                                 stored in.
    -f --force                   Force download of items from each feed even
                                 if they have already been downloaded.
    --import_opml <FILE or URL>  Import servers from OPML file or
                                 HTTP/FTP URL.
    --import_pcast <FILE or URL> Import servers from iTunes PCAST file or
                                 HTTP/FTP URL.
    -l --library <DIRECTORY>     Directory to store downloaded files in.
    -p --playlist-asx            In addition to the default M3U playlist,
                                 create an ASX Playlist.
    -r --recent <count>          Download only the <count> newest items from
                                 each feed.
    --serverlist <list>          Serverlist to use.
    -s --silent                  Run silently (for cron jobs).
    --verbosity <LEVEL>          Set verbosity level (0-4).
    -v                           Set verbosity to level 1.
    -vv                          Set verbosity to level 2.
    -vvv                         Set verbosity to level 3.
    -vvvv                        Set verbosity to level 4.
    -h --help                    Display help.

初回起動時に設定ファイルなどが作成されます.引数無しで実行すると初期設定の中のpodcastをダウンロードするので--cleanup_simulateオプションを付けて実行すると良さそうです.
設定ファイルは規定値では~/.podget以下に作成されます.

$ podget --cleanup_simulate
$ ls -lA ~/.podget
合計 8
-rw-rw-r-- 1 mk mk 3652  2月 19 05:34 podgetrc
-rw-rw-r-- 1 mk mk 1131  2月 19 05:34 serverlist
  • podgetrc : 設定ファイル
  • serverlist : podcastのリスト

設定ファイルの用意

お好みで設定ファイルの~/podgetrcを編集します.私は以下の辺りを書き換えました.

ログファイルを有効に

# Directory to store logs in
dir_log=/home/mk/POD/LOG

プレイリストの年月日の形式を書き換え

# Date format for new playlist names
date_format=+%Y-%m-%d

Podcastの取得数を3つに

# Most Recent
# 0  == download all new items.
# 1+ == download only the <count> most recent
most_recent=3

サーバリストの作成

取得するPodcastを~/.podget/serverlistに書いていきます.

書式はスペース区切りで

URL カテゴリー 番組名

になっています.podgetを実行した時に
カテゴリー/番組名/番組というふうにディレクトリが掘られます.
具体的にはこんな感じで書いていきます.

http://feeds.feedburner.com/weblogs/csc tech 電脳空間カウボーイズ
http://feeds.backspace.fm/backspacefm tech backspace.fm
http://www.joqr.co.jp/science-podcast/index.xml science 日立ハイテクプレゼンツ 大村正樹のサイエンスキッズ
http://www.tbsradio.jp/life/rss.xml etc 文化系トークラジオ Life
http://www.tbsradio.jp/cycle-r/index.xml bike ミラクル・サイクル・ライフ
http://sokoani.com/feed anime そこあに
  :

他のアプリケーションらの移行でOPMLファイルのエクスポートが可能な場合はそのファイルやURLを元にインポートできるようです.※未確認

$ podget --import_opml <FILE or URL>

若しくはPCAST形式(iTunes向け?)も同様に利用できるようです.※未確認

$ podget --import_pcast <FILE or URL>

OPML書き出しの機能もあります.但しこの機能は
Ubuntu 14.04の0.6.9にはなく,
Rasbian jessieの0.7.3,
Debian stretchの0.7.9には存在しました.

$ podget --export_opml /tmp/podcast.opml
podget
 
Session file not found.  Creating podget.22189 .
 
Export serverlist to OPML file: /tmp/podcast.opml
 
Closing session and removing lock file.
$ head /tmp/podcast.opml
<?xml version="1.0" encoding="utf-8" ?>
<opml version="1.0">
<head/>
<body>
<outline text="tech"><outline text="電脳空間カウボーイズ" type="rss" xmlUrl="http://feeds.feedburner.com/weblogs/csc" /></outline>
<outline text="tech"><outline text="backspace.fm" type="rss" xmlUrl="http://feeds.backspace.fm/backspacefm" /></outline>
<outline text="science"><outline text="日立ハイテクプレゼンツ 大村正樹のサイエンスキッズ" type="rss" xmlUrl="http://www.joqr.co.jp/science-podcast/index.xml" /></outline>
<outline text="etc"><outline text="文化系トークラジオ Life" type="rss" xmlUrl="http://www.tbsradio.jp/life/rss.xml" /></outline>
<outline text="bike"><outline text="ミラクル・サイクル・ライフ" type="rss" xmlUrl="http://www.tbsradio.jp/cycle-r/index.xml" /></outline>
<outline text="anime"><outline text="そこあに" type="rss" xmlUrl="http://sokoani.com/feed" /></outline>

実行

とりあえず引数無しで実行することでPodcastが取得できます.

$ podget
-------------------------------------------------
Category: anime         Name: そこあに
Downloading feed index from http://sokoani.com/feed
2016-02-19 07:37:15 URL:http://sokoani.com/feed [673868] -> "-" [1]
 
Downloading 0_s413.mp3 from http://sokoani.com/podpress_trac/feed/9818/0/
 :
 :

Podcastは規定値では~/POD以下にカテゴリ/番組名/番組ファイルの形で保存されます.

$ find ~/POD -type f | tail -3
/home/mk/POD/etc/JUNK 伊集院光 深夜の馬鹿力/files_20160216.mp3
/home/mk/POD/etc/JUNK 伊集院光 深夜の馬鹿力/files_20160202.mp3
/home/mk/POD/etc/JUNK 伊集院光 深夜の馬鹿力/files_20160209.mp3

また,~/POD/*.m3uとステプレイリストも作成されます.これは実行単位で作られるのかな?

$ ls -l ~/POD/*.m3u
-rw-rw-r-- 1 mk mk  946  2月 19 07:14 /home/mk/POD/New-2016-02-19.m3u
-rw-rw-r-- 1 mk mk 1924  2月 19 07:50 /home/mk/POD/New-2016-02-19.r2.m3u

うまく動作するようなら-sオプションを付けてcronに登録してあげると良さそうです.以下の例では毎時3分にpodgetを実行しています.

$ crontab -e
$ crontab -l | tail -2
# get podcast
3 * * * *       podget -s

podracerはPodcastを番組関係なく実行日のディレクトリに保存されてPodcast番組を探したりするのに不便でしたがpodgetだとカテゴリと番組でディレクトリが分かれるので便利です.
しばらく併用してみようと思います.

]]>
https://matoken.org/blog/2016/02/19/try-podget-of-podcast-aggregator-downloader-that-specializes-in-cron/feed/ 0
configs moduleで/proc/config.gzを呼び出す https://matoken.org/blog/2016/02/05/call-the-procconfig-gz-in-configs-module/ https://matoken.org/blog/2016/02/05/call-the-procconfig-gz-in-configs-module/#respond Fri, 05 Feb 2016 09:09:30 +0000 http://matoken.org/blog/?p=1118 kernel buildしようと現在のconfigをコピーしようとしたところ/boot以下にも/proc/config.gzも見当たらない.こういう場合configsというモジュールを読み込むと/proc/config.gzが出来るらしい.

$ ls -l /proc/config.gz
ls: cannot access /proc/config.gz: No such file or directory
$ ls -la /boot/config-*
ls: cannot access /boot/config-*: No such file or directory
$ sudo modprobe configs
$ lsmod|grep configs
configs                30516  0
$ ls -l /proc/config.gz
-r--r--r-- 1 root root 29305 Feb  4 18:34 /proc/config.gz
$ zcat /proc/config.gz > /usr/src/linux/.config
$ sudo rmmod configs
$ ls -l /proc/config.gz
ls: cannot access /proc/config.gz: No such file or directory

これはRasbina jessieで遭遇しました.
Debian stretch amd64でも試してみたところmoduleがありませんでした.でも普通に/boot/config-x.x.xがあるので困らないです.

$ sudo modprobe configs
modprobe: FATAL: Module configs not found in directory /lib/modules/4.3.0-1-amd64

menuconfigではこの辺みたいです.

General setup
  [*] Kernel .config support
    [*]   Enable access to .config through /proc/config.gz[*]   Enable access to .config through /proc/config.gz
]]>
https://matoken.org/blog/2016/02/05/call-the-procconfig-gz-in-configs-module/feed/ 0
雑なPadcastサーバを少しましにする https://matoken.org/blog/2016/02/04/to-a-little-better-the-sloppy-podcast-server/ https://matoken.org/blog/2016/02/04/to-a-little-better-the-sloppy-podcast-server/#respond Thu, 04 Feb 2016 13:39:54 +0000 http://matoken.org/blog/?p=1116

先日作ったPodcastサーバですがあれからずっと動かしていますが安定して動いているようです.雑さをましにするために少し修正しました.

プレイヤー部分はこんな感じで少し変わりました.

@reboot while true; do cvlc --ignore-config --extraintf=http --http-port=8081 --http-password='raspberry' ~/podcasts/todayspodcast.m3u --play-and-exit --norm-max-level=2.0 --sout='#transcode{acodec=mp3,ab=64,channels=1}:standard{access=http,mux=ts,dst=:8080}' ; done
40 * * * *      podracer ; cd ~/podcasts ; find . -mmin -1440 -type f -print0 | xargs -0n1 file | grep -i audio | cut -f1 -d: | xargs ls -1tr > ~/podcasts/todayspodcast.m3u
10 0 * * *  rm -rf ~/podcasts/`date --date '1 weeks ago' +\%F`
  • killせずに1周毎にVLCを呼ぶようにしてプレイリスト更新
  • Podcast取得を1時間に1度に変更
  • ボリュームのノーマライズ
  • ビットレートを64kにリアルタイムエンコーディング
  • プレイリストの作成も1時間に一度
  • プレイリストの順序を時間順にソート
  • プレイリストの内容はプレイリスト作成時から過去1日分(1440分)
  • 音泉の番組に対応(RSS化してpodracerに登録.簡単だけど公開すると怒られそうな気がする)

VLCのオプション

  • --ignore-config
    設定を読み込みません
  • --extraintf=http
    ウェブコントローラーを有効に
  • --http-port=8081
    ウェブコントローラーの待ち受けポートを8081番に
  • --http-password='raspberry'
    ウェブコントローラーの認証パスワードをraspberry
  • ~/podcasts/todayspodcast.m3u
    再生ファイル(プレイリストを指定)
  • --play-and-exit
    再生後終了する.これがないとプレイリストを再生後も起動しっぱなしになって次の周に入らない.(vlc://quitでも大丈夫だが,vlc://quitだとプレイリストにも表示される)
  • --norm-max-level=2.0
    ボリュームのノーマライズ.この値はもう少しいじったほうがいいかも?
  • --sout='#transcode{acodec=mp3,ab=64,channels=1}
    モノラル64kのmp3に変換している.Podcastを調べると殆どの番組が64kで一部40,96,128,160が混じっている.1日試したが32kでも大丈夫そう.
  • standard{access=http,mux=ts,dst=:8080}
    8080番ポートでHTTPライブストリーミング配信

VLCのオプションはmanにはあまり載ってなくて困っていたのですが,vlc -Hに大量のオプションが載っているのに気づいてからはかどりました.

$ vlc -h| tail -1
網羅的なヘルプを表示するためには、'-H'オプションを指定してください。
$ vlc -h | wc -l
372
$ vlc -H | wc -l
5674

その他細かいところで

  • 設置場所の変更
  • DNSに名前を登録して固定IPに(Androidでも名前でアクセス可能に)
  • 合わせてプレイリスト等のurlを名前に
  • hostnameの変更
  • sshd設定
  • iptable設定
  • OSの自動更新設定
  • watch dogの設定

といった辺りも設定しましたがこの辺は何時もの設定なので今回は省略.

と,こんな感じでだいたいやりたいことは出来たかなーという感じですが,VLCでなくMPD辺りで曲管理して再生,配信はまた別アプリでやったほうがいいような気もしてきました.VLCは1つで何でもできるしウェブコントローラーもあっていいのですが,MPDの方がリモート管理がしやすそうなので気が向いたらそっちも組むかもです.

今100円ショップのイヤホンを使って聞いているのでその部分が一番ストレスな感じです.

]]>
https://matoken.org/blog/2016/02/04/to-a-little-better-the-sloppy-podcast-server/feed/ 0
Raspberry Piの小さな液晶のPiTFTを仮想画面スクロールで広く使いたかったけど挫折 https://matoken.org/blog/2016/02/04/pitft-of-raspberry-pi-could-not-be-used-widely-in-the-virtual-screen-scrolling/ https://matoken.org/blog/2016/02/04/pitft-of-raspberry-pi-could-not-be-used-widely-in-the-virtual-screen-scrolling/#respond Wed, 03 Feb 2016 15:33:41 +0000 http://matoken.org/blog/?p=1111

IMGP2681

Raspberry Pi用でAdaruit製のGPIO経由(SPI)で接続する320×240 2.8"のタッチスクリーン付きのディスプレイ.動作には専用のドライバが必要.ドライバはsourceの他にAdaruitがRasbianに組み込み済みのものと,ビルド済みのリポジトリが用意されている.

Afafruit謹製のOSイメージ入手

通常のRasbianにAdafruitのリポジトリを追加する方法と,それを反映済みのOSイメージを使う方法(と自分でbuildする方法)がある.ここでは手順の少ないAfafruit謹製のOSイメージを利用する.こちらからwheesy/jessieのものが入手可能.

今回はjessie(2015-09-24-raspbian-jessie-pitft28r.zip)を利用.hashや署名は見当たらず.手元ではこんな感じだった.

$ md5sum 2015-09-24-raspbian-jessie-pitft28r.zip
e78c764abbd3426d63d9ae7180fcdfa8  2015-09-24-raspbian-jessie-pitft28r.zip
$ sha512sum 2015-09-24-raspbian-jessie-pitft28r.zip
a6be01345be6030aaf0bc85293a946be4db54e80a42dbbab0034ddff3c21e842fc10f7f066acd605ffd9d16b6d43e14631e7d5a969a7f2a0869d7d00f013d8fd  2015-09-24-raspbian-jessie-pitft28r.zip

SD Cardデバイス確認

$ dmesg | tail -3
[793679.349596] mmc0: new high speed SDHC card at address 59b4
[793679.350315] mmcblk0: mmc0:59b4 USDU1 14.9 GiB
[793679.351411]  mmcblk0: p1 p2 p3
$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 15 GiB, 16088301568 bytes, 31422464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb3c5e39a
 
Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1          8192   131071   122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        131072 27228158 27097087 12.9G 83 Linux
/dev/mmcblk0p3      27228159 31422463  4194305    2G 83 Linux
$ mount|grep /dev/mmcblk0

パーティション情報の確認と消去

$ sudo wipefs /dev/mmcblk0
offset               type
----------------------------------------------------------------
0x1fe                dos   [partition table]
 
$ sudo wipefs -a /dev/mmcblk0
/dev/mmcblk0: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/mmcblk0: calling ioctl to re-read partition table: 成功です
$ sudo wipefs /dev/mmcblk0

※Mac/Windowsではこの辺を使うといいと思う.

イメージ書き込み

$ unzip -p 2015-09-24-raspbian-jessie-pitft28r.zip | pv | sudo ionice -c2 dd of=/dev/mmcblk0 bs=4M
4.03GiB 0:05:58 [11.5MiB/s] [                                                                                                              <=>                         ]
0+36176 レコード入力
0+36176 レコード出力
4325376000 バイト (4.3 GB) コピーされました、 452.676 秒、 9.6 MB/秒
$ sync
$ sync
$ mount|grep /dev/mmcblk0

コマンドの意味などはこちらを

書き込んだSD CardをPiTFTの繋がったRaspberry Piに挿入して起動するとXが自動起動してLXDEにpiユーザで自動ログインした状態になる.

リモート接続(ssh)

Rasbian jessieは初期状態でavahi&sshが起動しているのでIPアドレスを調べなくても接続できて便利.

$ ssh pi@raspberrypi.local -CY

リモート接続(vnc)

x11vncを使ってvinoみたいに既に起動しているX画面(DISPLAY=:0)を転送

$ sudo apt install x11vnc
$ x11vnc -display :0 &

リポジトリサーバの日本への切り替えとパッケージのアップデート

$ sudo apt edit-sources
$ cat /etc/apt/sources.list
deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/  jessie main contrib non-free rpi
deb-src http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/  jessie main contrib non-free rpi
deb http://apt.adafruit.com/raspbian/ jessie main
$ sudo apt update && sudo apt upgrade

Xの確認

$ ps -ef|grep X
root       557   550  0 05:50 tty7     00:00:01 /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
pi         733   698  0 05:50 ?        00:00:00 /usr/bin/lxsession -s LXDE-pi -e LXDE
pi         837   733  1 05:51 ?        00:00:02 lxpanel --profile LXDE-pi
pi         838   733  0 05:51 ?        00:00:01 pcmanfm --desktop --profile LXDE-pi
pi         968   942  0 05:55 pts/0    00:00:00 grep --color=auto X
$ DISPLAY=:0 xrandr --verbose
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 240, current 320 x 240, maximum 320 x 240
default connected 320x240+0+0 (0x4f) normal (normal) 0mm x 0mm
        Identifier: 0x4e
        Timestamp:  35831
        Subpixel:   unknown
        Clones:
        CRTC:       0
        CRTCs:      0
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter:
  320x240 (0x4f)  0.000MHz *current
        h: width   320 start    0 end    0 total  320 skew    0 clock   0.00KHz
        v: height  240 start    0 end    0 total  240           clock   0.00Hz
$ ls -l /dev/fb*
crw-rw---- 1 root video 29, 0 Sep 24 17:32 /dev/fb0
crw-rw---- 1 root video 29, 1 Feb  3 05:52 /dev/fb1

PiTFT分のXだけが起動していて,ディスプレイ番号は:0のよう.解像度は320x240だけ.モニタ名はdefault?

XRandRのpanningを使って画面をスクロールして広く使う(失敗)

やっと本題.
xrandrのmanを見るとpanningというそれらしい設定が.

       Per-output options
 
       --panning widthxheight[+x+y[/track_widthxtrack_height+track_x+track_y[/border_left/border_top/border_right/border_bottom]]]
              This option sets the panning parameters.  As soon as panning is enabled, the CRTC position can change with every pointer move.  The first four param‐
              eters specify the total panning area, the next four the pointer tracking area (which defaults to the same area). The last four parameters specify the
              border and default to 0. A width or height set to zero disables panning on the according axis. You typically have to set the screen  size  with  --fb
              simultaneously.
 
       --transform a,b,c,d,e,f,g,h,i
              Specifies a transformation matrix to apply on the output. Automatically a bilinear filter is selected.  The mathematical form corresponds to:
                     a b c
                     d e f
                     g h i
              The transformation is based on homogeneous coordinates. The matrix multiplied by the coordinate vector of a pixel of the output gives the transformed
              coordinate vector of a pixel in the graphic buffer.  More precisely, the vector (x y) of the output pixel is extended to 3 values (x y w), with 1  as
              the  w coordinate and multiplied against the matrix. The final device coordinates of the pixel are then calculated with the so-called homogenic divi‐
              sion by the transformed w coordinate.  In other words, the device coordinates (x' y') of the transformed pixel are:
                     x' = (ax + by + c) / w'   and
                     y' = (dx + ey + f) / w'   ,
                     with  w' = (gx + hy + i)  .
              Typically, a and e corresponds to the scaling on the X and Y axes, c and f corresponds to the translation on those axes, and g, h, and i are  respec‐
              tively  0,  0 and 1. The matrix can also be used to express more complex transformations such as keystone correction, or rotation.  For a rotation of
              an angle T, this formula can be used:
                     cos T  -sin T   0
                     sin T   cos T   0
                      0       0      1
              As a special argument, instead of passing a matrix, one can pass the string none, in which case the default values are used (a  unit  matrix  without
              filter).
 
       --scale xxy
              Changes  the  dimensions  of the output picture. Values superior to 1 will lead to a compressed screen (screen dimension bigger than the dimension of
              the output mode), and values below 1 leads to a zoom in on the output. This option is actually a shortcut version of the --transform option.
 
       --scale-from wxh
              Specifies the size in pixels of the area of the framebuffer to be displayed on this output.  This option  is  actually  a  shortcut  version  of  the
              --transform option.
 
       --primary
              Set the output as primary.  It will be sorted first in Xinerama and RANDR geometry requests.

ちょっと複雑そう.xrandrのGUIの皮のarandr/lxrandrで設定できると便利なんだろうけど実装された機能が少なくてこの当たりの設定は使えない感じで残念.
#arandrは外部モニタの設定や解像度の変更にはよく使ってます.

XRandRを手動で設定してmodeの登録を試みる

cvtコマンドで取得した値をxrandrに渡すといいはずだけどうまく行かない.

$ cvt 800 600
# 800x600 59.86 Hz (CVT 0.48M3) hsync: 37.35 kHz; pclk: 38.25 MHz
Modeline "800x600_60.00"   38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
$ xrandr --newmode "800x600_60.00"   38.25  800 832 912 1024  600 603 607 624 -hsync +vsync
$ xrandr --addmode default 800x600_60.00
xrandr: cannot find output "default"
$ DISPLAY=:0 xrandr --addmode default 800x600_60.00
xrandr: Failed to get size of gamma for output default
xrandr: cannot find mode "800x600_60.00"
$ DISPLAY=:0 xrandr --addmode default 800x600_60.00
xrandr: Failed to get size of gamma for output default
xrandr: cannot find mode "800x600_60.00"

PC(i915なDebian stretch amd64)では想定した動作になった.
この例では存在するモードよりも広い1904×720のモードを追加した後,画面のモードを640×480にして仮想スクリーンを1904×720にしている.マウスカーソルを端に持って行くと自動スクロールする.

$ xrandr | grep LVDS1 -A5
LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 277mm x 156mm panning 1366x768+0+0
   1366x768      60.00*+
   1360x768      59.80    59.96  
   1024x768      60.00  
   800x600       60.32    56.25  
   640x480       59.94  
$ cvt 1904 720
# 1904x720 59.97 Hz (CVT) hsync: 44.86 kHz; pclk: 111.25 MHz
Modeline "1904x720_60.00"  111.25  1904 2000 2192 2480  720 723 733 748 -hsync +vsync
$ cvt 1904 720
# 1904x720 59.97 Hz (CVT) hsync: 44.86 kHz; pclk: 111.25 MHz
Modeline "1904x720_60.00"  111.25  1904 2000 2192 2480  720 723 733 748 -hsync +vsync
$ xrandr --newmode "1904x720_60.00"  111.25  1904 2000 2192 2480  720 723 733 748 -hsync +vsync
$ xrandr --addmode VGA1 1904x720_60.00
$ xrandr --output LVDS1 --mode 640x480 --panning 1904x720

そもそもpanningはmodeを追加しなくても使えるようだ.

$ xrandr --output LVDS1 --mode 1366x768 --panning 2000x768
$ xrandr --output LVDS1 --mode 1366x768 --panning 2732x1536 --scale 2x2

ということはこれだけでいいはずだけどモニタ名がうまく行けてない.モニタ名をドライバでちゃんと設定してない?

$ DISPLAY=:0 xrandr default --mode 320x240 --panning 800x600
xrandr: unrecognized option 'default'
Try 'xrandr --help' for more information.$ DISPLAY=:0 xrandr default --mode 320x240 --panning 800x600
xrandr: unrecognized option 'default'
Try 'xrandr --help' for more information.

Adafruitのフォーラムに同じ質問があったけど動いて無さそう.

もう少し叩いてみたらモニタ名はdefaultでOKのよう.320×240より小さなmodeを作ってみてもダメ.
xrandrコマンドを引数無しで実行した時のmaximum 320 x 240がいけないのかも.PCではmaximum 32767 x 32767と恐らくビデオカードの最大解像度であろう値が表示される.VRAMを増やしたりすると行けるけるのかもしれない.

$ DISPLAY=:0 xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 240, current 320 x 240, maximum 320 x 240
default connected 320x240+0+0 0mm x 0mm
   320x240        0.00*
$ DISPLAY=:0 xrandr --output default --auto --mode 320x240 --panning 800x600
xrandr: Failed to get size of gamma for output default
xrandr: screen cannot be larger than 320x240 (desired size 800x600)
$ DISPLAY=:0 xrandr --output default --auto --mode 160x120 --panning 320x240
xrandr: cannot find mode 160x120
$ cvt 160 120
# 160x120 50.08 Hz (CVT 0.02M3) hsync: 6.51 kHz; pclk: 1.25 MHz
Modeline "160x120_60.00"    1.25  160 168 176 192  120 123 127 130 -hsync +vsync
$ xrandr --newmode "160x120_60.00"    1.25  160 168 176 192  120 123 127 130 -hsync +vsync
$ DISPLAY=:0 xrandr --newmode "160x120_60.00"    1.25  160 168 176 192  120 123 127 130 -hsync +vsync
xrandr: Failed to get size of gamma for output default
$ DISPLAY=:0 xrandr --addmode default 160x120_60.00
xrandr: Failed to get size of gamma for output default
$ DISPLAY=:0 xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 240, current 320 x 240, maximum 320 x 240
default connected 320x240+0+0 0mm x 0mm
   320x240        0.00*
   160x120_60.00  50.08  
pi@raspberrypi ~ $ DISPLAY=:0 xrandr --output default --auto --mode 160x120_60.00 --panning 320x240
xrandr: Failed to get size of gamma for output default
xrandr: Configure crtc 0 failed

恐らくこれ以上はsourceを修正しないとダメだと思う.

fbcpを利用してRaspberry Pi標準のディスプレイをコピーして利用

フレームバッファをコピーするfbcpを利用する方法.便利だけどタッチパネル機能が使えない.

内蔵が/dev/fb0でPiTFTが/dev/fb1になっているので通常のRaspberry Piで行った設定をそのままPiTFTの画面に映すことが出来る.
フレームバッファのコピーなのでXだけでなくコンソール利用時にも使える.

fbcpのbuild

$ sudo apt install cmake
$ git clone https://github.com/tasanakorn/rpi-fbcp.git
$ cd rpi-fbcp
$ mkdir build
$ cd build
$ cmake ..
$ make

fbcpコマンドを適当な場所に置く.

$ sudo cp fbcp /usr/local/bin/

/dev/fb1を指定しているファイルを退避して,起動時にfbcpを起動するよう設定して再起動.

$ sudo mv /etc/X11/xorg.conf.d/99-fbdev.conf ~pi/99-fbdev.conf
$ sudo sed -i 's/exit/\/usr\/local\/bin\/fbcp \&\n\nexit/g' /etc/rc.local
$ sudo reboot

コンソールの途中からfbcpが動作してXも表示される.解像度は656×416になっている.もっと高解像度にもできるが使いやすさを考えるとこのくらいでいいと思う.

$ DISPLAY=:0 xrandr --verbose
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 656 x 416, current 656 x 416, maximum 656 x 416
default connected 656x416+0+0 (0x4f) normal (normal) 0mm x 0mm
        Identifier: 0x4e
        Timestamp:  19289
        Subpixel:   unknown
        Clones:    
        CRTC:       0
        CRTCs:      0
        Transform:  1.000000 0.000000 0.000000
                    0.000000 1.000000 0.000000
                    0.000000 0.000000 1.000000
                   filter:
  656x416 (0x4f)  0.000MHz *current
        h: width   656 start    0 end    0 total  656 skew    0 clock   0.00KHz
        v: height  416 start    0 end    0 total  416           clock   0.00Hz

過去の試み

]]>
https://matoken.org/blog/2016/02/04/pitft-of-raspberry-pi-could-not-be-used-widely-in-the-virtual-screen-scrolling/feed/ 0
aptコマンドのedit-sourcesオプションが便利 https://matoken.org/blog/2016/02/01/convenient-edit-sources-option-of-apt-command/ https://matoken.org/blog/2016/02/01/convenient-edit-sources-option-of-apt-command/#comments Mon, 01 Feb 2016 10:25:20 +0000 http://matoken.org/blog/?p=1102

Rasbianのパッケージサーバにjaistを指定していたのだけど最近遅いのでmirror listを見て

$ w3m -dump https://www.raspbian.org/RaspbianMirrors|grep -i japan -A1
Asia^*    Japan       JAIST                    (http|rsync)://ftp.jaist.ac.jp/pub/
                                               Linux/raspbian-archive/raspbian
--
Asia^*    Japan       WIDE Project Tsukuba NOC raspbian/raspbian/
                                               rsync://ftp.tsukuba.wide.ad.jp/
--
Asia^*    Japan       Yamagata University      http://ftp.yz.yamagata-u.ac.jp/pub/
                                               linux/raspbian/raspbian/

/etc/apt/sources.listをWIDEに変更した.

-deb http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian/ jessie main contrib non-free rpi
-deb-src http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian/ jessie main contrib non-free rpi
+deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/  jessie main contrib non-free rpi
+deb-src http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/  jessie main contrib non-free rpi

ところでaptコマンドのedit-sourcesオプションが便利なのでぜひ使うべき.visudoとかみたいに間違えると教えてくれる.

$ sudo apt edit-sources
E: Type 'eb' is not known on line 3 in source list /etc/apt/sources.list
Failed to parse /etc/apt/sources.list. Edit again?  [Y/n]

引数を付けて/etc/apt/sources.list.d/以下の編集も出来る

$ ls /etc/apt/sources.list.d/
google-chrome.list  gyazo_gyazo-for-linux.list  owncloud-client.list
$ sudo apt edit-sources owncloud-client

Debian jessie以降,Rasbian jessie以降,Ubuntu vivid(15.04)以降でそれぞれ利用可能だと思う.

apt (0.9.13.1) unstable; urgency=low
 
  [ Colin Watson ]
  * fix "apt-get  --purge build-dep" (closes: #720597)
  * fix regression that APT::Keep-Fds is not honored (closes: #730490)
 
  [ Michael Vogt ]
  * add "-f" option to "build-dep" as sbuild is using it to fix
    regression with cross-building (LP: #1255806)
  * add autopkgtest support for the integration testsuite
  * merge mvo/feature/short-list
  * merge mvo/feature/edit-sources
  * fix segfault in pkgDepCache::SetCandidateRelease() (closes: #709560)
  * reset terminal on error (closes: #730795)
  * fix apport report writing (LP: #1254499)
 
 -- Michael Vogt <mvo@debian.org>  Fri, 29 Nov 2013 20:50:17 +0100


]]>
https://matoken.org/blog/2016/02/01/convenient-edit-sources-option-of-apt-command/feed/ 1
Raspberry Piで雑いpodcastサーバを作った https://matoken.org/blog/2016/01/31/i-made-a-sloppy-podcast-server-in-the-raspberry-pi/ https://matoken.org/blog/2016/01/31/i-made-a-sloppy-podcast-server-in-the-raspberry-pi/#comments Sun, 31 Jan 2016 12:14:42 +0000 http://matoken.org/blog/?p=1092

IMGP2678

先日試したpodracer

毎日実行して今日の分をまとめて再生して消してというように使う感じなのかもしれません.

ということで自動取得,自動再生すると家庭内ラジオのようにできるのではと思い試してみました.

環境はRaspberry Pi 1B (512MB)Rasbian jessieを導入したもので有線LAN 利用です.

導入パッケージ

podcast の取得のためにpodracer,プレイリストの配信にboaを利用,音声配信の為にvlc-noxを導入しました.

$ sudo apt install podracer boa vlc-nox

podcast 取得の準備

を参考にpodracerの設定をして下さい.~/.podracer/subscriptionsを用意した後1度catchup modeで実行しておきます.

$ podracer -c

これでRSS Feedをひと舐めして過去のpodcastを取得しないようにします.

VLC での配信テスト

以下の例ではpodracerで作成された今日のプレイリストをそのままhttp 8080ポートで配信して更にloopさせています.

$ cvlc  ~/podcasts/`date +\%F`/`date +\%F`-podcasts.m3u --sout '#standard{access=http,mux=ts,dst=:8080}' --loop

この状態で再生したい端末で $ cvlc http://raspberrypi.local:8080/ とか mplayer http://raspberrypi.local:8080/ などとしてアクセスすると再生されるはずです.
1曲毎に停まってしまい再度再生し直す必要がありますがこれは後で解決することにします.

VLC の設定

VLCで配信しますが,コントローラーも利用したいです.--extraintf=http オプションでwebコントローラーが利用できます.規定値では localhost 以外からアクセスできないので家のネットワークのどこからでもコントロールできるように /usr/share/vlc/lua/http/.hosts に利用可能なネットワークを登録しておきます.

192.168.1.0/24
192.168.2.0/24

以下のように実行するとwebコントローラーが8081ポートで起動します.パスワードは raspberry です.適当なブラウザで http://:raspberry@raspberrypi.local:8081/ な感じでアクセスするとコントローラが利用できると思います.

$ cvlc --extraintf=http --http-port=8081 --http-password='raspberry' ~/podcasts/`date +\%F`/`date +\%F`-podcasts.m3u --sout '#standard{access=http,mux=ts,dst=:8080}' --loop

Screenshot_2016-01-31-19-04-03

パスワードを設定しないとパスワードの設定を促す画面が表示されて利用できないようです.

http の設定(プレイリストの作成)

boaの標準では /var/www 以下がDocumentRootになっています.ここにメニュー用の index.html とプレイリストの podcast.m3u を用意しておきます.

権限は www-data.www-data なので,以下のような感じで権限を設定して編集するといいかもしれません.

$ sudo chown www-data.www-data /var/www
$ sudo -u www-data vi /var/www/index.html
   :
  • /var/www/index.html の例
<html>
<body>
<ul>
<li><a href="./podcast.m3u">m3u</a></li>
<li><a href="http://:raspberry@192.168.2.200:8081/">VLC control</a></li>
</ul>
</body>
</html>

※AndroidではAvahiでの名前解決がうまく行かないのでIP アドレスで書いています.環境に合わせて変更して下さい.

  • /var/www/podcast.m3u の例
http://192.168.2.200:8080/
http://192.168.2.200/podcast.m3u

1行目だけだと1番組分で再生が停止してしまうので,2行目で自分自身を呼び出して再起しています.これで2番組以降でも続けて再生されます.
※AndroidではAvahiでの名前解決がうまく行かないのでip アドレスで書いています.環境に合わせて変更して下さい.

自動起動とpodcast更新処理

crontab で起動時に自動的に再生が始まるように&定期的にpodcast更新&再生リスト更新&古いpodcastの削除処理をします.

crontab -e コマンドで編集します.

@reboot cvlc --extraintf=http --http-port=8081 --http-password='raspberry' ~/podcasts/`date +\%F`/`date +\%F`-podcasts.m3u --sout '#standard{access=http,mux=ts,dst=:8080}' --loop
3 */6 * * *     podracer;killall vlc;cvlc --extraintf=http --http-port=8081 --http-password='raspberry' ~/podcasts/`date +\%F`/`date +\%F`-podcasts.m3u --sout '#standard{access=http,mux=ts,dst=:8080}' --loop
10 0 * * *  rm -rf ~/podcasts/`date --date '1 weeks ago' +\%F`

1行目は @reboot で起動時にVLCを自動起動します.
2行目は6時間毎にpodcastを更新してVLCを起動しなおしています.
3行目で1週間前のpodcastデータを削除しています.

利用方法

ウェブブラウザで Raspberry Pi にアクセスします.

http://raspberrypi.local

以下のようなメニューが出て来ます.

Screenshot_2016-01-31-20-49-47

• m3u
• VLC control

m3u をクリックするとプレイリストがダウンロードされます.VLC 等の関連付けられたアプリケーションなどで再生できると思います.
Screenshot_2016-01-31-19-03-53

VLC control をクリックするとVLCのウェブコントローラーが表示されます.URLに認証情報を埋め込んでいるので認証はスキップされます.

問題点や改善点など

  • ブロードキャスト配信の断念. はじめブロードキャスト配信を試したのですが,かなりの頻度でパケットロスしてそのたびに音が途切れました.音が途切れるのはかなりストレスなので諦めました.プレイリストがなくても連続再生可能なのは良かったのですが…….
  • podcast更新時の番組強制終了.更新時にVLCをkillしています.番組の途中で切れてしまうので改善したいです.
  • podcast の音量や音質を揃える.試しにmp3/128kbpsや64kbpsにリアルタイムエンコーディングしつつ配信も試してみましたが Raspberry Pi でもCPU 25%前後なので実用的な感じです.
    帯域を絞ったストリームも同時配信するようにして外で聴きやすくするのもありかもしれません.
  • VLC から他のアプリケーションに変更.今回お手軽なので VLC を利用しましたが Gstreamer や ffmpeg などを試すのもありかもしれません.
  • スピーカーでも再生.環境によっては同時にスピーカーで再生してもいいかもしれません.
  • 番組情報の配信.今は未知のアーティストなどと表示される.アートワークも含めて改善したい.
    Screenshot_2016-01-31-20-50-06
  • 更新間隔の調整.ニュース番組など定時のある番組があるのでそれらに合わせて更新処理を行うようにすると便利かもしれません.
  • 名前解決.AndroidでAvahiが利用できないので家の中のDNSサーバに名前を登録してあげると便利かもしれません.
  • pifmを使ってFMラジオでも視聴.日本だと電波法違反になるので自重しました.


現在は主にAndroidアプリのVLCで再生しています.AndroidとPCはBluetooth A2DPで繋がっていて,PCで聞いています.PCから離れるときはAndroidにイヤホンジャックを差し替えるとシームレスに移動できます.

20160201_01:02:04-5807

]]>
https://matoken.org/blog/2016/01/31/i-made-a-sloppy-podcast-server-in-the-raspberry-pi/feed/ 1
Rasbian jessie で watchdog を設定する https://matoken.org/blog/2016/01/30/setting-the-watchdog-in-raspbian-jessie/ https://matoken.org/blog/2016/01/30/setting-the-watchdog-in-raspbian-jessie/#respond Sat, 30 Jan 2016 12:38:55 +0000 http://matoken.org/blog/?p=1090

Rasbian jessie 環境でも設定したのでメモとして.

パッケージの導入

$ sudo apt install watchdog

設定ファイル修正

/etc/watchdog.conf を以下のように編集

-#min-memory              = 1
+min-memory              = 5000
 
-#watchdog-device       = /dev/watchdog
+watchdog-device        = /dev/watchdog

min-memory はページサイズ.今回は4096*5000で約20MB.このサイズ(swapを含めた容量)を切ったら再起動するはず.大きいような気もするけどまずは動作確認のためにこのくらいにしてみる.

/etc/default/watchdog を以下のような感じに編集して bcm2708_wdog モジュールを読みこむようにする.

-watchdog_module="none"
+watchdog_module="bcm2708_wdog"

起動設定

$ sudo update-rc.d watchdog defaults
$ sudo update-rc.d watchdog enable

動作確認

再起動して

$ sudo reboot

モジュールの読み込み,デバイスの確認,デーモンの確認をする.

$ lsmod|grep dog
bcm2708_wdog            3926  1
$ ls -l /dev/watchdog
crw------- 1 root root 10, 130  1月 26 23:32 /dev/watchdog
$ ps -ef|grep dog
root       642     1  0 23:32 ?        00:00:00 /usr/sbin/watchdog

問題無さそうなら swap を無効にしてファイルシステムを read only や sync を有効にしておいてから Forkbomb で動作確認をしてみる.以下の例ではbashでのForkbomb

$ sudo swapoff -a
$ sync
$ sudo mount -o remount,ro /boot
$ sudo mount -o remount,sync /
$ :(){ :|:& };:

うまく再起動が走ったら後は /etc/watchdog.conf を詰めていく.

kernel panic 時の設定

bcm2708_wdog を使っているのでkernel panic 時にも watchdog は効くはずだけど念の為設定しておく.

/etc/sysctl.conf に以下を追記

kernel.panic = 180
kernel.panic_on_oops = 1

sysctl や再起動で反映.

$ sudo sysctl -p
kernel.panic = 60
kernel.panic_on_oops = 1

]]>
https://matoken.org/blog/2016/01/30/setting-the-watchdog-in-raspbian-jessie/feed/ 0
awk 製 3Dシューティングゲーム awkaster で遊んでみた https://matoken.org/blog/2016/01/18/i-tried-playing-around-with-awk-made-3d-shooter-game-awkaster/ https://matoken.org/blog/2016/01/18/i-tried-playing-around-with-awk-made-3d-shooter-game-awkaster/#comments Mon, 18 Jan 2016 11:19:36 +0000 http://matoken.org/blog/?p=1071 awk 製 3Dシューティングゲームがあると聞いて遊んでみました.

遊ぶには GNU awk 4.0.0 以上が必要です.Debian だと gawk というパッケージです.とりあえず遊んでみるにはこんな感じで.

$ sudo apt install gawk
$ wget https://raw.githubusercontent.com/TheMozg/awk-raycaster/master/awkaster.awk
$ awk -f ./awkaster.awk

操作はこんな感じです.

  • 1234 画面表示切り替え
  • WASD 移動
  • JL 回転(16回で1回転)/Shiftを押しながらで高速回転(8回で1回転)
  • SPACE 攻撃
  • X エレベーターに乗る(ゲームクリア)
  • Q 終了

以下は遊んでいる様子です.

asciicast

3Dシューティングというとスターフォックスを思い浮かべたのですが,単純な 3D RPG 的な感じです.Wolfenstein 3D と doom に触発されたそうです.Wolfenstein 3DWolfenstein 3D は知らないのですが確かに doom みたいな感じです.
ターン制?なので敵の赤球が出てきても慌てず操作できます.

敵に触れるとHPが減っていって0になるとゲームオーバーでこんなメッセージが出ます.

GAME OVER! YOU LOSE!
Credits: Fedor 'TheMozg' Kalugin
https://github.com/TheMozg/awk-raycaster
Gameplay testing - Alex 'Yakojo' & Danya 'bogych97'
Go away!

うまいことエレベーターに到着して X を押すとゲームクリアです.
但し ELEVATOR COMING0 になっている必要があります.これは初め 1000 で1操作で1カウントダウンされます.ゴールのエレベーターの場所は見た目わかりません
敵が沢山居るところの辺りにあるので探してみて下さい.
(私は判んなくて結局 source 読んでクリアしましたorz)

YOU WIN! YOUR SCORE: 4900
Credits: Fedor 'TheMozg' Kalugin
https://github.com/TheMozg/awk-raycaster
Gameplay testing - Alex 'Yakojo' & Danya 'bogych97'
Go away!

ちなみにそこそこ広い領域が必要です.領域が狭いと画面に収まりきらずずれてしまいます.フォントサイズを小さくするなどして列と行を確保しましょう.
GNU screen 上でも Rasbian jessie 上でも問題なく動きました.

昔こんな3D迷路とかをポケコンBASIC で作っていたのを思い出しました.最近のマイコンやRaspberry Pi でこういうゲームを作ってみるのも楽しそうですね :)
(Arduboy とか POCKETC.H.I.P. とか )

]]>
https://matoken.org/blog/2016/01/18/i-tried-playing-around-with-awk-made-3d-shooter-game-awkaster/feed/ 3