Hi Nick,

On Wed, Dec 7, 2011 at 2:44 AM, Nick Starzicki <nick2501@gmail.com> wrote:
Works great. Was able to both use ports as input and output.
I just have two more questions:
1) I was able to control the ports via command line, but I need to be able to get the readings in such a way that I can check them while running my code. Meaning I need to know how to refer to them from a cpp file, since I need an "if" statement to determine the ports' value. How can this be done?

Well, when you do:

cat /sys/class/gpio/gpio146/value

In C or C++ you'd open the file /sys/class/gpio/gpio146/value and read it like a text file. You'll get back a string 0 or 1 followed by a newline.


echo 146 > /sys/class/gpio/export

is just open the file and write the string 146 followed by a newline to file.

2) I might also need in addition to this, a UART interface. Is this possible somehow? Even though the serial port exists, I read in many places that it is only possible to use it for getting access of the command line and not for UART. I basically need to connect a compass to the gumstix as well.

This page covers using the serial port programmatically:

I have a little test program I wrote called sertest:

It reads from stdin and sends to the serial port you open. And sends data received from the serial port to stdout.

Dave Hylands
Shuswap, BC, Canada