Re: poll or select for ppi?
In message: [EMAIL PROTECTED] Matt Kory [EMAIL PROTECTED] 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 = 10; : : 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 ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
poll or select for ppi?
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 = 10; while(1) { FD_ZERO( rfds ); FD_SET( ppi_fd, rfds ); if ( select(1, rfds, NULL, NULL, tv) ) { printf(hi\n); } } ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: poll or select for ppi?
On Tue, 15 Mar 2005 13:35, Matt Kory wrote: 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. PPI doesn't support select/poll. I don't think ere is any support for interrupt based notifications.. The only thing interrupts appear to be used for is for IEE1284 state changes. ie you're stuck with polling :( -- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au The nice thing about standards is that there are so many of them to choose from. -- Andrew Tanenbaum GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C pgpd8dWRD2quR.pgp Description: PGP signature
Re: poll or select for ppi?
On Mon, Mar 14, 2005 at 10:05:34PM -0500, Matt Kory wrote: 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. Disclaimer: I'm no expert on the parallel port. The man page for ppi(4) says that all I/O is via ioctl(), which isn't covered by the select() mechanism. You'd either have to poll PPIGSTATUS from userland on a timer, or perhaps hack the driver to use a kevent. Considering there's probably no way to get a hardware interrupt for the status change directly via ppi(4), you might need to consider writing a set of custom ppbus microsequences and a driver for your application. Regards, BMS ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]