Re: devfs Gpio and interrupt
Mancausoft <[email protected]>
| Newsgroups | gmane.linux.newbie |
|---|---|
| Message-ID | <20110322150145.GA14798@homer> |
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, 198 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk2IudkACgkQ2D/gwrU/kPIYDwCeMOIvr8loOsDmyI5hkkWdCVIj x6QAn3WtQgvl7viL7vAUPcnbOXY4u2ux =4uTn -----END PGP SIGNATURE-----