Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!oliveb!pyramid!ctnews!starfish!cdold From: cdold@starfish.Convergent.COM (Clarence Dold) Newsgroups: comp.sys.ibm.pc Subject: Re: Determining if a printer is available Message-ID: <979@starfish.Convergent.COM> Date: 29 Mar 89 19:12:24 GMT References: <42@datcon.UUCP> Organization: Convergent Technologies, San Jose, CA Lines: 79 From article <42@datcon.UUCP>, by sar@datcon.UUCP (Simon A Reap): > In article <7730@pyr.gatech.EDU> curci@stat.fsu.edu (Ray Curci (scri)) writes: >>In article <2165@pembina.UUCP> lake@alberta.UUCP (Robert Lake) writes: >>>I am trying to determine if a line printer is attached to my PC. I am > But beware: as far as I can see, even hacking as assembler, there's no > way to differentiate between an on-line paper-full printer all ready to > roll out your pearls, and a printer that's just powered OFF :-) (sure On my AT-Clone, with an Epson RX-80, I find that status truly boils down to three bits: NOT_BUSY, PAPER_OUT, and IOERR We could say that there are six states for the printer: 1- No Printer I/O Card 0x00 2- Printer not connected 0x30 3- Printer Off 0x98 4- Printer Offline 0x18 5- Printer Out of Paper 0xb0 Offline and out of paper 0x38 6- Online and ready. 0x90 In each case, BIOS INT 0x17, ah=2 returns ^ I didn't bother with checking if BUSY was really BUSY with a print task, since we were talking about a 'pre-print' on-line check. I also don't know how shared printer usage affects the return. I suspect that it would give 'off line' in either case. /* for QuickC, CADold cdold@tsdold.Convergent.COM */ #include #include union REGS regs; #define PRT_BIOS 0x17 #define PRT_STAT 0x02 #define PRT_PORT 0x00 #define NOTBUSY 0x80 #define PAPER_OUT 0x20 #define IOERR 0x08 main() { int prt_stat, retstat=1; regs.h.ah = PRT_STAT; regs.x.dx = PRT_PORT; int86(PRT_BIOS, ®s, ®s); prt_stat=regs.h.ah; printf("Port Status: %x\n", prt_stat ); switch(prt_stat & ( NOTBUSY | PAPER_OUT | IOERR) ) { /* masking off unintelligent bits */ case 0x00: printf("No Printer Port\n"); break; case 0x08: printf("Printer is Offline\n"); break; case 0x20: printf("Printer is not connected\n"); break; case 0x28: case 0xa0: printf("Printer is Out of Paper\n"); break; case 0x80: printf("Printer is Online and Ready\n"); retstat=0; break; case 0x88: printf("Printer is Turned Off\n"); break; } void exit(retstat); } /* end of main */ -- --- Clarence A Dold - cdold@starfish.Convergent.COM (408) 434-5293 ...pyramid!ctnews!tsdold!dold P.O.Box 6685, San Jose, CA 95150-6685 MS#10-007