/*********** * * lptwait2.c monitors the lpt1 port and waits for a change * * Short between ground (db25 #18-25 or centronics #19-30 * and: * #10 NACK * #11 BUSY * #12 Paper Out * #13 SELECT * #15/32 ERROR */ #include /* Contains the prototype for inportb */ #include /* Contains the prototype for printf */ #include int main(void) { long int li_iterations; int a,old; uclock_t start; printf("\ # lptwait2.c - monitors a PCs lpt1 \n\ # Dave Forrest drf5n@virginia.edu 1/11/98\n\ # compiled with GNU's gcc\n\ # source available at http://mug.sys.virginia.edu/~drf5n/extras\n\ # See also http://www.geocities.com/SiliconValley/Bay/8302/parallel.htm\n\ # or http://www.senet.com.au/~cpeacock/pdebug.htm\n\ # for help\n\ # try Centronics printer cable pin #19 with 10,11,12,13, or 32 \n\ # or DB-25 pin 18 with 10,11,12,13, or 15\n\ "); old = inportb(0x378 + 1); /* Gets input from Status Port in byte form. */ printf("# lpt1 port status (0x378+1): %d \n",old); /* Prints byte value to screen in */ start = uclock(); while( a=inportb(0x378+1), a == old) { ; } printf ("%lf secs > %d (+-%lf)\n", (double)uclock()/(double)UCLOCKS_PER_SEC,a, 1/(double)UCLOCKS_PER_SEC); return 0; }