iobroker-community-adapters / ioBroker.rpi2

RPI-Monitor Adapter for ioBroker
MIT License
10 stars 12 forks source link

Can't set GPIO port as output - Raspberry 4 and 5 #167

Open sigmashig opened 6 months ago

sigmashig commented 6 months ago

Describe the bug
Raspberry 5 only. I tried to set a GPIO 16,20,21 as Output and I have got an error "Cannot setup port 16 as output: Error: EINVAL: invalid argument, write".

To Reproduce
Steps to reproduce the behavior:

  1. GPIO settings of rpi2 instance
  2. Check mark 'Enable' Type='Output, initial value 0'
  3. Save and Close
  4. See error in the log

Expected behavior
The value is set

Screenshots & Logfiles
2024-01-13 20:33:40.163 - debug: rpi2.0 (33544) Creating gpio.16.isInput 2024-01-13 20:33:40.166 - debug: rpi2.0 (33544) stateChange for rpi2.0.gpio.16.isInput found state = {"val":false,"ack":true,"ts":1705170820166,"q":0,"from":"system.adapter.rpi2.0","user":"system.user.admin","lc":1644690728905} 2024-01-13 20:33:40.184 - debug: rpi2.0 (33544) Creating gpio.20.isInput 2024-01-13 20:33:40.186 - debug: rpi2.0 (33544) stateChange for rpi2.0.gpio.20.isInput found state = {"val":false,"ack":true,"ts":1705170820186,"q":0,"from":"system.adapter.rpi2.0","user":"system.user.admin","lc":1644690729188} 2024-01-13 20:33:40.192 - debug: rpi2.0 (33544) Creating gpio.21.isInput 2024-01-13 20:33:40.194 - debug: rpi2.0 (33544) stateChange for rpi2.0.gpio.21.isInput found state = {"val":false,"ack":true,"ts":1705170820193,"q":0,"from":"system.adapter.rpi2.0","user":"system.user.admin","lc":1644690729313} 2024-01-13 20:33:40.224 - debug: rpi2.0 (33544) Inputs are pull down. 2024-01-13 20:33:40.224 - debug: rpi2.0 (33544) Buttons are pull down. 2024-01-13 20:33:40.232 - debug: rpi2.0 (33544) Port 16 direction: outlow 2024-01-13 20:33:40.232 - debug: rpi2.0 (33544) Port 16 directionCode: low 2024-01-13 20:33:40.233 - debug: rpi2.0 (33544) Port 20 direction: outlow 2024-01-13 20:33:40.233 - debug: rpi2.0 (33544) Port 20 directionCode: low 2024-01-13 20:33:40.233 - debug: rpi2.0 (33544) Port 21 direction: outlow 2024-01-13 20:33:40.233 - debug: rpi2.0 (33544) Port 21 directionCode: low 2024-01-13 20:33:40.236 - error: rpi2.0 (33544) Cannot setup port 16 as output: Error: EINVAL: invalid argument, write 2024-01-13 20:33:40.236 - error: rpi2.0 (33544) Cannot setup port 20 as output: Error: EINVAL: invalid argument, write 2024-01-13 20:33:40.237 - error: rpi2.0 (33544) Cannot setup port 21 as output: Error: EINVAL: invalid argument, write Versions:

EDIT mcm1957: Problem seems to be related to OS Version (Bookworm ++) and occures at Pi4 and Pi5.

K2ij3 commented 5 months ago

+1

I've the same issue. Node.js: v18.19.1 JS-Controller: 5.0.1.7

Sir-James-Bond commented 5 months ago

I have the same issue. Is it possible to help us? :-(

hadde1234 commented 5 months ago

I have the same. đź‘Ž

manfredgerbeth commented 4 months ago

Same for me. I guess this adapter has to be updated to the new GPIO architecture on PI5 (as all other programming librarys ) .

toon2006 commented 4 months ago

I have the same Problem. pi4 with bookworm!

innriver commented 4 months ago

I have the same Problem on pi3 and pi4 since upgrade my raspberry today!

Cannot setup port 4 as output: Error: EINVAL: invalid argument, write Cannot setup port 5 as input: Error: EINVAL: invalid argument, write

RPI-Version: 1.3.2 Node.js: Version: 18.19.1 js-controller Version: 5.0.19

Kernel on Raspberry pi4 Model B: Linux iobroker01 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux Firmware: Feb 29 2024 12:24:53 Copyright (c) 2012 Broadcom version f4e2138c2adc8f3a92a3a65939e458f11d7298ba (clean) (release) (start)

Kernel on Raspberry pi3 Model B plus Linux iobroker02 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux Firmware: Feb 29 2024 12:26:47 Copyright (c) 2012 Broadcom version f4e2138c2adc8f3a92a3a65939e458f11d7298ba (clean) (release) (start)

Please can you help me?

innriver commented 4 months ago

Please change the title if possible, as not only the Raspberry 5 is affected but also all other RPIs can no longer address the GPIOs after an OS update. Thanks

Doener92 commented 4 months ago

+1

I've the same issue. Raspberry 4B rev 1.1 Bookworm Node.js: v20.12.0 JS-Controller: 5.0.19

Does anyone have a workaround?

Doener92 commented 4 months ago

I change to Bullseye 64 bit. Know it works. There is some bug in Bookworm.

innriver commented 4 months ago

It doesn't seem to be a bug in Bookworm but a general problem with old libraries that no longer work. I found this link: https://pi-buch.info/gpio-reloaded-ii-bash/

Doener92 commented 4 months ago

You might be right. Unfortunately, I don't know enough about that. Just found out that it doesn't work with the latest version of Bookworm, but it does work fine with the latest version of Bullseye. I installed the versions from the Raspberry-PI-Imager.

Grothesk242 commented 3 months ago

It looks like the adapter would need a complete rewrite. Too many changes in the most recent versions of Raspberry OS.

PatrickZ1990 commented 3 months ago

+1 latest RaspberryOS and fresh install of ioBroker. I really need those GPIO pins working.

Apollon77 commented 3 months ago

At all the +1 posters ... Please set a thimbs up in the initial post ... this is visible about "how many users need that fix".

Other then that, according to discussions in teh forum, that might not be too easy becauseof the fundamental changes in raspi 5 GPIO chip and such. So downgrading to a Raspi 4 migth be a workaround for now

innriver commented 3 months ago

At all the +1 posters ... Please set a thimbs up in the initial post ... this is visible about "how many users need that fix".

Other then that, according to discussions in teh forum, that might not be too easy becauseof the fundamental changes in raspi 5 GPIO chip and such. So downgrading to a Raspi 4 migth be a workaround for now

Downgrade to Raspi 4 is not working with the newest Version of Bookworm!

searcher57 commented 2 months ago

Ich habe das gleiche Problem mit Raspi 4 und 5! Raspberry Pi 4 Model B Rev 1.5 nodejs v18.20.2 npm 10.5.0 js-controller: 5.0.19

Doener92 commented 2 months ago

At all the +1 posters ... Please set a thimbs up in the initial post ... this is visible about "how many users need that fix".

Other then that, according to discussions in teh forum, that might not be too easy becauseof the fundamental changes in raspi 5 GPIO chip and such. So downgrading to a Raspi 4 migth be a workaround for now

Downgrade to Raspi 4 is not working with the newest Version of Bookworm!

Try the newest version of Bullseye. It worked for my application. Only as a workaround.

mcm1957 commented 2 months ago

see https://forum.iobroker.net/topic/73566/kein-zugriff-adapter-rpi2-auf-gpio/42

dermueller98 commented 2 months ago

I have the same issue on Pi4. But reading a DHT22 on a GPIO is still working, i don't really get it. Any Idea of setting a port "manually" to input or output? Maybe reading is still working, when it is possible to configure a port manually? I don't want to setup up my hole pi again with older Version.

Garfonso commented 2 months ago

I modified the adapter to use libgpiod. If anybody wants to try, go ahead and give 2.0.0-alpha.6 a try.

I could not really test GPIO Inputs (since I seem to have destroyed my testing PI 3 and need to get a replacement for that).... I'd be interested to see if those work. Control works in Raspian Bookworm and also in Buster.

Buttons won't actually work, yet... not sure if I can add that functionality back because it depends on the deprecated library. Is this feature really in use?

To test, make sure the libgpiod-dev library is installed: sudo apt install libgpiod-dev

After that, install the beta, for example using the command line: iob upgrade rpi2@2.0.0-alpha.6

Also it seems in Raspberry 5 there are even more GPIO Chips and 0 does not seem to be the default there. So I'd love to get some input from people using Raspberry 5.

manfredgerbeth commented 2 months ago

For Raspberry 5 the GPIO Chip number 4 should work.

dermueller98 commented 2 months ago

Hi, i treid out alpha.6 on RPI4 and cant get any gpio states in objects. Using libgpiod-dev via terminal is working, but only for gpios, not configured in the adapter.

searcher57 commented 2 months ago

Hello, I tested it with two RASPI 4 and it doesn't work. The inputs are still not recognized.

searcher57 commented 2 months ago

On a RASPI 5 the inputs are not recognized either.

Garfonso commented 2 months ago

yes, it seems the node libraries handling libgpio are still struggling with GPIO input... :-( The first I tried has not implemented it at all (but it is on roadmap), the second one has a bug in it... it says it would have been fixed, but they never release the fixed version (and manually applying the fix didn't solve it for me)...

I'm still not happy about trying the third library, because it seems a bit over engineered... but probalby I'll go that way soonish...

Garfonso commented 2 months ago

Question for users of gpio output: do you expect the adapter to read the iobroker states and set the outputs accordingly? Or should the adapter do that only on trigger?

Alex08151 commented 1 month ago

Same issue with Model 3B+ bookworm 64 bit

danickel commented 1 month ago

I also have the issue. I'm using alpha.7 Reading out gpio 22 via command line returns correct value: image

Adapter returns only "(null)": image

bookworm 64-bit

Garfonso commented 1 month ago

Can you try alpha 10? I switch to (yet) another gpio library. I got gpio input working with it.

install with iob upgrade rpi2@2.0.0-alpha.10, for example.

//Edit: alpha 8 had some errors, still. Try 10.

danickel commented 1 month ago

now the value is always "false". :-( Even if read out via command line says "true"

Value doesn't change

bjoernszw commented 1 month ago

auf einem pi5 mit bookworm läuft es nach dem man diese beiden Pakete so installiert:

sudo apt install libgpiod-dev iob upgrade rpi2@2.0.0-alpha.10

dermueller98 commented 1 month ago

tested alpha 10 on RPI4, same thing as @danickel mentioned, States are alway false now. Now refresh of states at all.

Garfonso commented 1 month ago

could you try alpha.11? There was an error if inputerDebounceMs was a string.

dermueller98 commented 1 month ago

i tried alpha 11 now, but still not even a refresh of the input states. Outputs are working, i can set GPIOs correctly.

danickel commented 1 month ago

i tried alpha 11 now, but still not even a refresh of the input states. Outputs are working, i can set GPIOs correctly.

@Garfonso Thanks for the effort! But I can confirm the observations from @dermueller98 . Inputs still not refreshing

Garfonso commented 1 month ago

Yeah, I did remove the strange debounce mechanism and implemented my own (till the node bindings allow to use the one the library offers, anyway). In my simple setup it now works as reliably as my hardware gets. :smile: (alpha.12 that is)

One question came to my mind, though: Is it really so that there is no update? Or is it only very brief? Since I configure the GPIO to react to "Edge.Both" (taken from old code), it will switch to true if there is a signal and then to false again if the signal is gone.

Would you mind confirming that with debug logging? The adapter should print a debug output for every change and tell you if it ignores the change because still in debounce time or not.

Alex13280815 commented 1 month ago

Guten Morgen, im Anhang mein Log. GPIO 7,12,13,16 = Input und 19 = Output. Der Status wird aber nicht richtig ,,angezeigt"". log.txt

dermueller98 commented 1 month ago

Hi, now Inputs and outputs are working. Its like you said, there is no refresh, but changes are recognized. Thank you

danickel commented 1 month ago

Hi, I can also confirm that changes are recognized now. đź‘Ť

SMS-2018 commented 1 month ago

Hi Komischerweise funktionieren bei mir nicht alle Ein-7Ausgänge. Gibt es dafür eine Erklärung? Was ist denn die aktuelle Version? Ich habe v2.0.0-alpha.11 installiert.

Danke!

Grothesk242 commented 1 month ago

Aktuell ist 2.0.0 aus dem Beta-Kanal

Garfonso commented 1 month ago

Ja, bitte mal die 2.0.0 beta aus dem latest repository nehmen. Oder manuell installieren: iob upgrade rpi2@2.0.0. Bei der letzten alpha gab es noch einen Fehler beim debounce timer, das könnte erklären, wenn was bei den Eingängen nicht geht.

Ansonsten bitte genauer beschreiben, welche Eingänge und welche Ausgänge nicht gehen und wo da die Unterschiede / Gemeinsamkeiten sind.

SMS-2018 commented 3 weeks ago

Z.B. funktioniert GPIO 25 (RM Solarpumpe Ein/Aus), aber GPIO 27 (RM Heizungspumpe Ein/Aus) funktioniert nicht. Beide als Eingänge eingestellt. Bei GPIO 16 (Impulse vom Gaszähler) bin ich mir nicht sicher ob der funktioniert. Also eigentlich keine Unterschiede.

Ich hatte ja mein iobroker neu aufgesetzt (jetzt bookworm) und ein Backup drauf gespielt. Muss ich eventuell jetzt noch mit import RPi.GPIO as GPIO die GPIOs aktivieren? Dann noch GPIO.setmode(GPIO.BCM), da ich die GPIOs mit Nummern anspreche?

Garfonso commented 3 weeks ago

Z.B. funktioniert GPIO 25 (RM Solarpumpe Ein/Aus), aber GPIO 27 (RM Heizungspumpe Ein/Aus) funktioniert nicht. Beide als Eingänge eingestellt. Bei GPIO 16 (Impulse vom Gaszähler) bin ich mir nicht sicher ob der funktioniert. Also eigentlich keine Unterschiede.

Ist das denn jetzt die 2.0.0 beta aus dem Repository oder noch eine Alpha? Das hast du leider nicht erwähnt...

Ich hatte ja mein iobroker neu aufgesetzt (jetzt bookworm) und ein Backup drauf gespielt. Muss ich eventuell jetzt noch mit import RPi.GPIO as GPIO die GPIOs aktivieren? Dann noch GPIO.setmode(GPIO.BCM), da ich die GPIOs mit Nummern anspreche?

Keine Ahnung, wovon du da redest. Das hab ich jedenfalls auf keinem meiner PIs gemacht, egal, welches Raspian. ;-) Daher vermutlich nicht notwendig. Das klingt irgendwie nach Python... und GPIO.BCM gibt es, wenn ich das richtig erinnere, nicht mehr. Das hat auch früher der Adapter gemacht. Ist also auch damals vermutlich unnötig gewesen (wie gesagt, hab ich auch nicht gemacht).

SMS-2018 commented 3 weeks ago

v2.0.0 und so installiert iob upgrade rpi2@2.0.0

dersch81 commented 2 weeks ago

Ihr seid die Besten! Endlich brauche ich nicht mehr ĂĽber NodeRed die GPIO's umkehren und der Fehler ist nach dem heutigen Upgrade von Bookworm und iob auch weg mit 2.0.0! Meine Heizungsanlage funktioniert nun wieder.

SMS-2018 commented 2 weeks ago

welches ist denn die aktuelle Version von bookworm und wie installiert bzw. kontrolliert? Danke!