cec-mqtt-bridge
cec-mqtt-bridge copied to clipboard
ERROR: Could not initialise CEC: Could not connect to cec adapter
I keep getting this error when trying to start the application. I've tried changing the port in the config but the error remains.
I've tried the default port=RPI. Using cec-client -l I got following output:
libCEC version: 6.0.2, compiled on Linux-5.10.63-v8+ ... , features: P8_USB, DRM, P8_detect, randr, RPi, Exynos, Linux, AOCEC
Found devices: 1
device: 1
com port: /dev/cec0
vendor id: 0000
product id: 0000
firmware version: 0
type: Linux
What to me looked like I should use port /dev/cec0 but with the same result.
I followed the setup as described here. Only things different is that is don't have the /dev/vcsm and I had to change the dockerfile as in https://github.com/AlecLetourneau/cec-mqtt-bridge/pull/1.
Any idea how to resolve this issue?
When running on docker, I use the following docker-compose.yml file.
version: '2'
services:
cec-mqtt-bridge:
build:
context: src/
restart: unless-stopped
environment:
TZ: "Europe/Brussels"
devices:
- /dev/vchiq
volumes:
- ./src:/usr/src/app
Maybe you need to map the /dev/vchiq device?
The /dev/vchiq device was already included. I've also tried to run it using privileged but with no success. I've seen there is now a new commit but after updating the code I can now no longer build the docker image. I get following error when it is trying to install the dependencies.
Step 8/10 : RUN pip install -r requirements.txt
---> Running in e66285ec475f
Collecting python-lirc==1.2.3 (from -r requirements.txt (line 1))
Downloading https://files.pythonhosted.org/packages/20/37/5614ed0459439a96430e1aac479b6608b51e69ca0bd7d91277517d5895e9/python-lirc-1.2.3.tar.gz
Collecting paho-mqtt==1.3 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/33/7f/3ce1ffebaa0343d509aac003800b305d821e89dac3c11666f92e12feca14/paho-mqtt-1.3.0.tar.gz (79kB)
Complete output from command python setup.py egg_info:
Couldn't find index page for 'pytest-runner' (maybe misspelled?)
No local packages or working download links found for pytest-runner
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-mmssqb6e/paho-mqtt/setup.py", line 55, in <module>
setup_requires=setup_requirements
File "/usr/local/lib/python3.6/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 318, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 373, in fetch_build_eggs
replace_conflicting=True,
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 851, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1123, in best_match
return self.obtain(req, installer)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1135, in obtain
return installer(requirement)
File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 441, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 668, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pytest-runner')
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mmssqb6e/paho-mqtt/
You are using pip version 9.0.1, however version 22.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Fixed the build errors with the changes from https://github.com/michaelarnauts/cec-mqtt-bridge/pull/36, but I am still getting the same error.
I also tried to run the cec-client in the container instead of on the host system which gives following output
libCEC version: 4.0.2, git revision: <unknown>, compiled on Tue Aug 15 19:43:44 UTC 2017 by root@d5a86b735779 on Linux 4.9.35-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
Running just the cec-client I do also get unable to open the device on port RPI after a bunch of
DEBUG: [ 116] Broadcast (F): osd name set to 'Broadcast'
ERROR: [ 118] RegisterLogicalAddress - vc_cec_set_logical_address(E) returned invalid arg (8)
ERROR: [ 118] Open - vc_cec could not be initialised
ERROR: [ 118] could not open a connection (try 1)
So it would seem that or a device is missing or something I not correct in the image config.
I see the same output:
$ 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
Do you have this device file?
# ls -lah /dev/vchiq
crw-rw---- 1 root video 243, 0 Oct 23 19:17 /dev/vchiq
I'm running this on a PI 3B btw:
# cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 3 Model B Plus Rev 1.3
Have you maybe disabled the TV output or something? I know it possible to do this in the boot configuration.
My output for vchiq is the same
# ls -lah /dev/vchiq
crw-rw---- 1 root video 242, 0 Dec 22 22:17 /dev/vchiq
The hardware and os info is
- Distribution: Raspbian GNU/Linux 11 (bullseye)
- CPU Model: ARMv7 Processor rev 4 (v7l)
- CPU Type: Raspberry Pi 3 Model B Rev 1.2
- CPU Revision: a22082
- CPU Hardware: BCM2835
- Kernel: linux (5.15.76-v7+ (WS: 32))
- Python Version: 3.9.2
The cec and tv are definitely working because commands like echo on 0 | cec-client -s -d 1 and echo standby 0 | cec-client -s -d 1 are working. It is just never working from within docker.
Are you running other software on the Pi? Like Kodi, or something that might already use the CEC driver?
It would still not explain why it works outside the container though...
The PI is also running hyperion. It is indeed strange that it's just not working within docker because it would seem that the dependencies should be easier there.
I just saw that I've actually run this on a retropi install, so not really sure how it compares with a vanilla raspbian...
Some versions you could use to compare with yours...
# docker --version
Docker version 19.03.13, build 4484c46
# uname -r
5.4.72-v7+
# python3 --version
Python 3.7.3
# lsmod | grep vchiq
bcm2835_mmal_vchiq 28672 3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
vc_sm_cma 32768 2 bcm2835_isp,bcm2835_mmal_vchiq
# modinfo bcm2835_mmal_vchiq
filename: /lib/modules/5.4.72-v7+/kernel/drivers/staging/vc04_services/vchiq-mmal/bcm2835-mmal-vchiq.ko
version: 0.0.1
license: GPL
author: Dave Stevenson, <[email protected]>
description: BCM2835 MMAL VCHIQ interface
srcversion: 886F2261ECF1BB9AE5BDDB0
depends: vc-sm-cma
staging: Y
intree: Y
name: bcm2835_mmal_vchiq
vermagic: 5.4.72-v7+ SMP mod_unload modversions ARMv7 p2v8
#
Here are my outputs:
# docker --version
Docker version 20.10.22, build 3a2c30b
# uname -r
5.15.76-v7+
# python3 --version
Python 3.9.2
# lsmod | grep vchiq
bcm2835_mmal_vchiq 32768 3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
vc_sm_cma 32768 2 bcm2835_isp,bcm2835_mmal_vchiq
# modinfo bcm2835_mmal_vchiq
filename: /lib/modules/5.15.76-v7+/kernel/drivers/staging/vc04_services/vchiq-mmal/bcm2835-mmal-vchiq.ko.xz
license: GPL
author: Dave Stevenson, <[email protected]>
description: BCM2835 MMAL VCHIQ interface
srcversion: 1068DD8F4A0BE4C25F9DCC8
depends: vc-sm-cma
staging: Y
intree: Y
name: bcm2835_mmal_vchiq
vermagic: 5.15.76-v7+ SMP mod_unload modversions ARMv7 p2v8
parm: debug:activates debug info (0-3) (uint)
I'm using some newer software but that seems about it.
I wonder if your newer kernel (and probably, newer bcm2835-mmal-vchiq.ko) might have something to do with this... I could try setting up my pi from scratch with the latest raspbian to see if I have the same issue. I'm only using it for this project anyway.
Since it only happens within docker, that could also be something to look into. Could you maybe try installing an older docker version? Not as a permanent solution, but it would be nice to know what the issue is :)
Hi!
Unfortunately I have exactly the same problem. I have all the same versions as @depuits.
Versions detail
# ls -lah /dev/vchiq
crw-rw---- 1 root video 242, 0 Jan 23 00:53 /dev/vchiq
# cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 3 Model B Rev 1.2
# docker --version
Docker version 20.10.22, build 3a2c30b
# uname -r
5.15.84-v7+
# python3 --version
Python 3.9.2
# lsmod | grep vchiq
bcm2835_mmal_vchiq 32768 3 bcm2835_isp,bcm2835_codec,bcm2835_v4l2
vc_sm_cma 32768 2 bcm2835_isp,bcm2835_mmal_vchiq
# modinfo bcm2835_mmal_vchiq
filename: /lib/modules/5.15.84-v7+/kernel/drivers/staging/vc04_services/vchiq-mmal/bcm2835-mmal-vchiq.ko.xz
license: GPL
author: Dave Stevenson, <[email protected]>
description: BCM2835 MMAL VCHIQ interface
srcversion: 1068DD8F4A0BE4C25F9DCC8
depends: vc-sm-cma
staging: Y
intree: Y
name: bcm2835_mmal_vchiq
vermagic: 5.15.84-v7+ SMP mod_unload modversions ARMv7 p2v8
parm: debug:activates debug info (0-3) (uint)
Here is the error message:
Traceback (most recent call last):
File "bridge.py", line 172, in <module>
bridge = Bridge()
File "bridge.py", line 60, in __init__
mqtt_send=self.mqtt_publish)
File "/usr/src/app/lib/hdmicec.py", line 42, in __init__
raise Exception("Could not connect to cec adapter")
I tried to downgrade my docker version but strangely it looks like docker doesn't keep their old version. Here are the available versions: https://docs.docker.com/engine/install/debian/#tab-latest
apt-cache madison docker-ce | awk '{ print $3 }'
5:20.10.23~3-0~raspbian-bullseye
5:20.10.22~3-0~raspbian-bullseye
5:20.10.21~3-0~raspbian-bullseye
5:20.10.20~3-0~raspbian-bullseye
5:20.10.19~3-0~raspbian-bullseye
5:20.10.18~3-0~raspbian-bullseye
5:20.10.17~3-0~raspbian-bullseye
5:20.10.16~3-0~raspbian-bullseye
5:20.10.15~3-0~raspbian-bullseye
5:20.10.14~3-0~raspbian-bullseye
5:20.10.13~3-0~raspbian-bullseye
5:20.10.12~3-0~raspbian-bullseye
5:20.10.11~3-0~raspbian-bullseye
5:20.10.10~3-0~raspbian-bullseye
5:20.10.9~3-0~raspbian-bullseye
5:20.10.8~3-0~raspbian-bullseye
5:20.10.7~3-0~raspbian-bullseye
5:20.10.6~3-0~raspbian-bullseye
Here is in detail all the steps to reproduce the problem
Flash the image Raspberry pi lite os 32 bit to the pi.
Update and upgrade
sudo apt-get update && sudo apt-get upgrade
Install Docker
Download Docker script
curl -fsSL https://get.docker.com -o get-docker.sh
Run the Docker install script
sudo sh get-docker.sh
Include a Non-Root Account to the Docker
sudo usermod -aG docker ${USER}
Reboot
sudo reboot
Install Git
sudo apt install -y git
Install and Run CEC MQTT Bridge:
https://selfhostedhome.com/make-a-dumb-tv-smart-using-mqtt-and-cec/
Clone the repository and check out the master branch:
git clone https://github.com/michaelarnauts/cec-mqtt-bridge.git
Enter the repository:
cd cec-mqtt-bridge/
Create config file
nano config.ini
Don't forget to edit variables "mqtt.broker", "mqtt.user", "mqtt.password", "mqtt.prefix"
;
; MQTT broker configuration
;
[mqtt]
; Hostname of mqtt broker (required)
broker=192.168.2.62
; Port to connect to (default=1883)
port=1883
; Use TLS
;tls=0
; Username and password
user=cec-mqtt-bridge
password=
; MQTT prefix to use
prefix=living-room-tv
; Name of your device (default=cec-ir-mqtt)
;name=cec-ir-mqtt
;
; HDMI-CEC configuration
;
[cec]
; Enable CEC
enabled=1
; ID of CEC controller
id=1
; Port where the CEC-device is connected
port=RPI
; Devices to query (comma seperated, defaults to all devices)
;devices=0,2,3,4,5
; Name of your device (default=cec-ir-mqtt)
;name=OSMC
;
; LIRC configuration
;
[ir]
; Enable LIRC
enabled=0
Build the Docker image
docker build -t cec-mqtt-bridge .
Run the Docker image
docker run -d --device=/dev/vcsm-cma --device=/dev/vchiq --restart unless-stopped cec-mqtt-bridge
same here +1. Any chance to get this working in 64 bits arm?
So for Pis using the newer vc4-kms-v3d GPU layer, you need to use the "Linux" port type rather than the "RPI" one.