Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: Issue with Rotary Encoder Device in Moode 9
#1
Hello everyone,
I am very excited about the new moode 9 release! There are many aspects to explore, and I am happy to report that I can play my music without any issues. However, I am encountering a problem with the "Enable a rotary encoder device to control MPD volume" feature.

Despite using the same hardware connection as in version 8, this option doesn't seem to trigger the correct script. I have tested other different interaction scripts with the rotary encoder that I had on hand under moode 9, and I was able to run them without any issues.

Is anyone else experiencing this problem or has any suggestions for a solution? Thanks in advance for your help!

Currently running 9 on Pi 3a+.

Best regards,
Reply
#2
Could be a bug.

See if the driver is running:
Code:
pgrep rotenc.py

If it's running and there is no response from the encoder then further debugging is required, however I don't have a device on hand that has an encoder wired in so someone else will need to help out.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(05-19-2024, 10:43 PM)Tim Curtis Wrote: Could be a bug.

See if the driver is running:
Code:
pgrep rotenc.py

If it's running and there is no response from the encoder then further debugging is required, however I don't have a device on hand that has an encoder wired in so someone else will need to help out.

I used the command pgrep rotenc.py but did not receive any output. When I searched for and executed rotenc.py, I received the following error message:

Code:
Traceback (most recent call last):
 File "/var/www/daemon/rotenc.py", line 170, in <module>
   main()
 File "/var/www/daemon/rotenc.py", line 61, in main
   GPIO.add_event_detect(pin_a, GPIO.BOTH, callback=encoder_isr) # NOTE: bouncetime= is not specified
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Failed to add edge detection
Reply
#4
@thestreamdigger

I have no suitable hardware encoder to connect to a moOde player, but...

With moOde r900 running on a Pi3A+, when I enable the Rotary Encoder I see in the journal that the rotenc service has started


Code:
xxx@m900pi3ap:~ $ journalctl -g rotenc
-- Boot ba831770f74b4de29376b5a84ae21e63 --
-- Boot d7a17260dc3d4ea0b6f15534bce1b489 --
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Started rotenc.service - Moode Rotary Encoder Driver.

As well, pgrep rotenc.py returns the process number 3212.

Curious that you don't see it running. What do you get when you search the journal as I did above?

Regards,
Kent


@Tim Curtis --- Note that another service unit marked executable has slipped in. Not relevant to the OPs problem, but spams the journal.

Also, Do we know rotenc.py will run on a Pi5? I have no first hand knowledge of this piece of code but any Python code which deals with gpio is suspect (a matter of the correct library being loaded and used).
Reply
#5
@thestreamdigger
Hi,
Would you please try this command:
Code:
sudo apt install python3-rpi.gpio


reboot the system and let us know.

@Tim Curtis and @TheOldPresbyope

It could be the new library: in case it is possibile to add 
Code:
, bouncetime=10


At the program line 61 and test with "lgpio"

Best regards to all of you,
Francesco
Reply
#6
The encoder already works on the Pi5 without any problems. I tried to install moode v 9.0.0 in Pi3, it runs without problems.
Reply
#7
The rotary encoder for volume is working fine for me (Pi3A+). I've changed the default parameters though, not sure if that might be relevant. The scripts attached to my GPIO buttons are not firing however, also not sure if that's relevant. Investigating...
----------------
Robert
Reply
#8
(05-20-2024, 02:25 AM)TheOldPresbyope Wrote: @thestreamdigger

I have no suitable hardware encoder to connect to a moOde player, but...

With moOde r900 running on a Pi3A+, when I enable the Rotary Encoder I see in the journal that the rotenc service has started


Code:
xxx@m900pi3ap:~ $ journalctl -g rotenc
-- Boot ba831770f74b4de29376b5a84ae21e63 --
-- Boot d7a17260dc3d4ea0b6f15534bce1b489 --
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Started rotenc.service - Moode Rotary Encoder Driver.

As well, pgrep rotenc.py returns the process number 3212.

Curious that you don't see it running. What do you get when you search the journal as I did above?

Regards,
Kent


@Tim Curtis --- Note that another service unit marked executable has slipped in. Not relevant to the OPs problem, but spams the journal.

Also, Do we know rotenc.py will run on a Pi5? I have no first hand knowledge of this piece of code but any Python code which deals with gpio is suspect (a matter of the correct library being loaded and used).

I'll add "rotenc.service marked as executable" to the TODO list.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#9
(05-20-2024, 08:38 AM)the_bertrum Wrote: The rotary encoder for volume is working fine for me (Pi3A+).  I've changed the default parameters though, not sure if that might be relevant.  The scripts attached to my GPIO buttons are not firing however, also not sure if that's relevant.  Investigating...

The change that was made to prevent python scripts that use GPIO from crashing was to install python3-rpi.lgpio lib instead of python3-rpi.gpio.

The scripts affected are:

/var/www/daemon/gpio_buttons.py
/var/www/daemon/rotenc.py
/opt/boss2_oled_p3/boss2_oled.py

There is some sort of typeerror bug in the gpio_button.py script causing it to crash.

Code:
pi@moode9:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-20 07:44:17 bounce_time=1000
Traceback (most recent call last):
 File "/var/www/daemon/gpio_buttons.py", line 43, in <module>
   print(str(datetime.datetime.now())[:19] +
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can only concatenate str (not "NoneType") to str
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#10
(05-20-2024, 02:25 AM)TheOldPresbyope Wrote: @thestreamdigger

I have no suitable hardware encoder to connect to a moOde player, but...

With moOde r900 running on a Pi3A+, when I enable the Rotary Encoder I see in the journal that the rotenc service has started


Code:
xxx@m900pi3ap:~ $ journalctl -g rotenc
-- Boot ba831770f74b4de29376b5a84ae21e63 --
-- Boot d7a17260dc3d4ea0b6f15534bce1b489 --
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:14 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please re>
May 19 22:06:17 m900pi3ap systemd[1]: Started rotenc.service - Moode Rotary Encoder Driver.

As well, pgrep rotenc.py returns the process number 3212.

Curious that you don't see it running. What do you get when you search the journal as I did above?

Regards,
Kent


@Tim Curtis --- Note that another service unit marked executable has slipped in. Not relevant to the OPs problem, but spams the journal.

Also, Do we know rotenc.py will run on a Pi5? I have no first hand knowledge of this piece of code but any Python code which deals with gpio is suspect (a matter of the correct library being loaded and used).

This my journalctl result:

Code:
May 19 18:42:40 breaka systemd[1]: Configuration file /lib/systemd/system/rotenc.service is marked executable. Please r>
May 19 18:42:40 breaka systemd[1]: Started rotenc.service - Moode Rotary Encoder Driver.
May 19 18:42:40 breaka rotenc.py[1285]:   File "/var/www/daemon/rotenc.py", line 170, in <module>
May 19 18:42:40 breaka rotenc.py[1285]:   File "/var/www/daemon/rotenc.py", line 61, in main
May 19 18:42:41 breaka systemd[1]: rotenc.service: Main process exited, code=exited, status=1/FAILURE
May 19 18:42:41 breaka systemd[1]: rotenc.service: Failed with result 'exit-code'.

Consulting the status of the service I get:
Code:
pi@breaka:~ $ sudo systemctl status rotenc.service
× rotenc.service - Moode Rotary Encoder Driver
    Loaded: loaded (/lib/systemd/system/rotenc.service; disabled; preset: enabled)
    Active: failed (Result: exit-code) since Mon 2024-05-20 11:49:36 -03; 1s ago
  Duration: 222ms
   Process: 2088 ExecStart=/var/www/daemon/rotenc.py 100 2 3 24 23 (code=exited, status=1/FAILURE)
  Main PID: 2088 (code=exited, status=1/FAILURE)
       CPU: 215ms

May 20 11:49:36 breaka systemd[1]: Started rotenc.service - Moode Rotary Encoder Driver.
May 20 11:49:36 breaka rotenc.py[2088]: Traceback (most recent call last):
May 20 11:49:36 breaka rotenc.py[2088]:   File "/var/www/daemon/rotenc.py", line 170, in <module>
May 20 11:49:36 breaka rotenc.py[2088]:     main()
May 20 11:49:36 breaka rotenc.py[2088]:   File "/var/www/daemon/rotenc.py", line 61, in main
May 20 11:49:36 breaka rotenc.py[2088]:     GPIO.add_event_detect(pin_a, GPIO.BOTH, callback=encoder_isr) # NOTE: bounc>
May 20 11:49:36 breaka rotenc.py[2088]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
May 20 11:49:36 breaka rotenc.py[2088]: RuntimeError: Failed to add edge detection
May 20 11:49:36 breaka systemd[1]: rotenc.service: Main process exited, code=exited, status=1/FAILURE
May 20 11:49:36 breaka systemd[1]: rotenc.service: Failed with result 'exit-code'.

It's strange that this issue occurs for me on a fresh install and not for everyone.
Reply


Forum Jump: