RaspberryPiにLibCEC(cec-client)をインストールする手順

シェアする

  • このエントリーをはてなブックマークに追加
  • Evernoteに保存Evernoteに保存

RasPi3でテレビのCEC制御をするためにLibCECを入れる

RaspberryPi3(ModelB)にモニタとしてHDMI経由でテレビをつなげているのですが、RasPi側からテレビの電源を管理したかったので、Raspbian8(Jessie)へLibCECをインストールする手順です。

sudo apt-get update
sudo apt-get install cmake libudev-dev libxrandr-dev python-dev swig
cd
git clone https://github.com/Pulse-Eight/platform.git
mkdir platform/build
cd platform/build
cmake ..
make
sudo make install
cd
git clone https://github.com/Pulse-Eight/libcec.git
mkdir libcec/build
cd libcec/build
cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..
make -j4
sudo make install
sudo ldconfig

参考元: 本家Pulse-Eight様のGitHub上にあるlibcecのREADME

所感

うちのラズパイは基本的にサーバー用途であるため、テレビの電源をつけっぱなしにするのも電気代がもったいないし、かといって再起動時にちゃんと動いているか確認するたびに電源を入れるのも面倒ということで、HDMIの信号を切ることは`tvservice`コマンドでは出来たものの、テレビの電源そのものをオン・オフをしたくてラズパイ向けの`LibSec`のインストール手順を探していました。

しかし、いささか古い情報ばかりで上記のように`platform`の導入の案内を記載した記事がなく、うまくインストールできなかったのですが、そもそも本家のライブラリ内のドキュメントに明記されていたという、なんともマニュアル読まないちゃんなのでした。

無事インストールできたものの、なんかうまく動かない。

対応メーカーの一覧を見てもシャープは電源のオンオフは対応しているのになぁと半分諦めていたら、「ケーブルを疑え」というフォーラムの記事を発見。動いた。ラズパイ用だからと安いケーブルを使っていたのですが、ここでも「ケーブルあるある」な事をやってしまって、最近初心を忘れているなと感じます。


記録・参考用ログ

pi@raspberrypi:~ $ cec-client -l
libCEC version: 4.0.1, git revision: libcec-4.0.1+2-00ee987, compiled on 2017年  1月 14日 土曜日 01:31:11 UTC by pi@raspberrypi on Linux 4.4.38-v7+ (armv7l), features: P8_USB, DRM, P8_detect, randr, RPi
Found devices: 1

device:              1
com port:            RPI
vendor id:           2708
product id:          1001
firmware version:    1
type:                Raspberry Pi

pi@raspberrypi:~ $ echo "standby 0"|cec-client -s
opening a connection to the CEC adapter...
DEBUG:   [              60]     Broadcast (F): osd name set to 'Broadcast'
DEBUG:   [              61]     Open - vc_cec initialised
DEBUG:   [              61]     logical address changed to Free use (e)
NOTICE:  [              62]     connection opened
DEBUG:   [              62]     processor thread started
DEBUG:   [              62]     << Broadcast (F) -> TV (0): POLL
DEBUG:   [              62]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [              62]     << e0
DEBUG:   [             154]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [             154]     << e0
DEBUG:   [             244]     >> POLL not sent
DEBUG:   [             244]     TV (0): device status changed into 'not present'
NOTICE:  [             244]     registering new CEC client - v4.0.1
DEBUG:   [             244]     detecting logical address for type 'recording device'
DEBUG:   [             244]     trying logical address 'Recorder 1'
DEBUG:   [             244]     << Recorder 1 (1) -> Recorder 1 (1): POLL
TRAFFIC: [             244]     << 11
TRAFFIC: [             515]     << 11
DEBUG:   [             785]     >> POLL not sent
DEBUG:   [             785]     using logical address 'Recorder 1'
DEBUG:   [             785]     Recorder 1 (1): device status changed into 'handled by libCEC'
DEBUG:   [             785]     Recorder 1 (1): power status changed from 'unknown' to 'on'
DEBUG:   [             785]     Recorder 1 (1): vendor = Pulse Eight (001582)
DEBUG:   [             785]     Recorder 1 (1): CEC version 1.4
DEBUG:   [             785]     AllocateLogicalAddresses - device '0', type 'recording device', LA '1'
DEBUG:   [             786]     logical address changed to Recorder 1 (1)
DEBUG:   [             786]     Recorder 1 (1): osd name set to 'CECTester'
DEBUG:   [             786]     Recorder 1 (1): menu language set to 'eng'
DEBUG:   [             786]     GetPhysicalAddress - physical address = 1000
DEBUG:   [             786]     AutodetectPhysicalAddress - autodetected physical address '1000'
DEBUG:   [             787]     Recorder 1 (1): physical address changed from ffff to 1000
DEBUG:   [             787]     << Recorder 1 (1) -> broadcast (F): physical address 1000
TRAFFIC: [             787]     << 1f:84:10:00:01
NOTICE:  [             937]     CEC client registered: libCEC version = 4.0.1, client version = 4.0.1, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, git revision: libcec-4.0.1+2-00ee987, compiled on 2017年  1月 14日 土曜日 01:31:11 UTC by pi@raspberrypi on Linux 4.4.38-v7+ (armv7l), features: P8_USB, DRM, P8_detect, randr, RPi
DEBUG:   [             937]     << Recorder 1 (1) -> TV (0): OSD name 'CECTester'
DEBUG:   [             937]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [             938]     << 10
TRAFFIC: [            1028]     << 10
DEBUG:   [            1118]     >> POLL not sent
DEBUG:   [            1119]     not sending command 'set osd name': destination device 'TV' marked as not present
DEBUG:   [            1119]     << requesting power status of 'TV' (0)
DEBUG:   [            1119]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [            1119]     << 10
TRAFFIC: [            1209]     << 10
DEBUG:   [            1300]     >> POLL not sent
DEBUG:   [            1300]     not sending command 'give device power status': destination device 'TV' marked as not present
DEBUG:   [            1300]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [            1300]     << 10
TRAFFIC: [            1391]     << 10
DEBUG:   [            1481]     >> POLL not sent
NOTICE:  [            1481]     << putting 'TV' (0) in standby mode
DEBUG:   [            1481]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [            1481]     << 10
TRAFFIC: [            1571]     << 10
DEBUG:   [            1662]     >> POLL not sent
DEBUG:   [            1662]     not sending command 'standby': destination device 'TV' marked as not present
DEBUG:   [            1662]     unregistering all CEC clients
NOTICE:  [            1662]     unregistering client: libCEC version = 4.0.1, client version = 4.0.1, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, git revision: libcec-4.0.1+2-00ee987, compiled on 2017年  1月 14日 土曜日 01:31:11 UTC by pi@raspberrypi on Linux 4.4.38-v7+ (armv7l), features: P8_USB, DRM, P8_detect, randr, RPi
DEBUG:   [            1662]     Recorder 1 (1): power status changed from 'on' to 'unknown'
DEBUG:   [            1662]     Recorder 1 (1): vendor = Unknown (000000)
DEBUG:   [            1662]     Recorder 1 (1): CEC version unknown
DEBUG:   [            1662]     Recorder 1 (1): osd name set to 'Recorder 1'
DEBUG:   [            1663]     Recorder 1 (1): device status changed into 'unknown'
DEBUG:   [            1663]     unregistering all CEC clients
DEBUG:   [            2063]     UnregisterLogicalAddress - releasing previous logical address
DEBUG:   [            2063]     logical address changed to Broadcast (f)
pi@raspberrypi:~ $ echo "scan"|cec-client -s
opening a connection to the CEC adapter...
DEBUG:   [              60]     Broadcast (F): osd name set to 'Broadcast'
DEBUG:   [              62]     Open - vc_cec initialised
DEBUG:   [              62]     logical address changed to Free use (e)
NOTICE:  [              62]     connection opened
DEBUG:   [              63]     processor thread started
DEBUG:   [              63]     << Broadcast (F) -> TV (0): POLL
DEBUG:   [              63]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [              63]     << e0
DEBUG:   [             154]     initiator 'Broadcast' is not supported by the CEC adapter. using 'Free use' instead
TRAFFIC: [             154]     << e0
DEBUG:   [             244]     >> POLL not sent
DEBUG:   [             244]     TV (0): device status changed into 'not present'
NOTICE:  [             244]     registering new CEC client - v4.0.1
DEBUG:   [             245]     detecting logical address for type 'recording device'
DEBUG:   [             245]     trying logical address 'Recorder 1'
DEBUG:   [             245]     << Recorder 1 (1) -> Recorder 1 (1): POLL
TRAFFIC: [             245]     << 11
TRAFFIC: [             515]     << 11
DEBUG:   [             786]     >> POLL not sent
DEBUG:   [             786]     using logical address 'Recorder 1'
DEBUG:   [             786]     Recorder 1 (1): device status changed into 'handled by libCEC'
DEBUG:   [             786]     Recorder 1 (1): power status changed from 'unknown' to 'on'
DEBUG:   [             787]     Recorder 1 (1): vendor = Pulse Eight (001582)
DEBUG:   [             787]     Recorder 1 (1): CEC version 1.4
DEBUG:   [             787]     AllocateLogicalAddresses - device '0', type 'recording device', LA '1'
DEBUG:   [             788]     logical address changed to Recorder 1 (1)
DEBUG:   [             788]     Recorder 1 (1): osd name set to 'CECTester'
DEBUG:   [             788]     Recorder 1 (1): menu language set to 'eng'
DEBUG:   [             789]     GetPhysicalAddress - physical address = 1000
DEBUG:   [             789]     AutodetectPhysicalAddress - autodetected physical address '1000'
DEBUG:   [             789]     Recorder 1 (1): physical address changed from ffff to 1000
DEBUG:   [             789]     << Recorder 1 (1) -> broadcast (F): physical address 1000
TRAFFIC: [             789]     << 1f:84:10:00:01
NOTICE:  [             941]     CEC client registered: libCEC version = 4.0.1, client version = 4.0.1, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, git revision: libcec-4.0.1+2-00ee987, compiled on 2017年  1月 14日 土曜日 01:31:11 UTC by pi@raspberrypi on Linux 4.4.38-v7+ (armv7l), features: P8_USB, DRM, P8_detect, randr, RPi
DEBUG:   [             941]     << Recorder 1 (1) -> TV (0): OSD name 'CECTester'
DEBUG:   [             941]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [             941]     << 10
TRAFFIC: [            1032]     << 10
DEBUG:   [            1122]     >> POLL not sent
DEBUG:   [            1123]     not sending command 'set osd name': destination device 'TV' marked as not present
DEBUG:   [            1123]     << requesting power status of 'TV' (0)
DEBUG:   [            1123]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [            1123]     << 10
TRAFFIC: [            1214]     << 10
DEBUG:   [            1304]     >> POLL not sent
DEBUG:   [            1304]     not sending command 'give device power status': destination device 'TV' marked as not present
requesting CEC bus information ...
DEBUG:   [            1305]     << Recorder 1 (1) -> TV (0): POLL
TRAFFIC: [            1305]     << 10
TRAFFIC: [            1396]     << 10
DEBUG:   [            1486]     >> POLL not sent
DEBUG:   [            1487]     << Recorder 1 (1) -> Recorder 2 (2): POLL
TRAFFIC: [            1487]     << 12
TRAFFIC: [            1578]     << 12
DEBUG:   [            1668]     >> POLL not sent
DEBUG:   [            1668]     Recorder 2 (2): device status changed into 'not present'
DEBUG:   [            1669]     << Recorder 1 (1) -> Tuner 1 (3): POLL
TRAFFIC: [            1669]     << 13
TRAFFIC: [            1759]     << 13
DEBUG:   [            1850]     >> POLL not sent
DEBUG:   [            1850]     Tuner 1 (3): device status changed into 'not present'
DEBUG:   [            1850]     << Recorder 1 (1) -> Playback 1 (4): POLL
TRAFFIC: [            1850]     << 14
TRAFFIC: [            1941]     << 14
DEBUG:   [            2031]     >> POLL not sent
DEBUG:   [            2031]     Playback 1 (4): device status changed into 'not present'
DEBUG:   [            2032]     << Recorder 1 (1) -> Audio (5): POLL
TRAFFIC: [            2032]     << 15
TRAFFIC: [            2123]     << 15
DEBUG:   [            2213]     >> POLL not sent
DEBUG:   [            2213]     Audio (5): device status changed into 'not present'
DEBUG:   [            2214]     << Recorder 1 (1) -> Tuner 2 (6): POLL
TRAFFIC: [            2214]     << 16
TRAFFIC: [            2304]     << 16
DEBUG:   [            2395]     >> POLL not sent
DEBUG:   [            2395]     Tuner 2 (6): device status changed into 'not present'
DEBUG:   [            2396]     << Recorder 1 (1) -> Tuner 3 (7): POLL
TRAFFIC: [            2396]     << 17
TRAFFIC: [            2486]     << 17
DEBUG:   [            2577]     >> POLL not sent
DEBUG:   [            2577]     Tuner 3 (7): device status changed into 'not present'
DEBUG:   [            2577]     << Recorder 1 (1) -> Playback 2 (8): POLL
TRAFFIC: [            2577]     << 18
TRAFFIC: [            2668]     << 18
DEBUG:   [            2758]     >> POLL not sent
DEBUG:   [            2758]     Playback 2 (8): device status changed into 'not present'
DEBUG:   [            2758]     << Recorder 1 (1) -> Recorder 3 (9): POLL
TRAFFIC: [            2758]     << 19
TRAFFIC: [            2849]     << 19
DEBUG:   [            2939]     >> POLL not sent
DEBUG:   [            2939]     Recorder 3 (9): device status changed into 'not present'
DEBUG:   [            2939]     << Recorder 1 (1) -> Tuner 4 (A): POLL
TRAFFIC: [            2939]     << 1a
TRAFFIC: [            3030]     << 1a
DEBUG:   [            3121]     >> POLL not sent
DEBUG:   [            3121]     Tuner 4 (A): device status changed into 'not present'
DEBUG:   [            3121]     << Recorder 1 (1) -> Playback 3 (B): POLL
TRAFFIC: [            3121]     << 1b
TRAFFIC: [            3211]     << 1b
DEBUG:   [            3302]     >> POLL not sent
DEBUG:   [            3302]     Playback 3 (B): device status changed into 'not present'
DEBUG:   [            3302]     << Recorder 1 (1) -> Reserved 1 (C): POLL
TRAFFIC: [            3302]     << 1c
TRAFFIC: [            3393]     << 1c
DEBUG:   [            3483]     >> POLL not sent
DEBUG:   [            3483]     Reserved 1 (C): device status changed into 'not present'
DEBUG:   [            3483]     << Recorder 1 (1) -> Reserved 2 (D): POLL
TRAFFIC: [            3483]     << 1d
TRAFFIC: [            3574]     << 1d
DEBUG:   [            3664]     >> POLL not sent
DEBUG:   [            3664]     Reserved 2 (D): device status changed into 'not present'
DEBUG:   [            3664]     << Recorder 1 (1) -> Free use (E): POLL
TRAFFIC: [            3664]     << 1e
TRAFFIC: [            3755]     << 1e
DEBUG:   [            3845]     >> POLL not sent
DEBUG:   [            3845]     Free use (E): device status changed into 'not present'
DEBUG:   [            3845]     << requesting active source
TRAFFIC: [            3846]     << 1f:85
DEBUG:   [            4907]     expected response not received (82: active source)
TRAFFIC: [            4907]     << 1f:85
DEBUG:   [            5967]     expected response not received (82: active source)
DEBUG:   [            5968]     << requesting active source
TRAFFIC: [            5968]     << 1f:85
DEBUG:   [            7028]     expected response not received (82: active source)
TRAFFIC: [            7028]     << 1f:85
CEC bus information
===================
device #1: Recorder 1
address:       1.0.0.0
active source: no
vendor:        Pulse Eight
osd string:    CECTester
CEC version:   1.4
power status:  on
language:      eng


currently active source: unknown (-1)
DEBUG:   [            8089]     expected response not received (82: active source)
DEBUG:   [            8089]     unregistering all CEC clients
NOTICE:  [            8090]     unregistering client: libCEC version = 4.0.1, client version = 4.0.1, firmware version = 1, logical address(es) = Recorder 1 (1) , physical address: 1.0.0.0, git revision: libcec-4.0.1+2-00ee987, compiled on 2017年  1月 14日 土曜日 01:31:11 UTC by pi@raspberrypi on Linux 4.4.38-v7+ (armv7l), features: P8_USB, DRM, P8_detect, randr, RPi
DEBUG:   [            8090]     Recorder 1 (1): power status changed from 'on' to 'unknown'
DEBUG:   [            8090]     Recorder 1 (1): vendor = Unknown (000000)
DEBUG:   [            8090]     Recorder 1 (1): CEC version unknown
DEBUG:   [            8090]     Recorder 1 (1): osd name set to 'Recorder 1'
DEBUG:   [            8090]     Recorder 1 (1): device status changed into 'unknown'
DEBUG:   [            8090]     unregistering all CEC clients
DEBUG:   [            9064]     UnregisterLogicalAddress - releasing previous logical address
DEBUG:   [            9064]     logical address changed to Broadcast (f)
pi@raspberrypi:~ $ 

スポンサーリンク
レクタングル(大)広告

シェアする

  • このエントリーをはてなブックマークに追加
  • Evernoteに保存Evernoteに保存
スポンサーリンク
レクタングル(大)広告