Cec-client does not work on Nightly 9.8 / RPI 4B

  • It looks the cec-client in lates nightly 9.8's is compiled without RPi feature so it does not work anymore on RPi 4B.

    Please find the details below.

    Hardware: RPI 4B / 1 GB

    LG TV

    LE version:

    LibreELEC (community): nightly-20201024-636e32e (RPi4.arm)

    (LibreELEC-RPi4.arm-9.80-nightly-20201024-636e32e.tar)

    Upgraded from official 9.2.5 where the HDMI CEC was partially working, some comamnds did not work (maybe the TV issue), some working commands sometimes failed with Segmentation fault error

    On 9.2.5:

    LibreELEC (official): 9.2.5 (RPi4.arm)

    LibreELEC:~ # echo 'scan' | cec-client -s -d 1

    opening a connection to the CEC adapter...

    requesting CEC bus information ...

    CEC bus information

    ===================

    device #0: TV

    address: 0.0.0.0

    active source: no

    vendor: LG

    osd string: TV

    CEC version: 1.3a

    power status: on

    language: eng


    device #1: Recorder 1

    address: 1.0.0.0

    active source: no

    vendor: LG

    osd string: CECTester

    CEC version: 1.3a

    power status: on

    language: eng


    on 9.80:

    LibreELEC (community): nightly-20201024-636e32e (RPi4.arm)

    RPi feature is missing...

    LibreELEC:~/downloads # cec-client -l

    libCEC version: 4.0.7, compiled on 2020-10-24 09:04:10 by jenkins@tsuboi on Linux 4.19.0-8-amd64 (x86_64), features: P8_USB, DRM, P8_detect, Linux

    Found devices: 1

    device: 1

    com port: Linux

    vendor id: 0000

    product id: 0000

    firmware version: 0

    type: Linux


    LibreELEC:~/downloads # echo 'scan' | cec-client -s -d 1

    opening a connection to the CEC adapter...

    ERROR: [ 60] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 60] could not open a connection (try 1)

    ERROR: [ 1060] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 1060] could not open a connection (try 2)

    ERROR: [ 2060] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 2060] could not open a connection (try 3)

    ERROR: [ 3060] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 3060] could not open a connection (try 4)

    ERROR: [ 4061] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 4061] could not open a connection (try 5)

    ERROR: [ 5061] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 5061] could not open a connection (try 6)

    ERROR: [ 6061] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 6062] could not open a connection (try 7)

    ERROR: [ 7062] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 7062] could not open a connection (try 8)

    ERROR: [ 8062] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 8062] could not open a connection (try 9)

    ERROR: [ 9063] CLinuxCECAdapterCommunication::Open - ioctl CEC_S_MODE failed - errno=16

    ERROR: [ 9063] could not open a connection (try 10)

    unable to open the device on port Linux

    ERROR: [ 10063] could not start CEC communications


    On RaspberryPI OS 5.4.51-v7l+:

    cec-client works

    pi@raspberrypi:~/Downloads $ cec-client -l

    libCEC version: 4.0.4, compiled on Linux-4.15.0-48-generic ... , features: P8_USB, DRM, P8_detect, randr, RPi, Exynos, AOCEC

    Found devices: 1

    device: 1

    com port: RPI

    vendor id: 2708

    product id: 1001

    firmware version: 1

    type: Raspberry Pi

  • LibreELEC master is using the linux kernel CEC framework instead of the old RPi firmware CEC support. Don't try to use libcec with RPi libs in parallel to that, this will interfere really badly.

    The error 16 you saw is caused by kodi running in the background and using the CEC adapter. If you stop kodi ("systemctl stop kodi") you can use cec-client as usual.

    so long,

    Hias

  • Thanks a lot for explanation, you are absolutely right.

    So that means if I wish to keep the Kodi running, I am now a bit limited regarding to CEC commands which can be sent to TV.

    It looks there are only 3 CEC built-in commands in Kodi: CECActivateSource, CECStandby and CECToggleState ( List of built-in functions - Official Kodi Wiki )

    I have tested all, kodi-send -a "CECActivateSource" worked fine, remaining commands did not work but I suppose it's due my old TV which is not fully compatible with all CEC commands.

    Thanks again for your quick reply.

  • LibreELEC also includes cec-ctl from the v4l-utils package, you could give that a try.

    I'm not really familiar with it (CEC with libcec/kodi works just fine here with my LG TV so I only did some very basic tests to check if cec-ctl works) but as that tool is written specifically for the linux kernel CEC framework there's some chance it might work better than cec-client/libcec.

    so long,

    Hias

  • Thanks for the hint, Hias, I can confirm cec-ctl works and can be used at the same time with Kodi, in my case at least for TV status monitoring and power on (all other commands, unfortunately including standby and power-off, are ignored by my 10 years old TV).

    Some examples, if someone else is interested:

    Show topology:

    LibreELEC:~ # cec-ctl -S

    Driver Info:

    Driver Name : vc4_hdmi

    Adapter Name : vc4

    Capabilities : 0x0000010e

    Logical Addresses

    Transmit

    Passthrough

    Connector Info

    Driver version : 5.9.0

    Available Logical Addresses: 1

    DRM Connector Info : card 0, connector 32

    Physical Address : 1.0.0.0

    Logical Address Mask : 0x0002

    CEC Version : 1.4

    Vendor ID : 0x001582 (Pulse-Eight)

    OSD Name : ''

    Logical Addresses : 1 (Allow Fallback to Unregistered)

    Logical Address : 1 (Recording Device 1)

    Primary Device Type : Record

    Logical Address Type : Record

    System Information for device 0 (TV) from device 1 (Recording Device 1):

    CEC Version : Tx, OK, Rx, Timeout

    Physical Address : Tx, OK, Rx, Timeout

    Vendor ID : 0x00e091 (LG)

    OSD Name : Tx, OK, Rx, Timeout

    Menu Language : kor

    Power Status : On

    Topology:

    1.0.0.0: Recording Device 1

    Power on:

    LibreELEC:~ # cec-ctl --user-control-pressed ui-cmd=power-on-function --to 0

    Driver Info:

    Driver Name : vc4_hdmi

    Adapter Name : vc4

    Capabilities : 0x0000010e

    Logical Addresses

    Transmit

    Passthrough

    Connector Info

    Driver version : 5.9.0

    Available Logical Addresses: 1

    DRM Connector Info : card 0, connector 32

    Physical Address : 1.0.0.0

    Logical Address Mask : 0x0002

    CEC Version : 1.4

    Vendor ID : 0x001582 (Pulse-Eight)

    OSD Name : ''

    Logical Addresses : 1 (Allow Fallback to Unregistered)

    Logical Address : 1 (Recording Device 1)

    Primary Device Type : Record

    Logical Address Type : Record


    Transmit from Recording Device 1 to TV (1 to 0):

    USER_CONTROL_PRESSED (0x44):

    ui-cmd: power-on-function (0x6d)

    Sequence: 178 Tx Timestamp: 654.417s


    Monitor CEC traffic:

    LibreELEC:~ # cec-ctl -m

    Driver Info:

    Driver Name : vc4_hdmi

    Adapter Name : vc4

    Capabilities : 0x0000010e

    Logical Addresses

    Transmit

    Passthrough

    Connector Info

    Driver version : 5.9.0

    Available Logical Addresses: 1

    DRM Connector Info : card 0, connector 32

    Physical Address : 1.0.0.0

    Logical Address Mask : 0x0002

    CEC Version : 1.4

    Vendor ID : 0x001582 (Pulse-Eight)

    OSD Name : ''

    Logical Addresses : 1 (Allow Fallback to Unregistered)

    Logical Address : 1 (Recording Device 1)

    Primary Device Type : Record

    Logical Address Type : Record


    Initial Event: State Change: PA: 1.0.0.0, LA mask: 0x0002, Conn Info: yes

    Received from TV to all (0 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Received from TV to all (0 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Received from TV to all (0 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Received from TV to all (0 to 15): STANDBY (0x36)

    Received from TV to all (0 to 15): STANDBY (0x36)

    Received from TV to all (0 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Received from TV to Recording Device 1 (0 to 1): GIVE_DEVICE_VENDOR_ID (0x8c)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Received from TV to Recording Device 1 (0 to 1): VENDOR_COMMAND (0x89):

    vendor-specific-data: 0x01

    Transmitted by Recording Device 1 to TV (1 to 0): VENDOR_COMMAND (0x89):

    vendor-specific-data: 0x02 0x05

    Received from TV to Recording Device 1 (0 to 1): GIVE_DEVICE_POWER_STATUS (0x8f)

    Transmitted by Recording Device 1 to TV (1 to 0): REPORT_POWER_STATUS (0x90):

    pwr-state: to-on (0x02)

    Received from TV to Recording Device 1 (0 to 1): GIVE_PHYSICAL_ADDR (0x83)

    Transmitted by Recording Device 1 to all (1 to 15): REPORT_PHYSICAL_ADDR (0x84):

    phys-addr: 1.0.0.0

    prim-devtype: record (0x01)

    Received from TV to all (0 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

    Transmitted by Recording Device 1 to all (1 to 15): DEVICE_VENDOR_ID (0x87):

    vendor-id: 57489 (0x0000e091)

  • I see that you have got cec-ctl running on your RPI.


    On the generic nightly matrix image it is not there. Is there a reason for that? It would be good to have cec-ctl available on the Intel NUC.

    I was reading this reference. I have some issues with the way that my CEC environment behaves, and being able to pass though commands to the CEC devices would probably give me a good workaround.


    CEC-HDMI - UDOO X86 II Docs

  • Thanks for the hint, Hias, I can confirm cec-ctl works and can be used at the same time with Kodi, in my case at least for TV status monitoring and power on (all other commands, unfortunately including standby and power-off, are ignored by my 10 years old TV).

    well.. i have a 3 years old tv.. and i cant get ir working too.. i used to make cec-client turn on and off my tv and my receiver ( a simple bd-player with 5.1 audio using arc) flawless, but i cant make it work at all with cec-ctl


    edit

    i could the shutdown work with

    Code
    cec-ctl --standby -tX  
    
    where X is your device number.. cec-ctl --standby -t4 (to turn off my receiver) just works. 
    
    and to turn on
    
    cec-ctl --user-control-pressed ui-cmd=power-on-function -tx
    
    x is your device in my case

    Edited 2 times, last by dudumaroja (June 7, 2021 at 9:51 PM).

  • I have tested all, kodi-send -a "CECActivateSource" worked fine, remaining commands did not work but I suppose it's due my old TV which is not fully compatible with all CEC commands.

    Thanks again for your quick reply.

    I don't think this is due to an old TV, I have a 2021 Samsung and "CECActivateSource" is the only one worked for me too.

    I have managed to get this command working to put into standby:

    Code
    cec-ctl -d/dev/cec0 --to 0 --standby

    However, it would mean having separate buttons on my remote to control the power unless someone cleverer than me could come up with a script to toggle one button.

    EDIT: I just realised @dudumaroja posted the same thing but his code block confused me ^^

  • Standby / Power off CEC functions simply does not work on my old LG TV. Due to other limits, especially non-existing CEC standards (regarding to even most basic functions) across devices, I found CEC unusable for my needs.

    Therefore I have created a very simple IR transmit hardware and I am now controlling the mentioned TV with IR commands (through ir-ctl utility) which works perfectly without any CEC limits (and it can control not just TVs but any device with IR remote control).

    BTW. tested CEC commands with concurrent OSMC with the same / similar results, just:

    CECStandby works as Pause

    CECToggleState works as Play/Pause toggle

  • LG are notoriously bad for CEC. I have Samsungs and they work fine with other devices. What I don't understand is why CECStandby doesn't work but cec-ctl -d/dev/cec0 --to 0 --standby does

    I also have a broadlink universal blaster controlled by Home Assistant but for another room I don't want to have to buy another for something which should work with the built in remote.

  • I also have a broadlink universal blaster controlled by Home Assistant but for another room I don't want to have to buy another for something which should work with the built in remote.

    Yeah I understand. I am controlling (not just) the LE with (any) preferred IR Remote Control.

    In my case it is the different type than my LG original to avoid conflict (in fact I don't control the TV anymore with the original IR RC).

    I have created the mapping file for my IR RC (currently Samsung) to be used with ir-keytable and configured irexec to run scripts, bound to selected (usually unused) buttons.

    See this post: RE: Remote Control

    So it is possible for instance to send a commands to Home Assistant through MQTT and much more.