networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
2.06k stars 349 forks source link

genericups but over GPIO? #839

Open dogtopus opened 4 years ago

dogtopus commented 4 years ago

It would be nice to support this so devices without a full RS232 port but has GPIO pins like Raspberry Pi could use genericups driver directly without a e.g. FTDI cable.

jimklimov commented 3 years ago

For Raspberry Pi in particular, there is a PiJuice HAT driver (GPIO/i2c) merged recently with #730

We also have one other i2c driver it seems (asem)

Otherwise, lacking the hardware to test at least some use-cases (including UPS-like hardware that has GPIO interface) I'm afraid I can only say "PRs welcome" :\

dogtopus commented 3 years ago

including UPS-like hardware that has GPIO interface

Well that would probably be the "next step". What I have in mind only applies to contact closure type UPSes. Basically if they have open-drain-like output (like using relays) then it could be possible to use GPIO input pins with pull-up resistors instead of RS232 flow control pins to at least receive the status signals from those UPSes.

clepple commented 3 years ago

@dogtopus I think what Jim is getting at is that he doesn't have the hardware available (either a contact-closure UPS or something similar that uses GPIO) to test such a driver, were he to write it.

I have a SleepyPi that I am mostly using for the RTC, but it could probably be a good testbed for a GPIO driver: https://spellfoundry.com/docs/getting-the-sleepy-pi-to-shutdown-the-raspberry-pi/

That said, my time is fairly limited at the moment, and I don't want to give the impression that I can work on this until at least after we get all of the existing code tested for the next NUT release.

(Someone who is decent at Arduino coding could probably whip up something quickly for the SleepyPi CPU that talks to one of the existing NUT drivers like nutdrv_qx over serial.)

clepple commented 3 years ago

Notes for future self, or someone else who has time to look at this now:

https://www.acmesystems.it/gpiod says "Since linux 4.8 the GPIO sysfs interface is deprecated."