Delete comment from: Ken Shirriff's blog
Many thanks for your post!
I tried the code in [2] and it worked fine.
Problems came up when I tried to go a little further, trying to read from a push button connected (properly!) on the same IO (set as direction:in).
I manage to catch the button's state by "cat /sys/class/gpio/gpio49/value" (I get 0 if not pushed and 1 if pushed).
Then I tried to use read() and I couldn't manage to catch the value with this code:
//----------------------------
int fd = open("/sys/class/gpio/gpio49/value",O_RDONLY);
printf("fd:%d\n",fd);
int* pbtn;
int btn;
int tmp;
// while(1)
{
tmp=read(fd,(void*)pbtn,1);
btn=*pbtn;
printf("%d\n",tmp);
printf("%x\n",btn);
if (btn==1)
{
printf("Button pressed!\n");
}
}
//----------------------------
All I have is:
fd:4
-1
4f0b00f0
Any idea? (at least I hope I didn't do any stupid thing in C...)
Thanks again!
Jun 29, 2017, 6:08:59 PM
Posted to The BeagleBone's I/O pins: inside the software stack that makes them work

