I got this working!

Basically I did not realize that SYSFS was more sophisticated than /
proc and actually supported file permissions.

This is basically what I did to access a GPIO from Java land.

echo "128" >/sys/class/gpio/export
echo "out" > /sys/devices/virtual/gpio/gpio128/direction
chmod 0666 /sys/devices/virtual/gpio/gpio128/value

Now you have GPIO #128 exported in sysfs, configured as an output and
accessible to your Java application.

Anything else that is accessible via sysfs can be handled in a similar
way.

NOTE: It has been pointed out to me that this is a security hole. On
the other hand, it get things working directly from Java. (the easy
way)

Enjoy!


On Dec 29, 1:58 pm, Deva R <[email protected]> wrote:
> >Do I need to use the NDK for this job?
>
> I guess so. You need a JNI, and can access sysfs from  java via the jni
> interface. Jave => JNI native => sysfs files
>
> exact same discussion for another sysfs handling 
> =>http://groups.google.com/group/android-porting/browse_thread/thread/3...
>
>
>
>
>
>
>
>
>
> On Tue, Dec 28, 2010 at 11:36 PM, A Curtis <[email protected]> wrote:
> > Hello,
>
> > I have exported some GPIOs to sysfs and now I want to manipulate them
> > from Java.
>
> > How do I do this?
>
> > new FileOutputStream("/sys/devices/virtual/gpio/gpio128/value");  //
> > throws an error
>
> > Do I need to use the NDK for this job?
>
> > TIA
>
> > --
> > unsubscribe: 
> > [email protected]<android-porting%2Bunsubscribe@ 
> > googlegroups.com>
> > website:http://groups.google.com/group/android-porting
>
> --
> Regards,
> Devawww.bittoggler.com

-- 
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting

Reply via email to