Raspberry pi 通过HDMI上的命令行发送CEC命令

Raspberry pi 通过HDMI上的命令行发送CEC命令,raspberry-pi,television,hdmi,Raspberry Pi,Television,Hdmi,我的主要计划是能够从我的raspberry pi发送CEC命令,以执行诸如打开/关闭电视以及连接到电视的其他设备等操作。然后我会添加语音识别来发送这些命令…那是另一天的事了。我读过CEC,但从我收集的信息来看,如果没有CEC usb适配器,您似乎无法通过命令行直接发送CEC命令?我已经在我的pi上安装了cec客户端和libCEC库,但是当我运行cec客户端-l时,它没有显示任何设备 我的问题是,在没有适配器的情况下,如何通过命令行将CEC命令从pi发送到电视?我是否遗漏了CEC的一些基本要素 更

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

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

更新

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


最新版本的libcec将Raspberry Pi硬件识别为CEC适配器。
要通过命令行发送控制命令,基本上:

echo "on 0" | cec-client -s
将打开设备0(即您的电视)

查看cec client interactive shell以了解更复杂的命令

您可以通过管道将命令传输到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.
================================================================================
摘自


我不知道这对你是否有用,但也许这是一个起点。当前,cec客户端注销所有活动的cec侦听器。执行此命令后,Kodi将断开与HDMI网络的连接。