public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
From: Mancausoft <andreamilazzo@mancausoft.org>
To: linux-newbie@vger.kernel.org
Subject: Re: devfs Gpio and interrupt
Date: Tue, 22 Mar 2011 16:01:45 +0100	[thread overview]
Message-ID: <20110322150145.GA14798@homer> (raw)
In-Reply-To: <20110209142230.GB10103@homer>

[-- Attachment #1: Type: text/plain, Size: 966 bytes --]

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      reply	other threads:[~2011-03-22 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09 14:22 devfs Gpio and interrupt Mancausoft
2011-03-22 15:01 ` Mancausoft [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110322150145.GA14798@homer \
    --to=andreamilazzo@mancausoft.org \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox