public class SerialWrapper extends Port
| Modifier and Type | Field and Description |
|---|---|
static boolean |
haveShownNoPortsWarning
This will be set to true once the message about no enumerated ports is shown.
|
static java.lang.String |
SERIAL
The string used to identify a port.
|
static java.lang.String |
serialMappingFileName
The name of the mapping file.
|
| Constructor and Description |
|---|
SerialWrapper()
Create the wrapper without setting the port (used by BlueTooth).
|
SerialWrapper(java.lang.String description)
The port name for a serial port consists of the string "SERIAL" followed by the port number,
for example "SERIAL0", "SERIAL1", etc.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
This will return the number of bytes available.
|
void |
close()
This will close a port (including all streams).
|
void |
configPorts()
This method will set all the current parameters (baud rate, data bits,
stop bits and parity) to the port.
|
boolean |
connect()
This method will open the port and configure the streams.
|
int |
getBaudRate()
This is the baud rate.
|
int |
getDataBits()
This is the data bits.
|
java.lang.String |
getEndString() |
int |
getFlowControl()
The flow control for both input and output.
|
int |
getParity()
This is the parity.
|
int |
getPort()
This is the port number.
|
int |
getStopBits()
This is the stop bits.
|
static void |
loadMappingFile() |
int |
read()
Read a single character without a timeout
|
int |
read(byte[] b)
Fill the given byte array b with data from the buffer, without applying a timeout.
|
int |
read(byte[] b,
int off,
int len)
Reads len bytes into the array b starting at the offset off, without applying a timeout.
|
byte[] |
readAndWait(int length,
int timeout,
int interCharacterTimeout)
This will wait until we have received data until either the
timeout or the interCharacterTimeout expire
or length characters are read. |
byte[] |
readCurrent()
Read the current buffer contents without waiting
|
void |
setBaudRate(int newValue)
This is the baud rate.
|
void |
setDataBits(int newValue)
This is the data bits.
|
void |
setEndString(java.lang.String endString) |
void |
setFlowControl(int flowControl)
The flow control for both input and output.
|
void |
setParity(int newValue)
This is the parity.
|
void |
setPortPool(PortPoolInterface portPool)
Opens and closes the port based on the value passed.
|
void |
setStopBits(int newValue)
This is the stop bits.
|
java.lang.String |
toString() |
getInputStream, getName, getOutputStream, getPortPool, hasError, setError, setInputStream, setOutputStream, setThread, write, write, writepublic static boolean haveShownNoPortsWarning
public static java.lang.String SERIAL
public static java.lang.String serialMappingFileName
public SerialWrapper()
public SerialWrapper(java.lang.String description)
throws BadParameterException,
java.io.IOException
portName - BadParameterExceptionjava.io.IOExceptionpublic int available()
throws java.io.IOException
available in interface PortInterfaceavailable in class Portjava.io.IOExceptionpublic void close()
public void configPorts()
public boolean connect()
public int getBaudRate()
setbaudRatepublic int getDataBits()
setDataBitspublic java.lang.String getEndString()
public int getFlowControl()
public int getParity()
setParitypublic int getPort()
public int getStopBits()
setStopBitspublic static void loadMappingFile()
throws BadParameterException
BadParameterExceptionpublic int read()
throws java.io.IOException
read in interface PortInterfaceread in class Portjava.io.IOExceptionpublic int read(byte[] b)
throws java.io.IOException
read in interface PortInterfaceread in class Portjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in interface PortInterfaceread in class Portjava.io.IOExceptionpublic byte[] readAndWait(int length,
int timeout,
int interCharacterTimeout)
throws java.io.IOException
Porttimeout or the interCharacterTimeout expire
or length characters are read. The timeout values are
in milliseconds. The call will wait for up to timeout for
a character to be available. If no characters are available then the
method will return with a null value. If character are available, then
the method will read characters until either length
characters have been read or no characters have been available for
interCharacterTimeout milliseconds. If the
interCharacterTimeout expires then the returned array may
have less than length characters available.readAndWait in interface PortInterfacereadAndWait in class Portlength - the maximum number of characters to readtimeout - the maximum time to wait for the first character to be
available at the portinterCharacterTimeout - the maximum time to wait for subsequent
characters to be available at the portlength if the interCharacterTimeout expired. It will be
null if the timeout expired.java.io.IOException - thrown by the underlying portpublic byte[] readCurrent()
throws java.io.IOException
readCurrent in class Portjava.io.IOExceptionpublic void setBaudRate(int newValue)
getbaudRatepublic void setDataBits(int newValue)
getDataBitspublic void setEndString(java.lang.String endString)
endString - the endString to setpublic void setFlowControl(int flowControl)
public void setParity(int newValue)
getParitypublic void setPortPool(PortPoolInterface portPool)
setPortPool in interface PortInterfacesetPortPool in class PortPort.setPortPool(com.ergotech.vib.ports.PortPoolInterface)public void setStopBits(int newValue)
getStopBitspublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 1999-2025 ErgoTech Systems, Inc. All Rights Reserved.