Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!hc!lll-winken!scooter!neoucom!wtm From: wtm@neoucom.UUCP (Bill Mayhew) Newsgroups: comp.sys.ibm.pc Subject: Re: Determining if a printer is available Summary: Call BIOS interrupt 17H to find out Message-ID: <1555@neoucom.UUCP> Date: 28 Mar 89 20:53:56 GMT References: <2165@pembina.UUCP> Organization: Northeastern Ohio Universities College of Medicine Lines: 96 Printer operations are handled by the BIOS interrupt 17H. You should use the interrupt to access the printer, as there are a number of packages that daisy-chain into INT 17H for redirecting output to file file, serial port, etc. If you play by the book, you can be a good citizen and work with any TSR programs that might be hanging around. Don't bother with the printer table at 0040:08H. Another reason to use the BIOS is that on AT machines it calls the BIOS time-out via INT 15 as per "multitasking provisions". Here is a short example program written in Turbo C. It should be relatively portable, as virtually all C compilers have some function for generating a software interrupt. Note that when a printer is plugged in, turned on, and ready to go, you will get a return code that indicates (Not busy | Selected). If the printer is switched off or not attached to the port, you'll get return values that vary from clone-to-clone, the main thing is that they will NOT be (Not busy | Selected). Here is a description of INT 17H summarized from the "IBM Personal System/2(tm) and Personal Computer BIOS Interface Technical Reference" pp 2-111 , 2-112: INT 17H printer on entry: AH=00 print character AH=01 initialize printer port AH=02 read status AH=03 to FF reserved AH=00, AL=ascii char, DX=port number 0,1,2 on return: AH=status bit 7=1 not busy bit 6=1 acknowledge bit 5=1 out of paper bit 4=1 selected bit 3=1 i/o error bit 2,1 (reserved) bit 0=1 time-out AH=01, DX=port number 0,1,2 on return: AH=status same as above AH=02, DX=port number 0,1,2 on return: AH=status same as above ---------------------------- cut here ------------------------- #include #include void main() { struct REGPACK preg; int mask=1; printf("Enter number of LPT port for status check: "); scanf("%d",&preg.r_dx); preg.r_dx = --preg.r_dx & 0xff; preg.r_ax=0x0200; intr(0x17,&preg); printf("\nPort returns the following status:\n"); while (mask<256) { switch(preg.r_ax>>8 & mask) { case 0x80: printf("\tNot busy\n"); break; case 0x40: printf("\tAcknowledge\n"); break; case 0x20: printf("\tOut of paper\n"); break; case 0x10: printf("\tSelected\n"); break; case 0x08: printf("\tI/O Error\n"); break; case 0x01: printf("\tTime-out\n"); } mask*=2; } } /* end of main */ ---------------------------------------------------------------- Bill wtm@impulse.UUCP or wtm@neoucom.UUCP