trainman419 / python-cec

Other
170 stars 42 forks source link

Exception: No default adapter found #4

Closed blachniet closed 10 years ago

blachniet commented 10 years ago

I get an exception when calling cec.init() on my RaspberryPi. I've included the terminal output below.

    pi@raspberrypi ~ $ sudo python
    Python 2.7.3 (default, Jan 13 2013, 11:20:46) 
    [GCC 4.6.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cec
    >>> cec.init()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    Exception: No default adapter found
    >>> 
trainman419 commented 10 years ago

Yep; it couldn't find any CEC adapters on your system.

When I've seen this on the Raspberry Pi, it's usually because the libcec library wasn't compiled with Raspberry Pi support (sadly, this includes the default version of libcec that ships with raspbian).

blachniet commented 10 years ago

Ok, it sounds like I may need to rebuild libcec myself with Raspberry Pi support. Before I do that, do you know if there is any way to check if the libs I have are supposed to have Raspberry Pi support? I haven't messed with them, so I assume they are the defaults that come with raspbian which, as you suggest, may not actually have Raspberry Pi support.

Romalouz commented 10 years ago

Hello,

Before using this python interface, you should download and compile libcec (ver 2.1.4) on the Pi. I used this package to compile on mine and it worked flawlessly: https://github.com/Pulse-Eight/libcec

Do not forget to pull version 0.1.0 of python-cec, otherwise you will get a segmentation fault (#3).

blachniet commented 10 years ago

Thanks @Romalouz, I'll try compiling it myself.

trainman419 commented 10 years ago

I've done a custom build of the libcec binaries for rasbian, with raspberry PI support. You should be able to install them with:

wget http://packages.namniart.com/repos/namniart.key -O - | sudo apt-key add -
sudo sh -c 'echo "deb http://packages.namniart.com/repos/pi wheezy main" > /etc/apt/sources.list.d/libcec.list'
sudo apt-get update
sudo apt-get install python-dev build-essential libcec-dev cec-utils
llauren commented 10 years ago

Hi @trainman419 . I followed your instructions above but still no luck. Checked out the 0.1.1 branch of python-cec, as per instructions on the main page. No go.

>>> import cec
>>> cec.list_adapters()
['RPI']
>>> cec.init()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: CEC failed to open RPI

This happens whether i run Python as pi or if i sudo python.

Plz halp. I would love it if my wife could hit a big red button, which would turn on the telly and the home theatre thingamabox and have all inputs as they should. Home entertainment infrastructure is so hard on the perfectly normal people who don't need to understand signal paths and configurations. In an ideal world, we wouldn't need this :)

trainman419 commented 10 years ago

I'm still getting the various version-compatibility bugs worked out between python-cec and the underlying library. I think version 0.1.1 doesn't work with newer versions of the library; try version 0.1.0, which was released before I starting adding backwards compatibility.

llauren commented 10 years ago

I'm a bit of a git noob, so pardon my possible wrongdoings.

This in ~/git/python-cec

git reset
git pull origin master
sudo python setup.py install

Got a few warnings but nothing more frightening than with the 0.1.1 branch. Then python:

>>> import cec
>>> cec.list_adapters()
['RPI']
>>> cec.init()
Segmentation fault

That's refreshing :)

trainman419 commented 10 years ago

Master is kind of broken at the moment. I've been trying to add callbacks from the C library back into python, and generally making a mess of things.

You should be able to check out the 0.1.0 tag and build it with:

git checkout 0.1.0
sudo python setup.py install
llauren commented 10 years ago

Success.

>>> import cec
>>> cec.init()
>>> 

Unfortunately i'm not at home at the moment so i can't actually see what's happening to my TV but at least nothing on my Pi crashed :)

trainman419 commented 10 years ago

Release 0.2.0 addresses this in a backwards-compatible way.