Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

MRAA on Galileo Gen 2 output

James_N_1
Beginner
955 Views

Hi,

I'm using the IOTDK Eclipse IDE to compile a C program using the MRAA.  I'm trying to do a basic read to see if the Arduino pins are high or low, this program in particular looks at pin 8 and sends the output to stdout. I'm basing my program off of this: http://iotdk.intel.com/docs/master/mraa/gpio_8h.html

#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "mraa/gpio.h"

int main(int argc, char **argv)
{
    mraa_gpio_context gpio8;
    gpio8=mraa_gpio_init(8);
    mraa_gpio_dir(gpio8, MRAA_GPIO_IN);
    for (;;) {
        fprintf(stdout, "The value of pin 8 is: %d\n", gpio8);
        sleep(1);
    }

I'm getting the following output:

The value of pin 8 is: 143212968
The value of pin 8 is: 143212968

... and so on. What does this integer mean, and how do I determine if this is high or low? Thanks!

 

 

0 Kudos
1 Solution
Brian_B_Intel
Employee
955 Views

Hi Jim. 

That integer looks to be the memory location of the gpio8 structure. I think you need to read the pin value with:

fprintf(stdout, "The value of pin 8 is %d\n", mraa_gpio_read(gpio8));

See http://iotdk.intel.com/docs/master/mraa/gpio_8h.html

Brian

View solution in original post

0 Kudos
4 Replies
Matthias_H_Intel
Employee
955 Views

not answering your question but in general:

which platform are you on?

have you latest MRAA running on your target?

0 Kudos
James_N_1
Beginner
955 Views

I'm on the galileo gen 2 running the latest iotdk image.  I've done a board firmware upgrade via the arduino console (not related im guessing) and also run opkg update and opkg upgrade, so not really sure what version of mraa.  I would just use the arduino ide, but I'd like to export the data into a JSON and send that out, so I figured a C or python script would do the trick best?

Thanks for the interest,

Jim

0 Kudos
Brian_B_Intel
Employee
956 Views

Hi Jim. 

That integer looks to be the memory location of the gpio8 structure. I think you need to read the pin value with:

fprintf(stdout, "The value of pin 8 is %d\n", mraa_gpio_read(gpio8));

See http://iotdk.intel.com/docs/master/mraa/gpio_8h.html

Brian

0 Kudos
James_N_1
Beginner
955 Views

That makes a lot of sense, I should've seen that lol.

That's definitely what was wrong with it, I simply changed that line and voila. Thanks, Brian!

0 Kudos
Reply