libgpiod looks like a nice API. I tried it out, but I'm rather baffled by 
the behavior. If I try to set a pin with gpioset, it turns the pin off and 
unexports it.

$ config-pin P8_44 1 # This turns P8_44 on as expected
$ gpioset gpiochip2 9=1 # Should turn on gpio2[9], i.e. P8_44, but turns it 
off.
$ config-pin P8_44 1# Now config-pin can't access the pin???
WARNING: GPIO pin not exported, cannot set direction or value!

So why does gpioset turn the pin off instead of on? This isn't specific to 
P8_44; for instance "gpioset gpiochip2 7=1" will mess up P8_46 (gpio2[7]). 
This also happens even if I don't use config-pin, so it's not config-pin 
messing things up.

Ken

On Sunday, December 2, 2018 at 7:40:51 PM UTC-8, RobertCNelson wrote:
>
>
>
> On Sun, Dec 2, 2018, 8:42 PM Ken Shirriff <[email protected] 
> <javascript:> wrote:
>
>> /sys/class/gpio/export will unexport a pin if accessed twice. Is this a 
>> bug?
>>
>> $ echo 13 > /sys/class/gpio/export
>> $ ls /sys/class/gpio/gpio13
>> active_low  device  direction  edge  label  power  subsystem  uevent  
>> value
>> $ echo 13 > /sys/class/gpio/export
>> -bash: echo: write error: Operation not permitted
>> $ ls /sys/class/gpio/gpio13
>> ls: cannot access '/sys/class/gpio/gpio13': No such file or directory
>>
>> Expected behavior: gpio13 should still be there after the second export.
>> Observed behavior: gpio13 disappears after the second export.
>>
>> This is with the latest Debian kernel (4.14.71-ti-r80).
>>
>> Is there a recommended way to export a gpio pin if it may already exist? 
>> I want to write a script to set up the pins. I could check if each pin 
>> already exists, but that's a recipe for race conditions as well as being 
>> inconvenient.
>>
>
> Don't use that interface...
>
>
> https://blog.adafruit.com/2018/12/02/update-new-gpio-interface-for-linux-user-space-gpio-character-device-api-and-libgpiod-linuxpiter/
>
> Regards,
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/4b7bf33d-7f1a-418a-b6af-07ee9076e7d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to