Closed vesley closed 6 years ago
This is technically expected behavior. The first time you export and open a GPIO, the direction defaults to in
.
I'm presuming you want to preserve the output direction and state, so one easy workaround is to check and update the direction to out
after opening it with preserve
:
local gpio_10 = GPIO(10, "preserve")
if gpio_10.direction ~= "out" then
gpio_10.direction = "out"
end
Let me know if you run into any more issues.
Following command is not working on a raspberry pi zero:
local gpio_10 = GPIO(10, "preserve")
Following error is thrown:
But when I open the pin 10 with "out" for the first time, I can open it after that with "preserve" without any error. The lua script is executed from a nginx web server, using the libnginx_mod_http_lua module with the user www-data. The user www-data belongs to the gpio group.
Here is the lua code: