Hi Dave
Thanks for the response
1) I know there is the possibility of opening files, but I meant if there is a way of adding some include and having built in functions. Then I found some "GPIO Interfaces" txt file on the GPIO wiki. I saw there something to do with a header file and some c functions, or as it seems. Haven't gone over them yet, but will soon.
2) I may not have asked my question correctly. Regarding the UART I was really meaning to ask if the serial lines (which I now see are pins 9 and 10 I think) are the UART pins, and if they have to do with the serial console port (usb port for communication with the comp and getting a command line). Because if the are the same lines then it won't be possible to use UART and command line at the same time?

On 7 December 2011 18:15, Dave Hylands <dhylands@gmail.com> wrote:
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

Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
gumstix-users mailing list