Date: Tue, 15 Mar 2005 15:41:52 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: uber.caulker@gmail.com Cc: freebsd-hackers@freebsd.org Subject: Re: poll or select for ppi? Message-ID: <20050315.154152.25159739.imp@bsdimp.com> In-Reply-To: <5e52cc0005031419056fdf10c6@mail.gmail.com> References: <5e52cc0005031419056fdf10c6@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <5e52cc0005031419056fdf10c6@mail.gmail.com> Matt Kory <uber.caulker@gmail.com> writes: : Is it possible to use poll or select to detect a change in the status : bits of the parallel port? I tried something like this, and took bits : 5 and 6 of the status register low and nothing seemed to happen. Is : what I am trying to do even possible, or I am supposed to take a : certain bit low to cause a read event? Any help is appreciated. : : int ppi_fd; : char port[] = "/dev/ppi0"; : ppi_fd = open(port, O_RDWR); : : fd_set rfds; : struct timeval tv; : tv.tv_sec = 0; : tv.tv_usec = 100000; : : while(1) { : FD_ZERO( &rfds ); : FD_SET( ppi_fd, &rfds ); : if ( select(1, &rfds, NULL, NULL, &tv) ) { : printf("hi\n"); : } : } With the driver, as written: No. You can't poll(2). You can ask the device often if something has changed yet. However, it would be relatively simple to add a read channel and poll support. I've written several custom drivers that do things based on parallel port interrupts... Such drivers aren't that hard. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050315.154152.25159739.imp>