On Thu, 2004-04-15 14:08:54 -0600, Xu, Jiang <Jiang.Xu@echostar.com>
wrote in message
> Thanks for the reply, I did some testing and found some interesting things:
> 1. Everytime I push the key on the keyboard, I can see something out from
> /dev/input/event0 by "cat /dev/input/event0".
> However, I don't see a directory named "proc/input", did I miss configure
> something in the kernel?
Maybe your kernel isn't configured with CONFIG_PROC_FS=y ?
Maybe it's not mounted?
> 2. read() does work and is a blocking read. However, if I use select, then
> it does not work.
> Select() never detects the state change.
> Here is the sample code I am using:
> int test_fd = -1;
No need to initialize - you're assigning a value before accessing it.
> fd_set rfds;
> struct timeval tv;
> tv.tv_sec = 1;
> tv.tv_usec = 0;
tv_* need to be set before *every* select () invocation, not only once.
> test_fd = open("/dev/input/event0", O_RDONLY);
> if( test_fd < 0 )
> while( 1 )
> FD_SET(test_fd, &rfds);
> retval = select( 1, &rfds, NULL, NULL, &tv );
That's wrong. The "1" should be "fd + 1".
> if( retval )
> printf("\nDetects something....");
A negative retval would also be != 0 ...
> What could be wrong?
Most probably it's the hardcoded "1" with the select. That is, select
only looks at all fd's which are smaller than one, so only fd=0 would be
testes, but this one isn't in the set, so...
Jan-Benedict Glaw firstname.lastname@example.org . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak!
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
Description: Digital signature