Public abstract class CommPort extends java.lang.Object. A communications port. CommPort is an abstract class that describes a communications port made available by the underlying system. It includes high-level methods for controlling I/O that are common to different kinds of communications ports. May 16, 2016 SerialPort has been rock solid in production 24/7 for over 5 years. They support the standard Java serial API, as well as their own alternative proprietary one. I would stick with the standard API though, unless you really need something theirs has that the standard one doesn't, just to keep your options open. Answered Nov 5 '08 at 7:28. The Java Communications API (also known as javax.comm) provides applications access to RS-232 hardware (serial ports) and limited access to IEEE-1284 (parallel ports), SPP mode. Implementations of the API are currently available for Solaris SPARC, Solaris x86, and Linux x86. Public class SerialPort extends java.lang.Object. Driver for the RS-232 serial port on the roboRIO. The current implementation uses the VISA formatted I/O mode. This means that all traffic goes through the formatted buffers. This allows the intermingled use of print, readString, and the raw buffer accessors read and write. Reads up to bytesToRead raw data bytes from the serial port and stores them in the buffer. The length of the byte buffer must be greater than or equal to the value passed in for bytesToRead. In blocking-read mode, if no timeouts were specified or the read timeout was set to 0, this call will block until bytesToRead bytes of data have been successfully read from the serial port.
javax.comm
|
Field Summary | |
protected java.lang.String |
name |
Method Summary | |
void |
close() Closes the communications port. |
abstract void |
disableReceiveFraming() Disables receive framing. |
abstract void |
disableReceiveThreshold() Disables receive threshold. |
abstract void |
disableReceiveTimeout() Disables receive timeout. |
abstract void |
enableReceiveFraming(int framingByte) Enables receive framing, if this feature is supported by the driver. |
abstract void |
enableReceiveThreshold(int thresh) Enables receive threshold, if this feature is supported by the driver. |
abstract void |
enableReceiveTimeout(int rcvTimeout) Enables receive timeout, if this feature is supported by the driver. |
abstract int |
getInputBufferSize() Gets the input buffer size. |
abstract java.io.InputStream |
getInputStream() Returns an input stream. |
java.lang.String |
getName() Gets the name of the communications port. |
abstract int |
getOutputBufferSize() Gets the output buffer size. |
abstract java.io.OutputStream |
getOutputStream() Returns an output stream. |
abstract int |
getReceiveFramingByte() Gets the current byte used for receive framing. |
abstract int |
getReceiveThreshold() Gets the integer value of the receive threshold. |
abstract int |
getReceiveTimeout() Gets the integer value of the receive timeout. |
abstract boolean |
isReceiveFramingEnabled() Checks if receive framing is enabled. |
abstract boolean |
isReceiveThresholdEnabled() Checks if receive threshold is enabled. |
abstract boolean |
isReceiveTimeoutEnabled() Checks if receive timeout is enabled. |
abstract void |
setInputBufferSize(int size) Sets the input buffer size. |
abstract void |
setOutputBufferSize(int size) Sets the output buffer size. |
java.lang.String |
toString() Returns a String representation of this communications port. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
Method Detail |
getInputStream
returns null.
getInputStream
depends on combination of the threshold and timeout values. The possible behaviours are described in the table below:
Threshold | Timeout | Read Buffer Size | Read Behaviour | ||
---|---|---|---|---|---|
State | Value | State | Value | ||
disabled | - | disabled | - | n bytes | block until any data is available |
enabled | m bytes | disabled | - | n bytes | block until min(m,n) bytes are available |
disabled | - | enabled | x ms | n bytes | block for x ms or until any data is available |
enabled | m bytes | enabled | x ms | n bytes | block for x ms or until min(m,n) bytes are available |
java.io.IOException
- if an I/O error occurredgetOutputStream
returns null.java.io.IOException
- if an I/O error occurredclose
when it is done with the port. Notification of this ownership change will be propagated to all classes registered using addPortOwnershipListener
.read
from the input stream for this port will return immediately.
enableReceiveThreshold
is an advisory method which the driver may not implement. By default, receive threshold is not enabled.
enableReceiveThreshold
method and then calling the isReceiveThresholdEnabled
method. If isReceiveThresholdEnabled
still returns false, then receive threshold is not supported by the driver. If the driver does not implement this feature, it will return from blocking reads at an appropriate time.
getInputStream
for description of exact behaviour.
thresh
- when this many bytes are in the input buffer, return immediately from read
.UnsupportedCommOperationException
- is thrown if receive threshold is not supported by the underlying driver.read
from the input stream for this port will return immediately.
enableReceiveTimeout
is an advisory method which the driver may not implement. By default, receive timeout is not enabled.
enableReceiveTimeout
method and then calling the isReceiveTimeout
method. If isReceiveTimeout
still returns false, then receive timeout is not supported by the driver.
getInputStream
for description of exact behaviour.
rcvTimeout
- when this many milliseconds have elapsed, return immediately from read
, regardless of bytes in input buffer.UnsupportedCommOperationException
- is thrown if receive timeout is not supported by the underlying driver.read
from the input stream for this port will return immediately.
enableReceiveFraming
is an advisory method which the driver may not implement. By default, receive framing is not enabled.
enableReceiveFraming
method and then calling the isReceiveFramingEnabled
method. If isReceiveFramingEnabled
still returns false, then receive framing is not supported by the driver.
framingByte
- this byte in the input stream suggests the end of the received frame. Blocked reads will return immediately. Only the low 8 bits of framingByte
are used while the upper 24 bits are masked off. A value outside the range of 0-255 will be converted to the value of its lowest 8 bits.UnsupportedCommOperationException
- is thrown if receive timeout is not supported by the underlying driver.getReceiveFramingByte
is an integer, the low 8 bits of which represent the current byte used for receive framing.
size
- size of the input buffersize
- size of the output bufferPackage | Class | Tree | Deprecated | Index | Help |
PREV CLASS NEXT CLASS | FRAMESNO FRAMESAll Classes |
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Write something about yourself. No need to be fancy, just an overview.