raspberry-pi - 通过命令行通过 HDMI 发送 CEC 命令

标签 raspberry-pi television hdmi

我的总体计划是能够从我的树莓派发送 CEC 命令来执行诸如打开/关闭电视以及连接到电视的其他设备之类的操作。然后我将添加语音识别来发送这些命令......那是另一天。我已经阅读了 CEC,但从我收集到的信息来看,如果没有 CEC USB 适配器,您似乎无法直接通过命令行发送 CEC 命令?我已经在我的 pi 上安装了 cec-client 和 libCEC 库,但是当我运行 cec-client -l 时它没有显示任何设备。

我的问题是,如何在没有适配器的情况下通过命令行将 CEC 命令从 pi 发送到我的电视?我是否缺少有关 CEC 的一些基本要素?

更新

除了下面的帖子之外,这里还有一个链接,它在 stackoverflow 的 PI 部分中询问了更多 CEC 命令,我已将这些命令放入我的 .bashrc 中以打开/关闭电视并更改输入

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

最佳答案

您可以通过管道将命令发送到 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/

关于raspberry-pi - 通过命令行通过 HDMI 发送 CEC 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15315372/

相关文章:

python - 树莓派串口数据传输输入输出延迟

java - 我在树莓派上运行 debian wheezy 的 Java 蓝牙服务器需要 bluecove native 库 - 我在哪里可以找到它?

android - 我该如何编写这个 Android 应用程序?自动改变音频输出模式

android - 在 Android 应用程序中使用 libCEC + USB 加密狗

python - 从树莓派上传文件到谷歌驱动器

python - 如何更改 Raspberry Pi 中的默认 Python 版本

reactjs - React Native 焦点在 tvOS 中没有改变

tizen - 在 Tizen TV 2016 [KU6300] 上启用开发者模式

javascript - 氨基A140开发(机顶盒)

c++ - 如果没有连接 HDMI 设备,没有 X 的 SDL2 显示 'Segmentation fault'