com.engidea.win32jcom
Class WinjcomPort

java.lang.Object
  extended by com.engidea.comm.CommPort
      extended by com.engidea.comm.SerialPort
          extended by com.engidea.win32jcom.WinjcomPort

public final class WinjcomPort
extends SerialPort


Field Summary
 
Fields inherited from class com.engidea.comm.SerialPort
DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2
 
Fields inherited from class com.engidea.comm.CommPort
portName
 
Method Summary
 int available()
          Return the number of bytes available on read.
 void close()
          Close does not throw exception since there is no receovery from it.
 void disableReceiveFraming()
           
 void disableReceiveThreshold()
           
 void disableReceiveTimeout()
           
 void enableReceiveFraming(int f)
           
 void enableReceiveThreshold(int thresh)
           
 void enableReceiveTimeout(int timeoutMilli)
           
 void finalize()
          Ideally the program MUST call close, but if it does not this is a chance to recover.
 void flush()
          This THROWS AWAY any char that is in the input or output queue !!!!
 int getBaudRate()
           
 int getDataBits()
           
 int getFlowControlMode()
           
 int getInputBufferSize()
           
 int getOutputBufferSize()
           
 int getParity()
           
 int getReceiveFramingByte()
           
 int getReceiveThreshold()
           
 int getReceiveTimeout()
           
 int getStopBits()
           
 boolean isCD()
           
 boolean isCTS()
           
 boolean isDSR()
           
 boolean isDTR()
           
 boolean isReceiveFramingEnabled()
           
 boolean isReceiveThresholdEnabled()
           
 boolean isReceiveTimeoutEnabled()
           
 boolean isRI()
           
 boolean isRTS()
           
 void notifyOnBreakInterrupt(boolean enable)
           
 void notifyOnCarrierDetect(boolean enable)
           
 void notifyOnCTS(boolean enable)
           
 void notifyOnDataAvailable(boolean enable)
           
 void notifyOnDSR(boolean enable)
           
 void notifyOnFramingError(boolean enable)
           
 void notifyOnOutputEmpty(boolean enable)
           
 void notifyOnOverrunError(boolean enable)
           
 void notifyOnParityError(boolean enable)
           
 void notifyOnRingIndicator(boolean enable)
           
 void open()
          Opens the port to be used for work.
 int read(byte[] buff, int offset, int len)
          Port instances are allowed to read less chars than requested at their wish.
 void sendBreak(int duration)
           
 void setDTR(boolean state)
           
 void setEventListener(SerialPortEventListener portListener)
          Set the listener to be used, if null then it just clears the listener.
 void setFlowControlMode(int flowcontrol)
          The param is one of FLOWCONTROL_ defined in SerialPort
 void setInputBufferSize(int size)
           
 void setOutputBufferSize(int size)
           
 void setRTS(boolean state)
           
 void setSerialPortParams(int baudrate, int databits, int stopbits, int parity)
           
 java.lang.String toString()
          What is probably useful is to have the port this driver is bound to.
 int write(byte[] buff, int offset, int len)
          Port instances are allowed to write less chars than requested.
 
Methods inherited from class com.engidea.comm.CommPort
getName
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

open

public void open()
          throws java.io.IOException
Opens the port to be used for work. If you want to receive events right at port opening, you should set the listener before opening theport.

Specified by:
open in class CommPort
Throws:
java.io.IOException

setSerialPortParams

public void setSerialPortParams(int baudrate,
                                int databits,
                                int stopbits,
                                int parity)
                         throws java.io.IOException
Specified by:
setSerialPortParams in class SerialPort
Throws:
java.io.IOException

getBaudRate

public int getBaudRate()
                throws java.io.IOException
Specified by:
getBaudRate in class SerialPort
Throws:
java.io.IOException

getDataBits

public int getDataBits()
                throws java.io.IOException
Specified by:
getDataBits in class SerialPort
Throws:
java.io.IOException

getStopBits

public int getStopBits()
                throws java.io.IOException
Specified by:
getStopBits in class SerialPort
Throws:
java.io.IOException

getParity

public int getParity()
              throws java.io.IOException
Specified by:
getParity in class SerialPort
Throws:
java.io.IOException

getFlowControlMode

public int getFlowControlMode()
                       throws java.io.IOException
Specified by:
getFlowControlMode in class SerialPort
Throws:
java.io.IOException

setFlowControlMode

public void setFlowControlMode(int flowcontrol)
                        throws java.io.IOException
The param is one of FLOWCONTROL_ defined in SerialPort

Specified by:
setFlowControlMode in class SerialPort
Parameters:
flowcontrol -
Throws:
java.io.IOException

enableReceiveFraming

public void enableReceiveFraming(int f)
                          throws java.io.IOException
Specified by:
enableReceiveFraming in class CommPort
Throws:
java.io.IOException

disableReceiveFraming

public void disableReceiveFraming()
                           throws java.io.IOException
Specified by:
disableReceiveFraming in class CommPort
Throws:
java.io.IOException

isReceiveFramingEnabled

public boolean isReceiveFramingEnabled()
                                throws java.io.IOException
Specified by:
isReceiveFramingEnabled in class CommPort
Throws:
java.io.IOException

getReceiveFramingByte

public int getReceiveFramingByte()
                          throws java.io.IOException
Specified by:
getReceiveFramingByte in class CommPort
Throws:
java.io.IOException

disableReceiveTimeout

public void disableReceiveTimeout()
                           throws java.io.IOException
Specified by:
disableReceiveTimeout in class CommPort
Throws:
java.io.IOException

enableReceiveTimeout

public void enableReceiveTimeout(int timeoutMilli)
                          throws java.io.IOException
Specified by:
enableReceiveTimeout in class CommPort
Throws:
java.io.IOException

isReceiveTimeoutEnabled

public boolean isReceiveTimeoutEnabled()
                                throws java.io.IOException
Specified by:
isReceiveTimeoutEnabled in class CommPort
Throws:
java.io.IOException

getReceiveTimeout

public int getReceiveTimeout()
                      throws java.io.IOException
Specified by:
getReceiveTimeout in class CommPort
Throws:
java.io.IOException

enableReceiveThreshold

public void enableReceiveThreshold(int thresh)
                            throws java.io.IOException
Specified by:
enableReceiveThreshold in class CommPort
Throws:
java.io.IOException

disableReceiveThreshold

public void disableReceiveThreshold()
                             throws java.io.IOException
Specified by:
disableReceiveThreshold in class CommPort
Throws:
java.io.IOException

getReceiveThreshold

public int getReceiveThreshold()
                        throws java.io.IOException
Specified by:
getReceiveThreshold in class CommPort
Throws:
java.io.IOException

isReceiveThresholdEnabled

public boolean isReceiveThresholdEnabled()
                                  throws java.io.IOException
Specified by:
isReceiveThresholdEnabled in class CommPort
Throws:
java.io.IOException

setInputBufferSize

public void setInputBufferSize(int size)
                        throws java.io.IOException
Specified by:
setInputBufferSize in class CommPort
Throws:
java.io.IOException

getInputBufferSize

public int getInputBufferSize()
                       throws java.io.IOException
Specified by:
getInputBufferSize in class CommPort
Throws:
java.io.IOException

setOutputBufferSize

public void setOutputBufferSize(int size)
                         throws java.io.IOException
Specified by:
setOutputBufferSize in class CommPort
Throws:
java.io.IOException

getOutputBufferSize

public int getOutputBufferSize()
                        throws java.io.IOException
Specified by:
getOutputBufferSize in class CommPort
Throws:
java.io.IOException

isDTR

public boolean isDTR()
              throws java.io.IOException
Specified by:
isDTR in class SerialPort
Throws:
java.io.IOException

setDTR

public void setDTR(boolean state)
            throws java.io.IOException
Specified by:
setDTR in class SerialPort
Throws:
java.io.IOException

setRTS

public void setRTS(boolean state)
            throws java.io.IOException
Specified by:
setRTS in class SerialPort
Throws:
java.io.IOException

sendBreak

public void sendBreak(int duration)
               throws java.lang.InterruptedException,
                      java.io.IOException
Specified by:
sendBreak in class SerialPort
Throws:
java.lang.InterruptedException
java.io.IOException

isCTS

public boolean isCTS()
              throws java.io.IOException
Specified by:
isCTS in class SerialPort
Throws:
java.io.IOException

isDSR

public boolean isDSR()
              throws java.io.IOException
Specified by:
isDSR in class SerialPort
Throws:
java.io.IOException

isCD

public boolean isCD()
             throws java.io.IOException
Specified by:
isCD in class SerialPort
Throws:
java.io.IOException

isRI

public boolean isRI()
             throws java.io.IOException
Specified by:
isRI in class SerialPort
Throws:
java.io.IOException

isRTS

public boolean isRTS()
              throws java.io.IOException
Specified by:
isRTS in class SerialPort
Throws:
java.io.IOException

setEventListener

public void setEventListener(SerialPortEventListener portListener)
Set the listener to be used, if null then it just clears the listener.

Specified by:
setEventListener in class SerialPort
Parameters:
portListener -

notifyOnDataAvailable

public void notifyOnDataAvailable(boolean enable)
Specified by:
notifyOnDataAvailable in class SerialPort

notifyOnOutputEmpty

public void notifyOnOutputEmpty(boolean enable)
Specified by:
notifyOnOutputEmpty in class SerialPort

notifyOnCTS

public void notifyOnCTS(boolean enable)
Specified by:
notifyOnCTS in class SerialPort

notifyOnDSR

public void notifyOnDSR(boolean enable)
Specified by:
notifyOnDSR in class SerialPort

notifyOnRingIndicator

public void notifyOnRingIndicator(boolean enable)
Specified by:
notifyOnRingIndicator in class SerialPort

notifyOnCarrierDetect

public void notifyOnCarrierDetect(boolean enable)
Specified by:
notifyOnCarrierDetect in class SerialPort

notifyOnOverrunError

public void notifyOnOverrunError(boolean enable)
Specified by:
notifyOnOverrunError in class SerialPort

notifyOnParityError

public void notifyOnParityError(boolean enable)
Specified by:
notifyOnParityError in class SerialPort

notifyOnFramingError

public void notifyOnFramingError(boolean enable)
Specified by:
notifyOnFramingError in class SerialPort

notifyOnBreakInterrupt

public void notifyOnBreakInterrupt(boolean enable)
Specified by:
notifyOnBreakInterrupt in class SerialPort

write

public int write(byte[] buff,
                 int offset,
                 int len)
          throws java.io.IOException
Description copied from class: CommPort
Port instances are allowed to write less chars than requested. Expect this to throw exception on timeout or alternatively to return zero bytes.

Specified by:
write in class CommPort
Returns:
the number of bytes written, only -1 means EOF, Zero is a valid return
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from class: CommPort
This THROWS AWAY any char that is in the input or output queue !!!!

Specified by:
flush in class CommPort
Throws:
java.io.IOException

read

public int read(byte[] buff,
                int offset,
                int len)
         throws java.io.IOException
Description copied from class: CommPort
Port instances are allowed to read less chars than requested at their wish. Expect this to throw exception on timeout or alternatively to return zero bytes.

Specified by:
read in class CommPort
Returns:
the number of bytes read, only -1 means EOF, zero is a valid return
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Description copied from class: CommPort
Return the number of bytes available on read.

Specified by:
available in class CommPort
Returns:
the number of bytes available to read
Throws:
java.io.IOException

close

public void close()
Close does not throw exception since there is no receovery from it. But I print it out, just in case someone wants to notice...

Specified by:
close in class CommPort

finalize

public void finalize()
Ideally the program MUST call close, but if it does not this is a chance to recover. Of course you never know when GC is run...

Overrides:
finalize in class java.lang.Object

toString

public java.lang.String toString()
What is probably useful is to have the port this driver is bound to.

Overrides:
toString in class CommPort
Returns:
human readable information for this object