Package com.celer

Class COM

java.lang.Object
com.celer.COM

public class COM
extends java.lang.Object
The COM class can be used to open and close a COM port, retrieve an input and output streams to perform I/O.

CelerSMS

This class will try to use the native driver, if available. Otherwise it will fallback to the Java RAF driver.

  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the COM port.
    COMInputStream getInputStream()
    Get an input stream, which can be used to read from this COM port.
    COMOutputStream getOutputStream()
    Get an output stream, which can be used to write to this COM port.
    boolean isNative()
    Test if the COM driver is native or Java (RAF).
    static COM open​(java.lang.String comdev)
    Open the COM port.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • open

      public static final COM open​(java.lang.String comdev) throws java.io.IOException
      Open the COM port.
      Parameters:
      comdev - specifies the name of the COM port.

      In Windows the COM port names must start with "\\.\" if the port number is greater than 9, for example:

      COM9
      \\.\COM15
      Note: Don't forget to escape the backslash character in Java!

      In Linux a typical COM port name can be:

      /dev/ttyUSB1
      Returns:
      The COM port instance, which can be used to read, write or close the port.
      Throws:
      java.lang.IllegalArgumentException - if the COM port name is null or empty.
      java.io.IOException - if the port can't be opened. This can happen if the device is not connected.
    • getInputStream

      public final COMInputStream getInputStream()
      Get an input stream, which can be used to read from this COM port.
      Returns:
      The input stream. This stream is released implicitly when the COM port is closed by calling the close() method.
    • getOutputStream

      public final COMOutputStream getOutputStream()
      Get an output stream, which can be used to write to this COM port.
      Returns:
      The output stream. This stream is released implicitly when the COM port is closed by calling the close() method.
    • close

      public void close()
      Close the COM port. Call this method to free the resources and streams. After closing the COM port any read or write operation will fail. It is recommended to close the COM port when it is no longer needed.
    • isNative

      public boolean isNative()
      Test if the COM driver is native or Java (RAF).
      Returns:
      If the driver is native returns true. Otherwise returns false.