Dear Ali,
that seems to be exactly what I have been looking for!
In the meantime since I wrote this posting I did a little port of circuits_gpio to erlang,
this is working so far.
As I just saw, it uses the sysfs interface. I was not aware of the deprecation yet.
I tried the library on a RPi4, but was not very successful yet.
I can open a chip, but opening lines does not work yet on my side:
I want to use GPIO16, 20 and 21. According to gpioinfo, the offsets should be identical to the
numbers in the GPIO name:
pi@r40:~ $ gpioinfo
gpiochip0 - 58 lines:
line 0: "ID_SDA" unused input active-high
[..]
line 16: "GPIO16" unused input active-high
line 17: "GPIO17" "onewire@11" output active-high [used open-drain]
line 18: "GPIO18" unused input active-high
line 19: "GPIO19" unused input active-high
line 20: "GPIO20" unused input active-high
line 21: "GPIO21" unused input active-high
[..]
1> {ok,Chip0}=gpio:open_chip("/dev/gpiochip0").
{ok,#Ref<0.2094800486.2528772108.122490>}
2> {ok, L3} = gpio:open_lines(Chip0, [16,20,21], [output], [0,0,0], "my-application").
** exception error: bad argument
in function gpio:open_lines_nif/5
called as gpio:open_lines_nif(#Ref<0.2094800486.2528772108.122490>,
[16,20,21],
[output],
[0,0,0],
"my-application")
It seems to fail in enif_get_resource.
Have you tried the library on a Raspberry, by any chance?
If not, I could try some changes, if you have an idea…
If I use the gpiod tools, all works fine (also with gpiochip0), so the hardware seems to be fine.