Query the TV status using cec-client or something else

Raspberry Pi 2

Query the TV status using cec-client or something else

Postby graysky » Sun Jan 17, 2016 1:12 pm

I have an RPi2 connected via HDMI to an HDTV. My goal is query the power on/off status of the TV. I think cec-client will allow for this.

I added my user to the lock and uucp groups and as I understand the following output give me available options if I am using the software correctly:
$this->bbcode_second_pass_code('', '
% 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.
================================================================================')

If I turn the TV on and I can see the login prompt at this point, this command returns nothing:
$this->bbcode_second_pass_code('', '
% echo pow | cec-client -s -d 1
opening a connection to the CEC adapter...')

I also found /opt/vc/bin/tvservice

Again, the TV is manually turned on:
$this->bbcode_second_pass_code('', '% /opt/vc/bin/tvservice -s
state 0x120002 [TV is off]
')

So that's completely incorrect. But, the script does show the name of the device (it is an LG set):
$this->bbcode_second_pass_code('', '/opt/vc/bin/tvservice -n
device_name=GSM-LG_TV
')

I cannot turn the set off using any of the "off" modes in the script:
$this->bbcode_second_pass_code('', '/opt/vc/bin/tvservice -o
Powering off HDMI')

But the set is clearly still powered on. Any advice is welcomed.
graysky
Developer
 
Posts: 1731
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Return to Broadcom

Who is online

Users browsing this forum: No registered users and 12 guests