0
情況: 我想從我的目的使SerialPort有用的傳入數據。在一個類Processor.java中,我實現了幾個方法 - 其中一個(serialEvent)實現了gnu.io.SerialPortEventListener。它將從inputStream中讀取的信息存儲在一個字節數組的緩衝區中。還有一種將數據寫入outputStream的方法。RXTX中的同步方法
問題: 我想要實現的方法(在同一個班),這將寫的東西依賴於從InputStream讀取消息的OutputStream。
僞代碼:
@Override
public void serialEvent(SerialPortEvent event) {
// get data
}
public void writeData(String dataToWrite) {
// write data
}
public void respond() {
// write data
// wait for appropriate response (read data)
// write data
// ...
}
我怎樣才能做到這一點?