|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.comm.CommPort
javax.comm.ParallelPort
com.sun.comm.LinuxParallel
| Nested Class Summary | |
(package private) class |
LinuxParallel.LPInputStream
|
(package private) class |
LinuxParallel.LPOutputStream
|
| Field Summary | |
private int |
framing_byte
|
private int |
ibuffer_size
|
private LinuxParallel.LPInputStream |
inputStream
|
private ParallelPortEventListener |
listener
|
static int |
LPT_MODE_ANY
|
static int |
LPT_MODE_ECP
|
static int |
LPT_MODE_EPP
|
static int |
LPT_MODE_PS2
|
static int |
LPT_MODE_SPP
|
private int |
notificationMask
|
private static int |
NOTIFY_BUF
|
private static int |
NOTIFY_ERR
|
private int |
obuffer_size
|
private LinuxParallel.LPOutputStream |
outputStream
|
private int |
port_fd
|
private int |
port_mode
|
private int |
rcv_threshold
|
private int |
rcv_timeout
|
private static int |
STATUS_PaperOut
|
private static int |
STATUS_PrtBusy
|
private static int |
STATUS_PrtError
|
private static int |
STATUS_PrtSelected
|
private static int |
STATUS_PrtTimedOut
|
| Fields inherited from class javax.comm.ParallelPort |
LPT_MODE_NIBBLE |
| Fields inherited from class javax.comm.CommPort |
name |
| Constructor Summary | |
LinuxParallel(java.lang.String theName)
|
|
| Method Summary | |
void |
addEventListener(ParallelPortEventListener lsnr)
Registers a ParallelPortEventListener object for
ParallelPortEvents. |
void |
close()
Closes the communications port. |
void |
disableReceiveFraming()
Disables receive framing. |
void |
disableReceiveThreshold()
Disables receive threshold. |
void |
disableReceiveTimeout()
Disables receive timeout. |
void |
enableReceiveFraming(int framingByte)
Enables receive framing, if this feature is supported by the driver. |
void |
enableReceiveThreshold(int thresh)
Enables receive threshold, if this feature is supported by the driver. |
void |
enableReceiveTimeout(int rcvTimeout)
Enables receive timeout, if this feature is supported by the driver. |
int |
getInputBufferSize()
Gets the input buffer size. |
java.io.InputStream |
getInputStream()
Returns an input stream. |
int |
getMode()
Gets the currently configured mode. |
int |
getOutputBufferFree()
Gets the number of bytes available in the output buffer. |
int |
getOutputBufferSize()
Gets the output buffer size. |
java.io.OutputStream |
getOutputStream()
Returns an output stream. |
int |
getReceiveFramingByte()
Gets the current byte used for receive framing. |
int |
getReceiveThreshold()
Gets the integer value of the receive threshold. |
int |
getReceiveTimeout()
Gets the integer value of the receive timeout. |
boolean |
isPaperOut()
Checks if the port is indicating an "Out of Paper" state. |
boolean |
isPrinterBusy()
Checks if the port is indicating a "Printer Busy" state. |
boolean |
isPrinterError()
Checks if the printer has encountered an error. |
boolean |
isPrinterSelected()
Checks if the printer is in selected state. |
boolean |
isPrinterTimedOut()
Checks if the printer has timed out. |
boolean |
isReceiveFramingEnabled()
Checks if receive framing is enabled. |
boolean |
isReceiveThresholdEnabled()
Checks if receive threshold is enabled. |
boolean |
isReceiveTimeoutEnabled()
Checks if receive timeout is enabled. |
private int |
nativeAvailable(int port_fd)
|
private void |
nativeClosePort(int port_fd)
|
private boolean |
nativeGetStatusFlags(int port_fd,
int flag)
|
private int |
nativeOpenPort(java.lang.String port_name)
|
private int |
nativeRead(int port_fd,
byte[] buf,
int offset,
int len)
|
private byte |
nativeReadByte(int port_fd)
|
private void |
nativeSetTimeout(int port_fd,
int timeout)
|
int |
nativeWrite(int port_fd,
byte[] buf,
int offset,
int len)
|
void |
notifyOnBuffer(boolean enable)
Expresses interest in being notified when the output buffer is empty. |
void |
notifyOnError(boolean enable)
Expresses interest in being notified of port errors. |
private void |
raiseEvent(int notify_bit,
boolean oldvalue,
boolean newvalue)
|
void |
removeEventListener()
Deregisters event listener registered using addEventListener. |
void |
restart()
Restarts output after an error. |
void |
setInputBufferSize(int size)
Sets the input buffer size. |
int |
setMode(int mode)
Sets the printer port mode. |
void |
setOutputBufferSize(int size)
Sets the output buffer size. |
void |
suspend()
Suspends output. |
| Methods inherited from class javax.comm.CommPort |
getName, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private int port_mode
private int port_fd
private int rcv_timeout
private int rcv_threshold
private int framing_byte
private int ibuffer_size
private int obuffer_size
public static final int LPT_MODE_ANY
public static final int LPT_MODE_SPP
public static final int LPT_MODE_PS2
public static final int LPT_MODE_EPP
public static final int LPT_MODE_ECP
private static final int STATUS_PaperOut
private static final int STATUS_PrtBusy
private static final int STATUS_PrtSelected
private static final int STATUS_PrtTimedOut
private static final int STATUS_PrtError
private ParallelPortEventListener listener
private LinuxParallel.LPInputStream inputStream
private LinuxParallel.LPOutputStream outputStream
private int notificationMask
private static final int NOTIFY_ERR
private static final int NOTIFY_BUF
| Constructor Detail |
public LinuxParallel(java.lang.String theName)
throws java.io.IOException
| Method Detail |
private int nativeOpenPort(java.lang.String port_name)
throws java.io.IOException
java.io.IOExceptionpublic int getOutputBufferFree()
ParallelPort
getOutputBufferFree in class ParallelPort
public int setMode(int mode)
throws UnsupportedCommOperationException
ParallelPort
setMode in class ParallelPortmode - one of LPT_MODE_ANY, LPT_MODE_SPP,
LPT_MODE_PS2, LPT_MODE_EPP, or LPT_MODE_ECP
UnsupportedCommOperationException - is thrown if the
mode is not supported by the underline driver.public int getMode()
ParallelPort
getMode in class ParallelPortpublic void suspend()
ParallelPort
suspend in class ParallelPortpublic void restart()
ParallelPort
restart in class ParallelPort
private boolean nativeGetStatusFlags(int port_fd,
int flag)
public boolean isPaperOut()
ParallelPort
isPaperOut in class ParallelPortpublic boolean isPrinterBusy()
ParallelPort
isPrinterBusy in class ParallelPortpublic boolean isPrinterSelected()
ParallelPortNote: This method is platform dependent.
isPrinterSelected in class ParallelPortpublic boolean isPrinterTimedOut()
ParallelPortNote: This method is platform dependent.
isPrinterTimedOut in class ParallelPortpublic boolean isPrinterError()
ParallelPortNote: This method is platform dependent.
isPrinterError in class ParallelPort
public void addEventListener(ParallelPortEventListener lsnr)
throws java.util.TooManyListenersException
ParallelPortParallelPortEventListener object for
ParallelPortEvents. Interest in specific events
may be expressed by using the notifyOnError and
notifyOnBuffer methods.
Only one listener per ParallelPort is supported.
Calling addEventListener multiple times will simply
replace the current ParallelPortEventListener object.
After the port is closed, no more event will be generated. Another
call to open() of the port's
CommPortIdentifier
object will return a new CommPort object, and the lsnr
has to be added again to the new CommPort object to
receive event from this port.
addEventListener in class ParallelPortlsnr - A ParallelPortEventListener object
whose parallelEvent method will be called
to indicate an event.
java.util.TooManyListenersException - If an initial attempt to
attach a listener succeeds, subsequent
attempts will throw TooManyListenersException
without effecting the first listener.public void removeEventListener()
ParallelPortaddEventListener.
This is done automatically when a port is closed.
removeEventListener in class ParallelPort
private void raiseEvent(int notify_bit,
boolean oldvalue,
boolean newvalue)
public void notifyOnError(boolean enable)
ParallelPort
notifyOnError in class ParallelPortenable - enable or disable error notification based on whether
notify is true or falsepublic void notifyOnBuffer(boolean enable)
ParallelPort
notifyOnBuffer in class ParallelPortenable - true enables notification;
false disables notification.
public java.io.InputStream getInputStream()
throws java.io.IOException
CommPortgetInputStream
returns null.
The read behaviour of the input stream returned by
getInputStream depends on combination of the
threshold and timeout values. The possible behaviours are
described in the table below:
| Threshold | Timeout | Read Buffer Size | Read Behaviour | ||
|---|---|---|---|---|---|
| State | Value | State | Value | ||
| disabled | - | disabled | - | n bytes | block until any data is available |
| enabled | m bytes | disabled | - | n bytes | block until min(m,n) bytes are available |
| disabled | - | enabled | x ms | n bytes | block for x ms or until any data is available |
| enabled | m bytes | enabled | x ms | n bytes | block for x ms or until min(m,n) bytes are available |
Note, however, that framing errors may cause the Timeout and Threshold values to complete prematurely without raising an exception.
Enabling the Timeout OR Threshold with a value a zero is a special case. This causes the underlying driver to poll for incoming data instead being event driven. Otherwise, the behaviour is identical to having both the Timeout and Threshold disabled.
getInputStream in class CommPortjava.io.IOException - if an I/O error occurred
public java.io.OutputStream getOutputStream()
throws java.io.IOException
CommPortgetOutputStream
returns null.
getOutputStream in class CommPortjava.io.IOException - if an I/O error occurredpublic void close()
CommPortclose when it is done with the port.
Notification of this ownership change will be propagated to all classes
registered using addPortOwnershipListener.
close in class CommPort
private void nativeClosePort(int port_fd)
throws java.io.IOException
java.io.IOException
private int nativeAvailable(int port_fd)
throws java.io.IOException
java.io.IOException
private byte nativeReadByte(int port_fd)
throws java.io.IOException
java.io.IOException
private int nativeRead(int port_fd,
byte[] buf,
int offset,
int len)
throws java.io.IOException
java.io.IOException
public int nativeWrite(int port_fd,
byte[] buf,
int offset,
int len)
throws java.io.IOException
java.io.IOException
public void enableReceiveThreshold(int thresh)
throws UnsupportedCommOperationException
CommPortread
from the input stream for this port will return immediately.
enableReceiveThreshold is an advisory method which the driver
may not implement. By default, receive threshold is not enabled.
An application can determine whether the driver supports this feature
by first calling the enableReceiveThreshold method and then
calling the isReceiveThresholdEnabled method. If
isReceiveThresholdEnabled still returns false, then receive
threshold is not supported by the driver. If the driver does not implement
this feature, it will return from blocking reads at an appropriate time.
See getInputStream for description of exact behaviour.
enableReceiveThreshold in class CommPortthresh - when this many bytes are in the input buffer, return
immediately from read.
UnsupportedCommOperationException - is thrown if receive
threshold is not supported by the underlying driver.public void disableReceiveThreshold()
CommPort
disableReceiveThreshold in class CommPortpublic boolean isReceiveThresholdEnabled()
CommPort
isReceiveThresholdEnabled in class CommPortpublic int getReceiveThreshold()
CommPort
getReceiveThreshold in class CommPortpublic void enableReceiveTimeout(int rcvTimeout)
CommPortread
from the input stream for this port will return immediately.
enableReceiveTimeout is an advisory method which the driver
may not implement. By default, receive timeout is not enabled.
An application can determine whether the driver supports this feature
by first calling the enableReceiveTimeout method and then
calling the isReceiveTimeout method. If
isReceiveTimeout still returns false, then receive timeout
is not supported by the driver.
See getInputStream for description of exact behaviour.
enableReceiveTimeout in class CommPortrcvTimeout - when this many milliseconds have elapsed, return
immediately from read, regardless of bytes in
input buffer.
public void disableReceiveTimeout()
CommPort
disableReceiveTimeout in class CommPortpublic boolean isReceiveTimeoutEnabled()
CommPort
isReceiveTimeoutEnabled in class CommPortpublic int getReceiveTimeout()
CommPort
getReceiveTimeout in class CommPort
private void nativeSetTimeout(int port_fd,
int timeout)
public void disableReceiveFraming()
CommPort
disableReceiveFraming in class CommPort
public void enableReceiveFraming(int framingByte)
throws UnsupportedCommOperationException
CommPortread
from the input stream for this port will return immediately.
enableReceiveFraming is an advisory method which the driver
may not implement. By default, receive framing is not enabled.
An application can determine whether the driver supports this feature
by first calling the enableReceiveFraming method and then
calling the isReceiveFramingEnabled method. If
isReceiveFramingEnabled still returns false, then receive
framing is not supported by the driver.
Note: As implemented in this method, framing is not related to bit-level framing at the hardware level, and is not associated with data errors.
enableReceiveFraming in class CommPortframingByte - this byte in the input stream
suggests the end of the received frame. Blocked reads
will return immediately. Only the low 8 bits of framingByte
are used while the upper 24 bits are masked off. A value outside the range
of 0-255 will be converted to the value of its lowest 8 bits.
UnsupportedCommOperationException - is thrown if receive
timeout is not supported by the underlying driver.public boolean isReceiveFramingEnabled()
CommPort
isReceiveFramingEnabled in class CommPortpublic int getReceiveFramingByte()
CommPortgetReceiveFramingByte
is an integer, the low 8 bits of which represent the current byte
used for receive framing.
Note: As implemented in this method, framing is not related to bit-level framing at the hardware level, and is not associated with data errors.
getReceiveFramingByte in class CommPortpublic void setInputBufferSize(int size)
CommPort
setInputBufferSize in class CommPortsize - size of the input bufferpublic int getInputBufferSize()
CommPort
getInputBufferSize in class CommPortpublic void setOutputBufferSize(int size)
CommPort
setOutputBufferSize in class CommPortsize - size of the output bufferpublic int getOutputBufferSize()
CommPort
getOutputBufferSize in class CommPort
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||