Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re^14: Controlling USB on Raspberry Piby afoken (Chancellor) |
on Dec 13, 2020 at 21:33 UTC ( [id://11125142]=note: print w/replies, xml ) | Need Help?? |
There's a definition issue on read_file but that is unused so I have commented it out to test it. Yes, it's missing my $fn=shift; as the first line of read_file(). As I wrote: untested. As I expected, but cannot explain, your code works as expected provided the GPIO is already exported. Your export code doesn't work and fails with Could not open /sys/class/gpio/gpio20/direction: Permission denied at afoken.pl line 12. I have burried my spare Raspi unter tons of stuff, so I can't reproduce that at the moment. But I have two ideas why that happens:
I just had a look at the source code of the daemon mentioned in Re^12: Controlling USB on Raspberry Pi. It runs as root, so permission checks are effectively off. The source code does write a lot of debug output, so there is definitively a delay between exporting and setting direction. Alexander
-- Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom
|
|