[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-newbie
Subject:    Re: devfs Gpio and interrupt
From:       Mancausoft <andreamilazzo () mancausoft ! org>
Date:       2011-03-22 15:01:45
Message-ID: 20110322150145.GA14798 () homer
[Download RAW message or body]

On 15:22 Wed 09 Feb     , Mancausoft wrote:
> I read gpio.txt in Documentation of kernel and try to use it.
> pfd.fd = open("/root/tasto1/value", O_RDONLY);
> pfd.events = POLLPRI | POLLERR; 
> 
> //ready = poll(&pfd, 1, -1); 
> ready = poll(&pfd, 1, 100000); 
> 
> lseek (pfd.fd, 0, SEEK_SET);
> 
> val = read(pfd.fd, buf, 254);
> //the output are: 1, 10, 10
> printf ("%d, %d, %d\n", ready, pfd.revents, pfd.events);
> 
> printf ("%d, %s\n", val, buf );
> 
> close(pfd.fd);
> 
> But it don't wait for an edge but they exit immediatly. 
> Why? where is the problem?

My Bad!

now work:

pfd.fd = open("/root/ledverde/value", O_RDWR );
while (1)
{
pfd.events =  POLLPRI | POLLERR; // | POLLWRBAND;

lseek (pfd.fd, 0, SEEK_SET);

val = read(pfd.fd, buf, 254);
buf[val] = 0;
//printf ("%d, %s\n", val, buf );

ready = poll(&pfd, 1, -1);
printf("%d\n", ++i);
}


-- 
Mancausoft - http://www.mancausoft.org/
GPG key: B53F90F2

["signature.asc" (application/pgp-signature)]
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic