|
jSyncManager | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jSyncManager.JSerial.SerialInterface
A class for accessing serial port functionality via Java. This class provides serial port functionality to Java programs, allowing them to set various port parameters, read and write to the port, and grab and release the port. The serial functionality is presented as a set of standard Java InputStream/OutputStreams, making it easily interchangable with entities such as java.net.Socket.
Field Summary | |
static int |
EVENPARITY
Used to specify the use of even parity. |
static int |
MARKPARITY
Used to denote the use of mark parity. |
static int |
NOPARITY
Used to specify the use of no parity. |
static int |
ODDPARITY
Used to specify the use of odd parity. |
static int |
SPACEPARITY
Used to denote the use of space parity. |
Constructor Summary | |
SerialInterface(byte port)
Starts a new serial interface using the given port identifier at the default speed (9600bps) using 8 data bits, no parity, and 1 stop bit and starts off with the port in "grabbed" mode. |
|
SerialInterface(byte port,
int speed)
Starts a new serial interface using the given port, at the given speed, using 8 data bits, no parity, and 1 stop bit and starts off with the port in "grabbed" mode. |
|
SerialInterface(byte port,
int speed,
int databits,
int parity,
int stopbits,
boolean status)
Starts a new serial interface using the given port at the given speed, using the given values for data bits, parity and stop bits. |
Method Summary | |
protected void |
finalize()
Finalizes this object. |
int |
getCurrentDatabits()
Used to get the current data bit size. |
int |
getCurrentParity()
Returns the current serial interface parity. |
byte |
getCurrentPort()
Used to get the current serial port id number. |
int |
getCurrentSpeed()
Used to get the current serial speed. |
int |
getCurrentStopbits()
Used to get the current stop bit size. |
boolean |
getDSRDTRState()
Queries the state of the DSR/DTR handshaking. |
java.io.InputStream |
getInputStream()
This method returns the current input stream. |
java.io.OutputStream |
getOutputStream()
This method returns the current output stream. |
SerialPeer |
getPeer()
Used to get ahold of the handle to the Serial Peer class. |
static java.lang.String |
getPeerVersion()
Used to get the version number of the native code peer class. |
static java.lang.String |
getPlatformName()
Used to get the name of the platform to which the native code portion is written. |
boolean |
getRTSCTSState()
Queries the state of the RTS/CTS handshaking. |
boolean |
getXONXOFFState()
Queries the state of the XON/XOFF handshaking. |
void |
grabPort()
This method will grab a released port. |
boolean |
isReleased()
Used to check the status of the port assigned to this instance of the SerialInterface. |
void |
releasePort()
Releases the port back to the OS's use, but keeps the peer and streams alive. |
void |
setCurrentDatabits(int databits)
Used to set the current serial data bit size. |
void |
setCurrentParity(int parity)
Used to set the current serial parity. |
void |
setCurrentSpeed(int speed)
Used to set the current serial speed. |
void |
setCurrentStopbits(int stopbits)
Used to set the current serial stop bit size. |
void |
setDSRDTR(boolean state)
A method to set the state of the DSR/DTR handshaking. |
void |
setRTSCTS(boolean state)
A method to set the state of the RTS/CTS handshaking. |
void |
setXONXOFF(boolean state)
A method to set the state of the XON/XOFF handshaking. |
void |
transmitBreak(long length)
Transmits a break signal. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int NOPARITY
public static final int ODDPARITY
public static final int EVENPARITY
public static final int MARKPARITY
public static final int SPACEPARITY
Constructor Detail |
public SerialInterface(byte port) throws SerialInitializationException, SerialSpeedException, SerialDataBitException, SerialParityException, SerialStopBitException, SerialGrabException
port
- the identifier of the serial port to open
SerialInitializationException
- thrown if the port cannot be opened.
SerialSpeedException
- thrown if the given speed is invalid or unsupported.
SerialDataBitException
- thrown if the given data bit size is invalid.
SerialParityException
- thrown if the given parity is invalid.
SerialStopBitException
- thrown if the current stop-bit size is invalid.
SerialGrabException
- thrown if status is true, and the port is currently not available.public SerialInterface(byte port, int speed) throws SerialInitializationException, SerialSpeedException, SerialDataBitException, SerialParityException, SerialStopBitException, SerialGrabException
port
- the identifier of the serial port to openspeed
- the speed at which to initialize the port
SerialInitializationException
- thrown if the port cannot be opened.
SerialSpeedException
- thrown if the given speed is invalid or unsupported.
SerialDataBitException
- thrown if the given data bit size is invalid.
SerialParityException
- thrown if the given parity is invalid.
SerialStopBitException
- thrown if the current stop-bit size is invalid.
SerialGrabException
- thrown if status is true, and the port is currently not available.public SerialInterface(byte port, int speed, int databits, int parity, int stopbits, boolean status) throws SerialInitializationException, SerialSpeedException, SerialDataBitException, SerialParityException, SerialStopBitException, SerialGrabException
port
- the identifier of the serial port to openspeed
- the speed at which to initialize the portdatabits
- the number of data bits per byte to transmit/receiveparity
- the parity type for a single bytestopbits
- the number of stop bits in a single bytestatus
- the desired "grab" status.
If true the port is grabbed during construction, otherwise everything is prepared,
but the port is left in the non-"grabbed" state.
SerialInitializationException
- thrown if the port cannot be opened.
SerialSpeedException
- thrown if the given speed is invalid or unsupported.
SerialDataBitException
- thrown if the given data bit size is invalid.
SerialParityException
- thrown if the given parity is invalid.
SerialStopBitException
- thrown if the current stop-bit size is invalid.
SerialGrabException
- thrown if status is true, and the port is currently not available.Method Detail |
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public static java.lang.String getPlatformName()
public static java.lang.String getPeerVersion()
public byte getCurrentPort()
public int getCurrentSpeed()
public void setCurrentSpeed(int speed) throws SerialSpeedException
speed
- the desired serial communications speed.
SerialSpeedException
- thrown if the given speed is invalid or unsupported.public int getCurrentDatabits()
public void setCurrentDatabits(int databits) throws SerialDataBitException
databits
- the desired number of data bits per transmission byte.
SerialDataBitException
- thrown if the given data bit size is invalid.public int getCurrentParity()
public void setCurrentParity(int parity) throws SerialParityException
parity
- the desired parity type (ie: EVENPARITY, ODDPARITY, NOPARITY, MARKPARITY).
SerialParityException
- thrown if the given parity is invalid.public int getCurrentStopbits()
public void setCurrentStopbits(int stopbits) throws SerialStopBitException
stopbits
- the desired number of stop bits ber transmission byte
SerialStopBitException
- thrown if the given stop bit size is invalid.public SerialPeer getPeer()
public void releasePort() throws SerialReleaseException
SerialReleaseException
- thrown if there is a problem releasing the current portpublic void grabPort() throws SerialGrabException
SerialGrabException
- thrown if the port is not available, or is already in the "grabbed" state.public boolean isReleased()
protected void finalize() throws java.lang.Throwable
java.lang.Throwable
- any Throwable that occurs during finalization.public void setRTSCTS(boolean state) throws SerialHandshakingException
state
- if true, enables RTS/CTS hardware handshaking.
SerialHandshakingException
- thrown if the serial driver is unable to change modes.public void setDSRDTR(boolean state) throws SerialHandshakingException
state
- if true, enables hardware handshaking.
SerialHandshakingException
- thrown if the serial driver is unable to change modes.public void setXONXOFF(boolean state) throws SerialHandshakingException
state
- if true, enables software handshaking.
SerialHandshakingException
- thrown if the serial driver is unable to change modes.public void transmitBreak(long length)
length
- how long, in milliseconds, to transmit the break signal.public boolean getRTSCTSState()
public boolean getDSRDTRState()
public boolean getXONXOFFState()
|
jSyncManager | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |