|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectSerialio.SerialPortLocal
public class SerialPortLocal
Class for interface to serial port(s). This class allows high-performance serial port throughput as well as low-level serial port access to the serial port(s) of the computer.
| Field Summary | |
|---|---|
protected static int |
buildNum
|
protected static java.lang.String[] |
comPortNums
|
protected ErrorStatusHandler |
esh
|
protected static java.lang.String |
jspLib
|
protected static boolean |
jspLibLoaded
|
protected static int |
maxBitRate
|
protected static PortDriverInfo |
portInfo
|
protected static java.util.Vector |
portList
|
protected static java.util.Vector |
portListInfo
|
protected static java.util.List |
portNumList
|
protected static StringCompare |
stringCompare
|
protected static SortVector |
svPortList
|
| Fields inherited from interface Serialio.SerialPort |
|---|
RXREADYCOUNT |
| Constructor Summary | |
|---|---|
SerialPortLocal()
Create a default SerialPort object. |
|
SerialPortLocal(SerialConfig cfgObj)
Create a SerialPort object based on a SerialConfig object. |
|
| Method Summary | |
|---|---|
static void |
addPortInfo(java.lang.String comName,
java.lang.String devMfgr,
java.lang.String devDesc)
Add port driver manufacture name & description to the list. |
static void |
addPortName(java.lang.String newName)
Add port name to the list. |
void |
clearReadSinceRxBufCheck()
Clears state of 'read since rx buffer check' flag. |
void |
clearSendSinceTxBufEmpty()
Clears state of 'send since empty msg' flag. |
void |
close()
Close a port object. |
void |
configure()
Configures port with the parameters in the SerialConfig object |
void |
configure(SerialConfig cfgObj)
Configures port with the parameters in the SerialConfig object. |
protected void |
finalize()
Be sure that port is cleaned up before exit (in case close was not called) |
int |
getBitRate()
|
int |
getBuildNum()
Returns the build number of this class. |
int |
getByte()
Get the next available byte from the receive buffer. |
SerialConfig |
getConfig()
Gets the the SerialConfig object |
int |
getData(byte[] buf)
Gets next available bytes from the receive buffer. |
int |
getData(byte[] buf,
int off,
int len)
Gets next available bytes from the receive buffer. |
int |
getDataBits()
|
java.lang.String |
getDevName()
Returns the device name (OS name for port) |
static PortDriverInfo[] |
getDriverInfoList()
Returns device driver information for device name |
int |
getHandshake()
|
static int |
getInstanceLock()
Get the instance lock state. |
int |
getLibVer()
Returns the version number of the current serial port native lib (so/DLL) The most significant 16 bits contain the major version The least significant 16 bits contain the minor version |
int |
getMaxBitRate()
Return maximum bitrate supported on the platform |
java.lang.String |
getName()
Returns the name of this serial port object |
java.lang.String |
getName(int port)
Returns the name of this serial port object |
int |
getParity()
|
static java.lang.String[] |
getPortList()
Get list of ports from OS 'registry' First we check to see if a system property SERIAL_PORT_LIST is defined. |
static int |
getPortListMode()
|
java.lang.String |
getPortName()
|
int |
getPortNum()
Returns the port number for this serial port object |
static int |
getPowerMode(int slotNum)
Gets the port state for devices that support standby mode to save power. |
static int |
getResumeState(boolean clear)
Gets the state of the resume flag. |
static int |
getStatusAPM()
Gets the status of APM (advanced power management) |
int |
getStopBits()
|
int |
getTimeoutRx()
Returns the receive timeout interval of serial port object. |
int |
getTimeoutTx()
Returns the receive timeout interval of serial port object. |
boolean |
isOpen()
Indicates if port is currently open |
boolean |
isSupported(java.lang.String name)
Check for supported feature |
void |
open()
Open the SerialPortLocal object. |
void |
putByte(byte data)
Send byte out the serial port. |
void |
putData(byte[] data)
Send byte array contents to the serial port. |
void |
putData(byte[] data,
int dLen)
Deprecated. The preferred method is putData(dataBuf, off, len) |
void |
putData(byte[] data,
int off,
int dLen)
Send specificed length of the byte array to the serial port. |
void |
putString(java.lang.String s)
Send the string out the serial port. |
boolean |
readSinceRxBufCheck()
Returns flag indicating if data was read since last receive buffer check. |
void |
reset()
Reset a port object. |
void |
resetPortDriver(SerialConfig cfgObj)
Reset the OS driver Sometimes devices don't initialize correctly (mainly due to device firmware issues) This method resets the device driver on the port. |
int |
rxFlush()
Flushes the objects receive buffer (contents are discarded) |
boolean |
rxOverflow()
Returns true if the objects receive buffer overflowed since the last call to this method. |
int |
rxReadyCount()
Returns number of bytes in the objects receive buffer |
void |
sendBreak(int bLen)
Send a break signal on the line |
boolean |
sendSinceTxBufEmpty()
Returns flag indicating if data sent since last transmit buffer check. |
void |
setBitRate(int value)
|
void |
setConfig(SerialConfig serCfg)
Sets the the SerialConfig object |
void |
setDataBits(int value)
|
void |
setDTR(boolean onOff)
Set the DTR signal of objects serial port |
void |
setErrorStatusHandler(ErrorStatusHandler handler)
Sets the UnexpectedStatusHandler. |
void |
setHandshake(int value)
|
static int |
setInstanceLock(int mode)
Set the instance lock to SET or CLEAR state. |
void |
setName(java.lang.String spName)
Sets the name of this serial port object |
void |
setParity(int value)
|
static void |
setPortListMode(int value)
getPortList method will discover all COM ports or only active COM ports depending on setting of portListMode portListMode = 0; get only active ports portListMode = 1; get all ports |
void |
setPortName(java.lang.String name)
|
static void |
setPowerMode(int slotNum,
int pwrMode)
Sets the port state for devices that support standby mode to save power. |
void |
setRTS(boolean onOff)
Set the RTS signal of objects serial port. |
void |
setStopBits(int value)
|
void |
setTimeoutRx(int tmoRx)
Sets the receive timeout of the serial port object. |
void |
setTimeoutTx(int tmoTx)
Sets the transmit timeout of the serial port object. |
boolean |
sigBreak()
Returns true if the serial port for this object detected a break on the line since the last call to this method. |
boolean |
sigCD()
Returns state of serial port CD (Carrier Detect) signal Note: This may not be supported on all platforms |
boolean |
sigCTS()
Returns state of serial port CTS (Clear To Send) signal |
boolean |
sigDSR()
Returns state of serial port DSR (Data Set Ready) signal |
boolean |
sigFrameErr()
Returns true if the serial port for this object had a Framing Error since last call to this method. |
boolean |
sigOverrun()
Returns true if the serial port UART for this object had a was Overrun since last call to this method. |
boolean |
sigParityErr()
Returns true if the serial port for this object had a Parity Error Note: This may not be supported on all platforms since last call to this method. |
boolean |
sigRing()
Returns true if the serial port object detects a ring signal on the line. |
static java.util.ArrayList |
stripCOM(java.lang.String[] strings)
Strip "COM" from port names for efficient sorting in numeric order. |
int |
txBufCount()
Returns number of bytes in the objects transmit buffer |
int |
txDrain()
Drains the objects transmit buffer (contents are sent). |
int |
txFlush()
Flushes the objects transmit buffer (contents are discarded) |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static int buildNum
protected static StringCompare stringCompare
protected static SortVector svPortList
protected static java.util.Vector portList
protected static java.util.Vector portListInfo
protected static PortDriverInfo portInfo
protected static java.lang.String[] comPortNums
protected static java.util.List portNumList
protected static java.lang.String jspLib
protected static boolean jspLibLoaded
protected static int maxBitRate
protected ErrorStatusHandler esh
| Constructor Detail |
|---|
public SerialPortLocal()
public SerialPortLocal(SerialConfig cfgObj) throws java.io.IOException
cfgObj - The serial port configuration object
java.io.IOException - if error| Method Detail |
|---|
public void open()
throws java.io.IOException
java.io.IOException - if error
public void configure()
throws java.io.IOException
java.io.IOException - if errorpublic void configure(SerialConfig cfgObj) throws java.io.IOException
configure in interface SerialPortcfgObj - The serial port configuration object
java.io.IOException - if errorpublic void setConfig(SerialConfig serCfg)
setConfig in interface SerialPortserCfg - The serial port configuration objectpublic SerialConfig getConfig()
getConfig in interface SerialPort
public void close()
throws java.io.IOException
close in interface SerialPortjava.io.IOException - if error
public void reset()
throws java.io.IOException
java.io.IOException - if errorpublic void resetPortDriver(SerialConfig cfgObj) throws java.io.IOException
cfgObj - The serial port configuration object
java.io.IOException - if error
public void putByte(byte data)
throws java.io.IOException
putByte in interface SerialPortdata - The byte of data to output to the objects serial port
java.io.IOException - if error
public void putString(java.lang.String s)
throws java.io.IOException
putString in interface SerialPorts - The string to output to the objects serial port.
java.io.IOException - if error
public void putData(byte[] data)
throws java.io.IOException
putData in interface SerialPortdata - The byte array of data to output to the objects serial port
are not sent to the transmit buffer
java.io.IOException - if error
public void putData(byte[] data,
int dLen)
throws java.io.IOException
data - The byte array of data to output to the objects serial portdLen - The length from the beginning of the byte array that will be
output to the objects serial port.
java.io.IOException - if error
public void putData(byte[] data,
int off,
int dLen)
throws java.io.IOException
putData in interface SerialPortdata - The byte array of data to output to the objects serial portoff - The offset in the buffer where data will be sent fromdLen - The length of data that will be sent beginning at the offset
java.io.IOException - if error
public int getByte()
throws java.io.IOException
getByte in interface SerialPortjava.io.IOException - if error
public int getData(byte[] buf)
throws java.io.IOException
getData in interface SerialPortbuf - The byte array that will contain the data read from the objects
serial port.
java.io.IOException - if error
public int getData(byte[] buf,
int off,
int len)
throws java.io.IOException
getData in interface SerialPortbuf - the byte array buffer where data will be put when readoff - the offset in the buffer where data will be putlen - the length of data requested to be put in the buffer
java.io.IOException - if an error occurs.
public int rxFlush()
throws java.io.IOException
rxFlush in interface SerialPortjava.io.IOException - if port not open
public int txFlush()
throws java.io.IOException
txFlush in interface SerialPortjava.io.IOException - if port not open
public int txDrain()
throws java.io.IOException
txDrain in interface SerialPortjava.io.IOException - if port not open
public int rxReadyCount()
throws java.io.IOException
rxReadyCount in interface SerialPortjava.io.IOException - if error
public int txBufCount()
throws java.io.IOException
txBufCount in interface SerialPortjava.io.IOException - if error
public void clearReadSinceRxBufCheck()
public boolean sendSinceTxBufEmpty()
public void clearSendSinceTxBufEmpty()
public boolean readSinceRxBufCheck()
public boolean rxOverflow()
throws java.io.IOException
rxOverflow in interface SerialPortjava.io.IOException - if error
public boolean sigDSR()
throws java.io.IOException
sigDSR in interface SerialPortjava.io.IOException - if error
public boolean sigCTS()
throws java.io.IOException
sigCTS in interface SerialPortjava.io.IOException - if error
public boolean sigCD()
throws java.io.IOException
sigCD in interface SerialPortjava.io.IOException - if error
public boolean sigFrameErr()
throws java.io.IOException
sigFrameErr in interface SerialPortjava.io.IOException - if error
public boolean sigOverrun()
throws java.io.IOException
sigOverrun in interface SerialPortjava.io.IOException - if error
public boolean sigParityErr()
throws java.io.IOException
sigParityErr in interface SerialPortjava.io.IOException - if error
public boolean sigRing()
throws java.io.IOException
sigRing in interface SerialPortjava.io.IOException - if error
Note: This may not be supported on all platforms
public boolean sigBreak()
throws java.io.IOException
sigBreak in interface SerialPortjava.io.IOException - if error
public void setDTR(boolean onOff)
throws java.io.IOException
setDTR in interface SerialPortonOff - The state that the objects DTR line will be set to.
java.io.IOException - if error
public void setRTS(boolean onOff)
throws java.io.IOException
setRTS in interface SerialPortonOff - The state that the objects RTS line will be set to.
java.io.IOException - if error
Note: This may not be supported on all platforms
public void sendBreak(int bLen)
throws java.io.IOException
sendBreak in interface SerialPortbLen - The number of milliseconds for the break signal.
java.io.IOException - if error
public int getTimeoutRx()
throws java.io.IOException
getTimeoutRx in interface SerialPortjava.io.IOException - if error
public int getTimeoutTx()
throws java.io.IOException
getTimeoutTx in interface SerialPortjava.io.IOException - if error
public void setTimeoutRx(int tmoRx)
throws java.io.IOException
setTimeoutRx in interface SerialPorttmoRx - The number of milliseconds for the timeout.
java.io.IOException - if error
public void setTimeoutTx(int tmoTx)
throws java.io.IOException
setTimeoutTx in interface SerialPorttmoTx - The number of milliseconds for the timeout.
java.io.IOException - if errorpublic void setErrorStatusHandler(ErrorStatusHandler handler)
ush - The Handler.
java.io.IOException - if error
public static void setPowerMode(int slotNum,
int pwrMode)
throws java.io.IOException
slotNum - The card slot number (e.g. 0 for CF slot on Zaurus)pwrMode - The power mode
java.io.IOException - if error
public static int getPowerMode(int slotNum)
throws java.io.IOException
slotNum - The card slot number (e.g. 0 for CF slot on Zaurus)pwrMode - The power mode
java.io.IOException - if errorpublic static int getResumeState(boolean clear)
clear - Set true to clear the flag following the read.
public static int getStatusAPM()
java.io.IOException - if errorpublic int getPortNum()
getPortNum in interface SerialPortpublic void setName(java.lang.String spName)
setName in interface SerialPortpublic java.lang.String getName()
getName in interface SerialPortpublic java.lang.String getDevName()
public static PortDriverInfo[] getDriverInfoList() throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getName(int port)
public int getBuildNum()
public int getLibVer()
getLibVer in interface SerialPortpublic static int setInstanceLock(int mode)
mode - 1=SET, 0=CLEAR
public static int getInstanceLock()
public boolean isOpen()
public int getMaxBitRate()
public boolean isSupported(java.lang.String name)
isSupported in interface SerialPort
public static java.lang.String[] getPortList()
throws java.io.IOException
java.io.IOExceptionpublic static void addPortName(java.lang.String newName)
public static void addPortInfo(java.lang.String comName,
java.lang.String devMfgr,
java.lang.String devDesc)
public static void setPortListMode(int value)
public static int getPortListMode()
public static java.util.ArrayList stripCOM(java.lang.String[] strings)
protected void finalize()
finalize in class java.lang.Objectpublic void setPortName(java.lang.String name)
public java.lang.String getPortName()
public void setBitRate(int value)
public int getBitRate()
public void setDataBits(int value)
public int getDataBits()
public void setStopBits(int value)
public int getStopBits()
public void setParity(int value)
public int getParity()
public void setHandshake(int value)
public int getHandshake()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||