michaeljtbrooks / raspiled

Raspberry Pi driven RGB LED strips
MIT License
15 stars 4 forks source link

Launching issue on Ubuntu 21.04 #16

Open revoxhere opened 3 years ago

revoxhere commented 3 years ago

Hey there, I'm not sure if this project is still maintained, but I was using Raspiled before for half a year on Ubuntu Server 18.04, and all worked fine. Problems stared appearing when I updated my pi to Ubuntu Server 21.04, that's the issue I'm facing:

(raspiled) ubuntu@revox-kala:~/raspiled$ python ./src/raspiled_listener.py
[13:40:00 RASPILED] Using config file: /home/ubuntu/raspiled/src/raspiled.conf
[13:40:01 RASPILED] [STARTING] Raspiled Listener with PID 43645
[13:40:01 RASPILED]  Cannot read PWM of pin #27
[13:40:01 RASPILED]  Cannot read PWM of pin #27
[13:40:01 RASPILED]  Cannot read PWM of pin #27
Unhandled error in Deferred:

Traceback (most recent call last):
  File "/home/ubuntu/raspiled/./src/raspiled_listener.py", line 831, in <module>
    start_if_not_running()
  File "/home/ubuntu/raspiled/./src/raspiled_listener.py", line 823, in start_if_not_running
    endpoint.listen(factory)
  File "/home/ubuntu/raspiled/lib/python3.9/site-packages/twisted/internet/endpoints.py", line 511, in listen
    return defer.execute(
--- <exception caught here> ---
  File "/home/ubuntu/raspiled/lib/python3.9/site-packages/twisted/internet/defer.py", line 139, in execute
    result = callable(*args, **kw)
  File "/home/ubuntu/raspiled/lib/python3.9/site-packages/twisted/internet/posixbase.py", line 569, in listenTCP
    p.startListening()
  File "/home/ubuntu/raspiled/lib/python3.9/site-packages/twisted/internet/tcp.py", line 1327, in startListening
    skt.bind(addr)
builtins.TypeError: an integer is required (got type str)

I'm not sure what's the issue here, maybe the repository or some dependencies don't work on Python 3.10? I'll keep looking myself, but any help will be greatly appreciated.

michaeljtbrooks commented 3 years ago

Hiya,

Yep I'm still looking after Raspiled, though as it is behaving for me I've not pushed that many updates recently.

I'd originally written it for Python 2.7, but with Python 3 compatibility to 3.5 at least. This bug is probably is a change to the way the Twisted library behaves in Python 3.

The error looks like Twisted is passing along whatever port got set in the user settings without casting it into an integer first. The settings file is essentially parsed internally as text. It's a bit daft because our config file does verify that you've stored something integer compatible, but I guess it fails to convert it into integer when it goes to actually use the value.

Does this commit fix it? https://github.com/michaeljtbrooks/raspiled/commit/d7c25531855a167e1d185fed323239fd3d1456fd

revoxhere commented 3 years ago

Looks like the new code allows me to progress further, but there's still an issue:

(ubuntu) ubuntu@revox-kala:~/raspiled$ python ./src/raspiled_listener.py
Traceback (most recent call last):
  File "/home/ubuntu/raspiled/./src/raspiled_listener.py", line 19, in <module>
    from src.config import CONFIG, get_setting, DEBUG
  File "/home/ubuntu/raspiled/src/__init__.py", line 10, in <module>
    from ledstrip import LEDStrip
  File "/home/ubuntu/raspiled/src/ledstrip.py", line 84, in <module>
    pigpiod_process()
  File "/home/ubuntu/raspiled/src/ledstrip.py", line 81, in pigpiod_process
    logging.info('PIGPIOD is running! PID: %s' % output.split('\n')[0])
TypeError: a bytes-like object is required, not 'str'

Manually editing that line removes that error, but a new one shows up:

(ubuntu) ubuntu@revox-kala:~/raspiled$ python ./src/raspiled_listener.py
[16:13:59 RASPILED] PIGPIOD is running!
[16:13:59 RASPILED] Using config file: /home/ubuntu/raspiled/src/raspiled.conf
Traceback (most recent call last):
  File "/home/ubuntu/raspiled/./src/raspiled_listener.py", line 19, in <module>
    from src.config import CONFIG, get_setting, DEBUG
  File "/home/ubuntu/raspiled/src/config.py", line 68, in <module>
    params = ordereddict_to_int(parser.defaults())
  File "/home/ubuntu/raspiled/src/config.py", line 22, in ordereddict_to_int
    if u"." in unicode(value):
NameError: name 'unicode' is not defined

Since strings in python 3 are unicode by default, I changed unicode() to str(), but there's a new issue:

ubuntu@revox-kala:~/raspiled$ python ./src/raspiled_listener.py
[20:34:33 RASPILED] PIGPIOD is running!
[20:34:33 RASPILED] Using config file: /home/ubuntu/raspiled/src/raspiled.conf
[20:34:33 RASPILED] Raspiled Listener already running with PID
(program exits)

After editing the file temporarily, I'm able to progress, and the app starts, but it can't read PWMs for some reason:

[20:40:32 RASPILED] PIGPIOD is running!
[20:40:32 RASPILED] Using config file: /home/ubuntu/raspiled/src/raspiled.conf
[20:40:33 RASPILED] [STARTING] Raspiled Listener with PID 95260
[20:40:33 RASPILED]  Cannot read PWM of pin #17
[20:40:33 RASPILED]  Cannot read PWM of pin #22
[20:40:33 RASPILED]  Cannot read PWM of pin #24

And the page looks like this: image

zvyn commented 2 years ago

The issues you describe look a lot like what I encountered when trying to run raspiled in Debian 11 (Python 3.9). I got it to work with the changes in #18