public abstract class LocalSerialPort extends Object implements IHarcHardware
Modifier and Type | Class and Description |
---|---|
static class |
LocalSerialPort.FlowControl |
static class |
LocalSerialPort.Parity |
Modifier and Type | Field and Description |
---|---|
static String |
defaultPort |
protected InputStream |
inStream |
protected OutputStream |
outStream |
protected boolean |
verbose |
Constructor and Description |
---|
LocalSerialPort(int portNumber) |
LocalSerialPort(String portName) |
LocalSerialPort(String portName,
int baud) |
LocalSerialPort(String portName,
int baud,
int length,
int stopBits,
LocalSerialPort.Parity parity,
LocalSerialPort.FlowControl flowControl,
int timeout) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
dropDTR(int duration) |
void |
flush() |
void |
flushInput() |
String |
getPortName()
Returns the nominal port name being used.
|
static String |
getSerialPortName(int portNumber) |
static ArrayList<String> |
getSerialPortNames(boolean useCached)
Returns all serial port names found in the system.
|
String |
getVersion()
Returns the hardware version (not the version of the driver software).
|
boolean |
isValid()
Tries to identify instances that are not valid.
|
void |
open()
Opens the device.
|
void |
setDTR(boolean state) |
void |
setTimeout(int timeout)
Set timeout in milliseconds.
|
void |
setVerbose(boolean verbose)
Sets a verbosity flag, causing commands to be executed verbosely.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setDebug
public static final String defaultPort
protected InputStream inStream
protected OutputStream outStream
protected boolean verbose
public LocalSerialPort(String portName, int baud, int length, int stopBits, LocalSerialPort.Parity parity, LocalSerialPort.FlowControl flowControl, int timeout) throws gnu.io.NoSuchPortException, gnu.io.PortInUseException, gnu.io.UnsupportedCommOperationException, IOException
gnu.io.NoSuchPortException
gnu.io.PortInUseException
gnu.io.UnsupportedCommOperationException
IOException
public LocalSerialPort(String portName, int baud) throws gnu.io.NoSuchPortException, gnu.io.PortInUseException, gnu.io.UnsupportedCommOperationException, IOException
gnu.io.NoSuchPortException
gnu.io.PortInUseException
gnu.io.UnsupportedCommOperationException
IOException
public LocalSerialPort(String portName) throws gnu.io.NoSuchPortException, gnu.io.PortInUseException, gnu.io.UnsupportedCommOperationException, IOException
gnu.io.NoSuchPortException
gnu.io.PortInUseException
gnu.io.UnsupportedCommOperationException
IOException
public LocalSerialPort(int portNumber) throws IOException, gnu.io.NoSuchPortException, gnu.io.PortInUseException, gnu.io.UnsupportedCommOperationException
IOException
gnu.io.NoSuchPortException
gnu.io.PortInUseException
gnu.io.UnsupportedCommOperationException
public static String getSerialPortName(int portNumber) throws IOException, gnu.io.NoSuchPortException
IOException
gnu.io.NoSuchPortException
public static ArrayList<String> getSerialPortNames(boolean useCached) throws IOException
useCached
- If true, use previously acquired list, if availableIOException
public void setVerbose(boolean verbose)
IHarcHardware
setVerbose
in interface IHarcHardware
verbose
- on or offpublic void open() throws HarcHardwareException, IOException
open
in interface IHarcHardware
HarcHardwareException
- Bundles RXTX exceptions together.IOException
public void flushInput() throws IOException
IOException
public boolean isValid()
IHarcHardware
isValid
in interface IHarcHardware
public void setTimeout(int timeout) throws IOException
IHarcHardware
setTimeout
in interface IHarcHardware
timeout
- Timeout in milliseconds.IOException
public String getVersion()
IHarcHardware
getVersion
in interface IHarcHardware
public String getPortName()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void flush() throws IOException
IOException
public void setDTR(boolean state)
public void dropDTR(int duration)
Copyright © 2019. All rights reserved.