/*********** * * lptbusy.c monitors the lpt1 busy pin * (#11 on db25 and centronics for state * changes and reports the times * * */ #include /* Contains the prototype for inportb */ #include /* Contains the prototype for printf */ #include #define MAXEVENTS 1000 #define MAXITERATIONS 5600000 int main(void) { long int li_iterations; int a,old,i,j; uclock_t time, timeout, data[MAXEVENTS+1]; a = inportb(0x378 + 1); /* Gets input from Status Port in byte form. */ printf("\ # lptbusy.c - monitors a PCs lpt1 pin 11 (BUSY)\n\ # for about 10 seconds or 1000 state changes\n\ # then prints a report to stdout.\n\ # You can short a ground pin to 11 for a signal. \n\ # Dave Forrest drf5n@virginia.edu 1/11/98\n\ # source available at http://mug.sys.virginia.edu/~drf5n/extras\n\ # See also http://www.geocities.com/SiliconValley/Bay/8302/parallel.htm\n\ "); printf("# lpt1 port status (0x378+1): %d bit 7 (128) is BUSY\n",a); /* Prints byte value to screen in */ i=0; old = inportb(0x378+1) & 128; time = uclock(); li_iterations = 0; while( (i < MAXEVENTS)&& (li_iterations < MAXITERATIONS)) { li_iterations++; a = inportb(0x378+1)&128; if ( a != old) { data[i++]= time = uclock(); old = a; } } time = uclock(); printf ("# Done!\n %ld iterations in %lf secs", li_iterations, (double)time/(double)UCLOCKS_PER_SEC); printf ("# Done!\n\n Cycle Open / close\n"); for (j=0; j