Package gnu.io

Class RXTXPort

    • Method Detail

      • getOutputStream

        public java.io.OutputStream getOutputStream()
        get the OutputStream
        Specified by:
        getOutputStream in class CommPort
        Returns:
        OutputStream
      • getInputStream

        public java.io.InputStream getInputStream()
        get the InputStream
        Specified by:
        getInputStream in class CommPort
        Returns:
        InputStream
        See Also:
        InputStream
      • getBaudRate

        public int getBaudRate()
        Specified by:
        getBaudRate in class SerialPort
        Returns:
        int representing the baudrate This will not behave as expected with custom speeds
      • getDataBits

        public int getDataBits()
        Specified by:
        getDataBits in class SerialPort
        Returns:
        int representing the databits
      • getStopBits

        public int getStopBits()
        Specified by:
        getStopBits in class SerialPort
        Returns:
        int representing the stopbits
      • getParity

        public int getParity()
        Specified by:
        getParity in class SerialPort
        Returns:
        int representing the parity
      • getFlowControlMode

        public int getFlowControlMode()
        Specified by:
        getFlowControlMode in class SerialPort
        Returns:
        int representing the flowmode
      • isReceiveFramingEnabled

        public boolean isReceiveFramingEnabled()
        Specified by:
        isReceiveFramingEnabled in class CommPort
        Returns:
        true if framing is enabled
      • getReceiveFramingByte

        public int getReceiveFramingByte()
        Specified by:
        getReceiveFramingByte in class CommPort
        Returns:
        int representing the framing byte
      • NativegetReceiveTimeout

        public int NativegetReceiveTimeout()
        Returns:
        int the timeout
      • enableReceiveTimeout

        public void enableReceiveTimeout​(int time)
        Specified by:
        enableReceiveTimeout in class CommPort
        Parameters:
        time -
      • isReceiveTimeoutEnabled

        public boolean isReceiveTimeoutEnabled()
        Specified by:
        isReceiveTimeoutEnabled in class CommPort
        Returns:
        boolean true if recieve timeout is enabled
      • getReceiveTimeout

        public int getReceiveTimeout()
        Specified by:
        getReceiveTimeout in class CommPort
        Returns:
        int the timeout
      • enableReceiveThreshold

        public void enableReceiveThreshold​(int thresh)
        Specified by:
        enableReceiveThreshold in class CommPort
        Parameters:
        thresh - threshold
      • getReceiveThreshold

        public int getReceiveThreshold()
        Specified by:
        getReceiveThreshold in class CommPort
        Returns:
        int the recieve threshold
      • isReceiveThresholdEnabled

        public boolean isReceiveThresholdEnabled()
        Specified by:
        isReceiveThresholdEnabled in class CommPort
        Returns:
        boolean true if receive threshold is enabled
      • setInputBufferSize

        public void setInputBufferSize​(int size)
        Specified by:
        setInputBufferSize in class CommPort
        Parameters:
        size -
      • setOutputBufferSize

        public void setOutputBufferSize​(int size)
        Specified by:
        setOutputBufferSize in class CommPort
        Parameters:
        size -
      • getOutputBufferSize

        public int getOutputBufferSize()
        Specified by:
        getOutputBufferSize in class CommPort
        Returns:
        in the output buffer size
      • isDTR

        public boolean isDTR()
        Specified by:
        isDTR in class SerialPort
        Returns:
        true if DTR is set
      • setDTR

        public void setDTR​(boolean state)
        Specified by:
        setDTR in class SerialPort
        Parameters:
        state -
      • setRTS

        public void setRTS​(boolean state)
        Specified by:
        setRTS in class SerialPort
        Parameters:
        state -
      • isCTS

        public boolean isCTS()
        Specified by:
        isCTS in class SerialPort
        Returns:
        boolean true if CTS is set
      • isDSR

        public boolean isDSR()
        Specified by:
        isDSR in class SerialPort
        Returns:
        boolean true if DSR is set
      • isCD

        public boolean isCD()
        Specified by:
        isCD in class SerialPort
        Returns:
        boolean true if CD is set
      • isRI

        public boolean isRI()
        Specified by:
        isRI in class SerialPort
        Returns:
        boolean true if RI is set
      • isRTS

        public boolean isRTS()
        Specified by:
        isRTS in class SerialPort
        Returns:
        boolean true if RTS is set
      • sendBreak

        public void sendBreak​(int duration)
        Write to the port
        Specified by:
        sendBreak in class SerialPort
        Parameters:
        duration -
      • writeByte

        protected void writeByte​(int b,
                                 boolean i)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArray

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

        protected boolean nativeDrain​(boolean i)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • nativeavailable

        protected int nativeavailable()
                               throws java.io.IOException
        RXTXPort 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
      • readTerminatedArray

        protected int readTerminatedArray​(byte[] b,
                                          int off,
                                          int len,
                                          byte[] t)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • checkMonitorThread

        public boolean checkMonitorThread()
      • sendEvent

        public boolean sendEvent​(int event,
                                 boolean state)
        Parameters:
        event -
        state -
        Returns:
        boolean true if the port is closing
      • removeEventListener

        public void removeEventListener()
        Remove the serial port event listener
        Specified by:
        removeEventListener in class SerialPort
      • waitForTheNativeCodeSilly

        protected void waitForTheNativeCodeSilly()
        Give the native code a chance to start listening to the hardware or should we say give the native code control of the issue. This is important for applications that flicker the Monitor thread while keeping the port open. In worst case test cases this loops once or twice every time.
      • notifyOnOutputEmpty

        public void notifyOnOutputEmpty​(boolean enable)
        Specified by:
        notifyOnOutputEmpty in class SerialPort
        Parameters:
        enable -
      • notifyOnCTS

        public void notifyOnCTS​(boolean enable)
        Specified by:
        notifyOnCTS in class SerialPort
        Parameters:
        enable -
      • notifyOnDSR

        public void notifyOnDSR​(boolean enable)
        Specified by:
        notifyOnDSR in class SerialPort
        Parameters:
        enable -
      • notifyOnRingIndicator

        public void notifyOnRingIndicator​(boolean enable)
        Specified by:
        notifyOnRingIndicator in class SerialPort
        Parameters:
        enable -
      • notifyOnCarrierDetect

        public void notifyOnCarrierDetect​(boolean enable)
        Specified by:
        notifyOnCarrierDetect in class SerialPort
        Parameters:
        enable -
      • notifyOnOverrunError

        public void notifyOnOverrunError​(boolean enable)
        Specified by:
        notifyOnOverrunError in class SerialPort
        Parameters:
        enable -
      • notifyOnParityError

        public void notifyOnParityError​(boolean enable)
        Specified by:
        notifyOnParityError in class SerialPort
        Parameters:
        enable -
      • notifyOnFramingError

        public void notifyOnFramingError​(boolean enable)
        Specified by:
        notifyOnFramingError in class SerialPort
        Parameters:
        enable -
      • notifyOnBreakInterrupt

        public void notifyOnBreakInterrupt​(boolean enable)
        Specified by:
        notifyOnBreakInterrupt in class SerialPort
        Parameters:
        enable -
      • close

        public void close()
        Overrides:
        close in class CommPort
      • finalize

        protected void finalize()
        Finalize the port
        Overrides:
        finalize in class java.lang.Object
      • setRcvFifoTrigger

        public void setRcvFifoTrigger​(int trigger)
        Deprecated.
        deprecated but used in Kaffe
        A dummy method added so RXTX compiles on Kaffee
      • staticGetBaudRate

        public static int staticGetBaudRate​(java.lang.String port)
                                     throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. This is only accurate up to 38600 baud currently.
        Parameters:
        port - the name of the port thats been preopened
        Returns:
        BaudRate on success UnsupportedCommOperationException; This will not behave as expected with custom speeds
        Throws:
        UnsupportedCommOperationException
      • staticGetDataBits

        public static int staticGetDataBits​(java.lang.String port)
                                     throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.
        Parameters:
        port - the name of the port thats been preopened
        Returns:
        DataBits on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticGetParity

        public static int staticGetParity​(java.lang.String port)
                                   throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.
        Parameters:
        port - the name of the port thats been preopened
        Returns:
        Parity on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticGetStopBits

        public static int staticGetStopBits​(java.lang.String port)
                                     throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.
        Parameters:
        port - the name of the port thats been preopened
        Returns:
        StopBits on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticSetSerialPortParams

        public static void staticSetSerialPortParams​(java.lang.String f,
                                                     int b,
                                                     int d,
                                                     int s,
                                                     int p)
                                              throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Set the SerialPort parameters 1.5 stop bits requires 5 databits
        Parameters:
        f - filename
        b - baudrate
        d - databits
        s - stopbits
        p - parity UnsupportedCommOperationException
        Throws:
        UnsupportedCommOperationException
        See Also:
        UnsupportedCommOperationException
      • staticSetDSR

        public static boolean staticSetDSR​(java.lang.String port,
                                           boolean flag)
                                    throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set DSR. remove lockfile and do not close This is so some software can appear to set the DSR before 'opening' the port a second time later on.
        Returns:
        true on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticSetDTR

        public static boolean staticSetDTR​(java.lang.String port,
                                           boolean flag)
                                    throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set DTR. remove lockfile and do not close This is so some software can appear to set the DTR before 'opening' the port a second time later on.
        Returns:
        true on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticSetRTS

        public static boolean staticSetRTS​(java.lang.String port,
                                           boolean flag)
                                    throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. Open the port and set RTS. remove lockfile and do not close This is so some software can appear to set the RTS before 'opening' the port a second time later on.
        Returns:
        none UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsRTS

        public static boolean staticIsRTS​(java.lang.String port)
                                   throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return RTS without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsCD

        public static boolean staticIsCD​(java.lang.String port)
                                  throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return CD without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsCTS

        public static boolean staticIsCTS​(java.lang.String port)
                                   throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return CTS without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsDSR

        public static boolean staticIsDSR​(java.lang.String port)
                                   throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return DSR without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsDTR

        public static boolean staticIsDTR​(java.lang.String port)
                                   throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return DTR without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • staticIsRI

        public static boolean staticIsRI​(java.lang.String port)
                                  throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems. find the fd and return RI without using a Java open() call
        Parameters:
        port -
        Returns:
        true if asserted UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • setUARTType

        public boolean setUARTType​(java.lang.String type,
                                   boolean test)
                            throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.
        Specified by:
        setUARTType in class SerialPort
        Parameters:
        type - String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750".
        test - boolean flag to determin if the UART should be tested.
        Returns:
        boolean true on success UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • getUARTType

        public java.lang.String getUARTType()
                                     throws UnsupportedCommOperationException
        Extension to CommAPI This is an extension to CommAPI. It may not be supported on all operating systems.
        Specified by:
        getUARTType in class SerialPort
        Returns:
        type String representation of the UART type which mayb be "none", "8250", "16450", "16550", "16550A", "16650", "16550V2" or "16750". UnsupportedCommOperationException;
        Throws:
        UnsupportedCommOperationException
      • setBaudBase

        public boolean setBaudBase​(int BaudBase)
                            throws UnsupportedCommOperationException,
                                   java.io.IOException
        Extension to CommAPI. Set Baud Base to 38600 on Linux and W32 before using.
        Specified by:
        setBaudBase in class SerialPort
        Parameters:
        BaudBase - The clock frequency divided by 16. Default BaudBase is 115200.
        Returns:
        true on success UnsupportedCommOperationException, IOException
        Throws:
        UnsupportedCommOperationException
        java.io.IOException
      • enableRs485

        public int enableRs485​(boolean busEnableActiveLow,
                               int delayBusEnableBeforeSendMs,
                               int delayBusEnableAfterSendMs)
      • disableRs485

        public int disableRs485()