protected class RS485ReadWriteServer.ReadWrite extends Thread
RS485ReadWriteServer#lock object.
RS485ReadWriteServer.writeString(java.lang.String) method to write the command
it was constructed with to the serial port.RS485ReadWriteServer.KEY_CR
character is read or the number of bytes to read is reached.RS485ReadWriteServer.interpretString(java.lang.String) method.#lock object and dies.getResult() method.cancel flag to true. This allows the
thread to die prematurely. In this case, the serial line is cleared of
any remaining bytes. These bytes are copied to the getResult()
method. The correct execution of the thread can be queired with the
isCancel() method.Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
private boolean |
busy
The bsuy flag indicating that a read/write cycle is in progress.
|
private boolean |
cancel
The cancel flag.
|
private String |
command
The command to write to the serial line.
|
private String |
result
The result read-in from the serial line.
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Modifier | Constructor and Description |
|---|---|
protected |
ReadWrite(String cmd)
Constructs a new, self-starting read/write thread.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getResult()
Returns the result of the read associated with this thread.
|
boolean |
isBusy()
Returns the status of the busy flag.
|
boolean |
isCancel()
Returns the status of the cancel flag.
|
void |
run()
The run command.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldprivate boolean cancel
private final String command
private String result
private boolean busy
protected ReadWrite(String cmd)
public void run()
cancel
variable.public String getResult()
If this method is called while the reading thread is still alive, we
join on the read thread for a maximum of RS485ReadWriteServer.KEY_RESPONDTIME ms.
If the thread is still alife after that period, the read thread is
canceld, and we join again on the thread until it really dies.
public boolean isCancel()
getResult() method received a time-out during waiting for
the retrieval of the data. If this method is called prior to the
getResult() method it will always return false.public boolean isBusy()