Getting Printer Status 
Author Message
 Getting Printer Status

Hello to ALL,

What is the best way to get information/Status on a printer? I've been
trying to use Interrupts, but...I can't figure out how to break down
what I get in AH.

Bitfields for printer status: Returned in AH
Bit(s)  Description     (Table 0548)                                            
 7      not busy                                                                
 6      acknowledge                                                            
 5      out of paper                                                            
 4      selected                                                                
 3      I/O error                                                              
 2-1    unused                                                                  
 0      timeout                                                                

Some test code.

'$INCLUDE: 'qbx.bi'

DIM regs AS RegType

regs.ax = &H2
regs.dx = &H0

CALL interrupt(&H17, regs, regs)

Status% = regs.ax AND &HFF    ' returns in AH

CLS

PRINT "Status is -"; Status%

    With just the Printer ON this returns 2 as an answer. Not useful.
I suppose I could recreate Ethan Winers PeekWord, and PokeWord,
but...was wondering if anyone had figured out how to break down what is
returned in AH into bits.

Thanks for your help.


.                       http://www.*-*-*.com/ ~ppridgen
*SignIt 2.0 #001*
---
 t SPEED 2.00 #2289 t It consoles me that Einstein made mistakes.

-----------------------------------------------------------------------------

This message was processed by Software Valley Information System
-----------------------------------------------------------------------------



Sat, 01 Apr 2000 03:00:00 GMT  
 Getting Printer Status


writes

Quote:
>I can't figure out how to break down
>what I get in AH.

>Bitfields for printer status: Returned in AH
>Bit(s)  Description     (Table 0548)                                            
> 7      not busy                                                                
> 6      acknowledge                                                            
> 5      out of paper                                                            
> 4      selected                                                                
> 3      I/O error                                                              
> 2-1    unused                                                                  
> 0      timeout                                                                

Her you are:

IF AH AND 1 THEN REM TIMEOUT
IF AH AND 8 THEN REM I/O ERROR
IF AH AND 16 THEN REM SELECTED
IF AH AND 32 THEN REM OUT OF PAPER
IF AH AND 64 THEN REM ACKNOWLEDGE IF YOU'RE LUCKY
IF AH AND 128 THEN REM NOT BUSY

--
Peter Hesketh, Mynyddbach, Gwent, UK
"Sex is not the answer.   Sex is the question.  Yes is the answer."



Mon, 03 Apr 2000 03:00:00 GMT  
 Getting Printer Status

Quote:

>What is the best way to get information/Status on a printer? I've been
>trying to use Interrupts, but...I can't figure out how to break down
>what I get in AH.

The following may not be the best way, but it works if Windows doesn't get
in the way.  You'll have to tailor the IFs to make the responses more
meaningful.

DIM padd AS INTEGER, pstat AS INTEGER
CONST BIT7 = &H80, BIT5 = &H20, BIT4 = &H10, BIT3 = &H8
CLS
DEF SEG = &H40                      'status table
padd = PEEK(9) * 256 + PEEK(8)      'port address
DEF SEG
pstat = INP(padd + 1)               'read status - address + 1
IF (pstat AND BIT7) = 0 THEN
PRINT "Printer is busy - printing, off line or jammed!"
END IF
IF (pstat AND BIT5) = 1 THEN
PRINT "Out of paper!"
END IF
IF (pstat AND BIT4) = 0 THEN
PRINT "Printer off line!"
END IF
IF (pstat AND BIT3) = 0 THEN
PRINT "Printer error or jammed!"
END IF

Quote:
>Bitfields for printer status: Returned in AH
>Bit(s)  Description     (Table 0548)                                        
> 7      not busy                                                            
> 6      acknowledge                                                          
> 5      out of paper                                                        
> 4      selected                                                            
> 3      I/O error                                                            
> 2-1    unused                                                              
> 0      timeout                                                              
>Some test code.
>'$INCLUDE: 'qbx.bi'
>DIM regs AS RegType
>regs.ax = &H2
>regs.dx = &H0
>CALL interrupt(&H17, regs, regs)
>Status% = regs.ax AND &HFF    ' returns in AH
>CLS
>PRINT "Status is -"; Status%

>    With just the Printer ON this returns 2 as an answer. Not useful.
>I suppose I could recreate Ethan Winers PeekWord, and PokeWord,
>but...was wondering if anyone had figured out how to break down what is
>returned in AH into bits.



Mon, 03 Apr 2000 03:00:00 GMT  
 Getting Printer Status



Quote:

> What is the best way to get information/Status on a printer? I've been
> trying to use Interrupts, but...I can't figure out how to break down
> what I get in AH.

> Bitfields for printer status: Returned in AH
> Bit(s)  Description     (Table 0548)                                    
>  7      not busy                                                        
>  6      acknowledge                                                      
>  5      out of paper                                                    
>  4      selected                                                        
>  3      I/O error                                                        
>  2-1    unused                                                          
>  0      timeout                                                          

>     With just the Printer ON this returns 2 as an answer. Not useful.
> I suppose I could recreate Ethan Winers PeekWord, and PokeWord,
> but...was wondering if anyone had figured out how to break down what is
> returned in AH into bits.

This is what the logical bit operators are for.  Taking your table above,
and adding the actual values of the individual bits, we get this table:

 Bit(s)  Description   Decimal  Hex   Binary
  7      not busy        128     80  10000000
  6      acknowledge      64     40  01000000
  5      out of paper     32     20  00100000
  4      selected         16     10  00010000
  3      I/O error         8      8  00001000
  2      unused            4      4  00000100
  1      unused            2      2  00000010
  0      timeout           1      1  00000001

To test or extract a bit or bits, use the 'AND' operator with a mask of the
bits you want to.  You are already doing this to extract the low order 8
bits (called AL, not AH) from the AX register with this instruction:

Quote:
> Status% = regs.ax AND &HFF    ' returns in AL

To test the out of paper status, for example, you can code this:

  IF (Status% AND &H20) THEN ...
     - or -
  IF (Status% AND 32) THEN ...

You will get a true condition if the out of paper bit is 1, false
otherwise.

To test for out of paper status or I/O error simultaneously, code this:

  IF (Status% AND (&H20 OR &H8)) THEN ...
     - or -
  IF (Status% AND &H28) THEN ...
     - or -
  IF (Status% AND 40) THEN ...

You will get a true if either bit is on, otherwise false.

You can extract a bit or bits into another variable like this:

  OutOfPaper% = Status% AND &H20

OutOfPaper% = 32 if the out of paper bit was set, otherwise 0.

  OutOfPaper% = Status% AND (&H20 OR &H8)
     - or -
  OutOfPaper% = Status% AND &H28

OutOfPaper% = 32 if the out of paper bit was set, otherwise 0.

To 'turn on' a bit, use 'OR' like this:

  Result% = Result% OR &H20

This will 'turn on' bit 5 in Result%, leaving the other bits unchanged.

You can 'toggle' a bit with XOR (eXclusive OR) like this:

  Result% = Result% XOR &H20

This will 'toggle' the value of bit 5 in Result%.  0 -> 1, 1 -> 0
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove zzz from email id to respond)



Mon, 03 Apr 2000 03:00:00 GMT  
 Getting Printer Status

Quote:

>Hello to ALL,

>What is the best way to get information/Status on a printer? I've been
>trying to use Interrupts, but...I can't figure out how to break down
>what I get in AH.

Here's a little function (for powerbasic) that works. You MAY, however, wish
to put the test in a loop as some of systems have a tendency to report all
kinds of {*filter*}the first few passes.

There is no reason to parse AH before the test.

FUNCTION fLPTready%( LptNo% )

  REG %AX, &h0200
  REG %CX, &h0064
  REG %DX, LptNo%
  CALL INTERRUPT &h17

  IF ( REG(%AX) AND &b1001000000000000 ) THEN fLPTready% = -1

END FUNCTION

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|

     www.basicguru.com/schullian



Tue, 04 Apr 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. getting printer status

2. GETTING PRINTER STATUS

3. Getting Printer Status

4. Getting printer status from 95

5. Getting Printer Status

6. Getting printer status with VB 5.0 (SP3)

7. Getting Printer Status

8. Getting status of Printer

9. Getting network printer status

10. ?printer status of LAN printer

11. Printer - Printer Status

12. Q: Forcing Printer Paper bins / Getting List Per Printer

 

 
Powered by phpBB® Forum Software