In comp.sys.raspberry-pi, wrote:
> I am a new user/programmer for the Raspberry Pi.
> I have found a pwm program in python that dims and brights
> an led. I have also found a program in C that does the
> same thing - when run as sudo.
>
> When I exit the C program, the led stays lit.
> I have a program in python that clears up the bus using GPIO.cleanup()
>
> This works fine, and turns the led off, etc.
>
> I am trying to write/find an equivalent program in C that
> will cleanup the gpio the same way.
As I recall it is all done by manipulating files under
/sys/class/gpio/. My rough recollection is you find a directory named
for you GPIO chip, look for an "export" file in there and then tell the
system which pins you want for what (eg, input or output) by writing
to that file. Thereupon the system creates a new file to read/write
to that connects with that pin. The cleanup step involves writing to the
"unexport" file.
There are standard Unix file permission issues involved in reading /
writing to the /sys/... files. Check the group ownership and your
group membership.
The are some finnicky things like the pin numbers are completely
different in different places. The pin number on the board is not the
pin number for the export/unexport file. And the pin numbers in the
python libraries are not the same as the pin numbers in either (IIRC).
I loathe python, so I hate that all of the GPIO guides seem to be
written using the python libraries.
Elijah
------
did some Perl GPIO stuff a few years ago
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|