05-21-2024, 07:57 AM
(This post was last modified: 05-21-2024, 08:02 AM by the_bertrum.
Edit Reason: Edited for clarity.
)
OK, well I'm really stumped.
The NULL condition only occurs when no button assignments have been set, as soon as those are configured I see no more null errors, although Tim's commands also work for fixing that condition of course.
The issue now is that as soon as button assignments are set, the GPIO.setup() function fails because it doesn't like the value of the pull_up_down parameter. The error message is "ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN". So I did some hacking. With the button set up using the UI on a clean system that never had any buttons set previously I see this:
OK, so pull_up_down needs to be PUD_UP but is set to the value of btn_1_pull which is set to the value of 'pull' which is GPIO.PUD_UP. So:
That should do the job...
But, but, just.... grrrr
Let's see if setting the value directly in the code works:
This is why I'm now a manager, not a technician.
The NULL condition only occurs when no button assignments have been set, as soon as those are configured I see no more null errors, although Tim's commands also work for fixing that condition of course.
The issue now is that as soon as button assignments are set, the GPIO.setup() function fails because it doesn't like the value of the pull_up_down parameter. The error message is "ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN". So I did some hacking. With the button set up using the UI on a clean system that never had any buttons set previously I see this:
Code:
master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:00:44 bounce_time=1000
2024-05-21 08:00:44 row1, pin27, enabled=1, pull=GPIO.PUD_UP, command=command
Traceback (most recent call last):
File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=btn_1_pull)
File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN
Code:
master@apollo:~ $ moodeutl -q "UPDATE cfg_gpio set pull='PUD_UP'"
Code:
master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:01:26 bounce_time=1000
2024-05-21 08:01:26 row1, pin27, enabled=1, pull=PUD_UP, command=command
Traceback (most recent call last):
File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down=btn_1_pull)
File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN
Let's see if setting the value directly in the code works:
Code:
master@apollo:~ $ sudo nano /var/www/daemon/gpio_buttons.py
GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down='PUD_UP')
master@apollo:~ $ sudo /var/www/daemon/gpio_buttons.py
2024-05-21 08:11:36 bounce_time=1000
2024-05-21 08:11:36 row1, pin27, enabled=1, pull=PUD_UP, command=command
Traceback (most recent call last):
File "/var/www/daemon/gpio_buttons.py", line 50, in <module>
GPIO.setup(btn_1_pin, GPIO.IN, pull_up_down='PUD_UP')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/RPi/GPIO/__init__.py", line 647, in setup
raise ValueError(
ValueError: Invalid value for pull_up_down - should be either PUD_OFF, PUD_UP or PUD_DOWN
This is why I'm now a manager, not a technician.
----------------
Robert
Robert