Package com.celer
Class COM
java.lang.Object
com.celer.COM
public class COM
extends java.lang.Object
-
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.
-
Method Details
-
open
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
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
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 returnsfalse
.
-