7

私のマスタープランは、ラズベリーパイからCECコマンドを送信して、テレビやテレビに接続されている他のデバイスのオン/オフなどを実行できるようにすることです。次に、これらのコマンドを送信するために音声認識を追加します...それは別の日です。私はCECについて読みましたが、私が集めたものから、CEC usbアダプターなしではコマンドラインを介してCECコマンドを直接送信できないように思われますか?piにcec-clientおよびlibCECライブラリをインストールしましたが、cec-client -lを実行すると、デバイスが表示されません。

私の質問は、アダプターなしで、コマンドラインを介してpiからテレビにCECコマンドを送信するにはどうすればよいですか?CECに関する基本的な要素が欠けていますか?

アップデート

以下の投稿に加えて、stackoverflowのPI部分で、テレビのオン/オフを切り替えたり入力を変更したりするために.bashrc内に配置したCECコマンドがいくつかあるリンクがあります。

https://raspberrypi.stackexchange.com/questions/5345/raspmbc-send-cec-commands-without-cec-adapter

4

2 に答える 2

6

コマンドをcec-clientバイナリにパイプできます

echo "on 0"      | cec-client -s # turn on the television
echo "standby 0" | cec-client -s # turn it off (standby)

完全を期すために、これらはあなたができる他のいくつかのことです

接続されているデバイスのリスト

tv# cec-client -l
libCEC version: 3.1.0, git revision: libcec-3.1.0+5-6d68d21, compiled on Fri  8 Apr 15:44:58 UTC 2016 by nacho@tv on Linux 4.1.19-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

使用可能なすべてのCECコマンドを確認してください

tv# echo h | cec-client -s -d 1
opening a connection to the CEC adapter...

================================================================================
Available commands:

[tx] {bytes}              transfer bytes over the CEC line.
[txn] {bytes}             transfer bytes but don't wait for transmission ACK.
[on] {address}            power on the device with the given logical address.
[standby] {address}       put the device with the given address in standby mode.
[la] {logical address}    change the logical address of the CEC adapter.
[p] {device} {port}       change the HDMI port number of the CEC adapter.
[pa] {physical address}   change the physical address of the CEC adapter.
[as]                      make the CEC adapter the active source.
[is]                      mark the CEC adapter as inactive source.
[osd] {addr} {string}     set OSD message on the specified device.
[ver] {addr}              get the CEC version of the specified device.
[ven] {addr}              get the vendor ID of the specified device.
[lang] {addr}             get the menu language of the specified device.
[pow] {addr}              get the power status of the specified device.
[name] {addr}             get the OSD name of the specified device.
[poll] {addr}             poll the specified device.
[lad]                     lists active devices on the bus
[ad] {addr}               checks whether the specified device is active.
[at] {type}               checks whether the specified device type is active.
[sp] {addr}               makes the specified physical address active.
[spl] {addr}              makes the specified logical address active.
[volup]                   send a volume up command to the amp if present
[voldown]                 send a volume down command to the amp if present
[mute]                    send a mute/unmute command to the amp if present
[self]                    show the list of addresses controlled by libCEC
[scan]                    scan the CEC bus and display device info
[mon] {1|0}               enable or disable CEC bus monitoring.
[log] {1 - 31}            change the log level. see cectypes.h for values.
[ping]                    send a ping command to the CEC adapter.
[bl]                      to let the adapter enter the bootloader, to upgrade
                          the flash rom.
[r]                       reconnect to the CEC adapter.
[h] or [help]             show this help.
[q] or [quit]             to quit the CEC test client and switch off all
                          connected CEC devices.
================================================================================

から抽出

https://ownyourbits.com/2017/02/02/control-your-raspberry-pi-with-your-tv-remote/

于 2017-02-07T13:19:53.387 に答える
4

libcecの最近のバージョンは、RaspberryPiハードウェアをCECアダプターとして認識します。
コマンドラインから制御コマンドを送信するには、基本的に次のようにします。

echo "on 0" | cec-client -s

デバイス0(つまりテレビ)の電源がオンになり
ますより複雑なコマンドについては、cec-clientインタラクティブシェルを確認してください

于 2013-07-01T08:22:28.133 に答える