gnu.io
Class LPRPort

java.lang.Object
  extended bygnu.io.CommPort
      extended bygnu.io.ParallelPort
          extended bygnu.io.LPRPort

final class LPRPort
extends ParallelPort

LPRPort


Nested Class Summary
(package private)  class LPRPort.MonitorThread
           
(package private)  class LPRPort.ParallelInputStream
          Inner class for ParallelInputStream
(package private)  class LPRPort.ParallelOutputStream
          Inner class for ParallelOutputStream
 
Field Summary
private static boolean debug
           
private  int fd
          File descriptor
private  LPRPort.ParallelInputStream in
          Input stream
private  int lprmode
          return current mode LPT_MODE_SPP, LPT_MODE_PS2, LPT_MODE_EPP, or LPT_MODE_ECP
private  LPRPort.MonitorThread monThread
          Thread to monitor data
private  LPRPort.ParallelOutputStream out
          Output stream
private  ParallelPortEventListener PPEventListener
          Parallel Port Event listener
private  int threshold
          Receive threshold control
private  int timeout
          Receive timeout control
 
Fields inherited from class gnu.io.ParallelPort
LPT_MODE_ANY, LPT_MODE_ECP, LPT_MODE_EPP, LPT_MODE_NIBBLE, LPT_MODE_PS2, LPT_MODE_SPP
 
Fields inherited from class gnu.io.CommPort
name
 
Constructor Summary
LPRPort(java.lang.String name)
          Open the named port
 
Method Summary
 void addEventListener(ParallelPortEventListener lsnr)
          Add an event listener
 boolean checkMonitorThread()
           
 void close()
           
 void disableReceiveFraming()
           
 void disableReceiveThreshold()
           
 void disableReceiveTimeout()
           
protected  void drain()
           
 void enableReceiveFraming(int f)
          Receive framing control
 void enableReceiveThreshold(int t)
           
 void enableReceiveTimeout(int t)
           
(package private)  void eventLoop()
          Process ParallelPortEvents
protected  void finalize()
          Finalize the port
 int getInputBufferSize()
           
 java.io.InputStream getInputStream()
           
 int getMode()
           
 int getOutputBufferFree()
           
 int getOutputBufferSize()
           
 java.io.OutputStream getOutputStream()
           
 int getReceiveFramingByte()
           
 int getReceiveThreshold()
           
 int getReceiveTimeout()
           
private static void Initialize()
          Initialize the native library
 boolean isPaperOut()
           
 boolean isPrinterBusy()
           
 boolean isPrinterError()
           
 boolean isPrinterSelected()
           
 boolean isPrinterTimedOut()
           
 boolean isReceiveFramingEnabled()
           
 boolean isReceiveThresholdEnabled()
           
 boolean isReceiveTimeoutEnabled()
           
protected  int nativeavailable()
          LPRPort read methods
private  void nativeClose()
          Close the port
 void notifyOnBuffer(boolean enable)
           
 void notifyOnError(boolean enable)
          Note: these have to be separate boolean flags because the ParallelPortEvent constants are NOT bit-flags, they are just defined as integers from 1 to 10 -DPL
private  int open(java.lang.String name)
           
protected  int readArray(byte[] b, int off, int len)
           
protected  int readByte()
           
 void removeEventListener()
          Remove the parallel port event listener
 void restart()
           
 boolean sendEvent(int event, boolean state)
           
 void setInputBufferSize(int size)
          Input/output buffers These are native stubs...
 boolean setLPRMode(int mode)
           
 int setMode(int mode)
           
 void setOutputBufferSize(int size)
           
 void suspend()
           
protected  void writeArray(byte[] b, int off, int len)
           
protected  void writeByte(int b)
          Write to the port
 
Methods inherited from class gnu.io.CommPort
getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

private static final boolean debug
See Also:
Constant Field Values

fd

private int fd
File descriptor


out

private final LPRPort.ParallelOutputStream out
Output stream


in

private final LPRPort.ParallelInputStream in
Input stream


lprmode

private int lprmode
return current mode LPT_MODE_SPP, LPT_MODE_PS2, LPT_MODE_EPP, or LPT_MODE_ECP


timeout

private int timeout
Receive timeout control


threshold

private int threshold
Receive threshold control


PPEventListener

private ParallelPortEventListener PPEventListener
Parallel Port Event listener


monThread

private LPRPort.MonitorThread monThread
Thread to monitor data

Constructor Detail

LPRPort

public LPRPort(java.lang.String name)
        throws PortInUseException
Open the named port

Method Detail

Initialize

private static void Initialize()
Initialize the native library


open

private int open(java.lang.String name)
          throws PortInUseException
Throws:
PortInUseException

getOutputStream

public java.io.OutputStream getOutputStream()
Specified by:
getOutputStream in class CommPort

getInputStream

public java.io.InputStream getInputStream()
Specified by:
getInputStream in class CommPort

getMode

public int getMode()
Specified by:
getMode in class ParallelPort

setMode

public int setMode(int mode)
            throws UnsupportedCommOperationException
Specified by:
setMode in class ParallelPort
Throws:
UnsupportedCommOperationException

restart

public void restart()
Specified by:
restart in class ParallelPort

suspend

public void suspend()
Specified by:
suspend in class ParallelPort

setLPRMode

public boolean setLPRMode(int mode)
                   throws UnsupportedCommOperationException
Throws:
UnsupportedCommOperationException

isPaperOut

public boolean isPaperOut()
Specified by:
isPaperOut in class ParallelPort

isPrinterBusy

public boolean isPrinterBusy()
Specified by:
isPrinterBusy in class ParallelPort

isPrinterError

public boolean isPrinterError()
Specified by:
isPrinterError in class ParallelPort

isPrinterSelected

public boolean isPrinterSelected()
Specified by:
isPrinterSelected in class ParallelPort

isPrinterTimedOut

public boolean isPrinterTimedOut()
Specified by:
isPrinterTimedOut in class ParallelPort

nativeClose

private void nativeClose()
Close the port


close

public void close()
Overrides:
close in class CommPort

enableReceiveFraming

public void enableReceiveFraming(int f)
                          throws UnsupportedCommOperationException
Receive framing control

Specified by:
enableReceiveFraming in class CommPort
Throws:
UnsupportedCommOperationException

disableReceiveFraming

public void disableReceiveFraming()
Specified by:
disableReceiveFraming in class CommPort

isReceiveFramingEnabled

public boolean isReceiveFramingEnabled()
Specified by:
isReceiveFramingEnabled in class CommPort

getReceiveFramingByte

public int getReceiveFramingByte()
Specified by:
getReceiveFramingByte in class CommPort

enableReceiveTimeout

public void enableReceiveTimeout(int t)
Specified by:
enableReceiveTimeout in class CommPort

disableReceiveTimeout

public void disableReceiveTimeout()
Specified by:
disableReceiveTimeout in class CommPort

isReceiveTimeoutEnabled

public boolean isReceiveTimeoutEnabled()
Specified by:
isReceiveTimeoutEnabled in class CommPort

getReceiveTimeout

public int getReceiveTimeout()
Specified by:
getReceiveTimeout in class CommPort

enableReceiveThreshold

public void enableReceiveThreshold(int t)
Specified by:
enableReceiveThreshold in class CommPort

disableReceiveThreshold

public void disableReceiveThreshold()
Specified by:
disableReceiveThreshold in class CommPort

getReceiveThreshold

public int getReceiveThreshold()
Specified by:
getReceiveThreshold in class CommPort

isReceiveThresholdEnabled

public boolean isReceiveThresholdEnabled()
Specified by:
isReceiveThresholdEnabled in class CommPort

setInputBufferSize

public void setInputBufferSize(int size)
Input/output buffers These are native stubs...

Specified by:
setInputBufferSize in class CommPort

getInputBufferSize

public int getInputBufferSize()
Specified by:
getInputBufferSize in class CommPort

setOutputBufferSize

public void setOutputBufferSize(int size)
Specified by:
setOutputBufferSize in class CommPort

getOutputBufferSize

public int getOutputBufferSize()
Specified by:
getOutputBufferSize in class CommPort

getOutputBufferFree

public int getOutputBufferFree()
Specified by:
getOutputBufferFree in class ParallelPort

writeByte

protected void writeByte(int b)
                  throws java.io.IOException
Write to the port

Throws:
java.io.IOException

writeArray

protected void writeArray(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
Throws:
java.io.IOException

drain

protected void drain()
              throws java.io.IOException
Throws:
java.io.IOException

nativeavailable

protected int nativeavailable()
                       throws java.io.IOException
LPRPort read methods

Throws:
java.io.IOException

readByte

protected int readByte()
                throws java.io.IOException
Throws:
java.io.IOException

readArray

protected int readArray(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
Throws:
java.io.IOException

eventLoop

void eventLoop()
Process ParallelPortEvents


checkMonitorThread

public boolean checkMonitorThread()

sendEvent

public boolean sendEvent(int event,
                         boolean state)

addEventListener

public void addEventListener(ParallelPortEventListener lsnr)
                      throws java.util.TooManyListenersException
Add an event listener

Specified by:
addEventListener in class ParallelPort
Throws:
java.util.TooManyListenersException

removeEventListener

public void removeEventListener()
Remove the parallel port event listener

Specified by:
removeEventListener in class ParallelPort

notifyOnError

public void notifyOnError(boolean enable)
Note: these have to be separate boolean flags because the ParallelPortEvent constants are NOT bit-flags, they are just defined as integers from 1 to 10 -DPL

Specified by:
notifyOnError in class ParallelPort

notifyOnBuffer

public void notifyOnBuffer(boolean enable)
Specified by:
notifyOnBuffer in class ParallelPort

finalize

protected void finalize()
Finalize the port