私はRXTXとPureJavaCommを何度も何度も使ってきました。私は自分のアプリケーションでこのコードを持っている:javax.comm.CommPortのセマンティクスenableReceiveThreshold(1)とenableReceiveTimeout
SerialPort port = /* code to get serial port instance here */
port.setInputBufferSize(65536);
port.enableReceiveThreshold(1);
port.enableReceiveTimeout(10);
(1文字の閾値を、10msのタイムアウトを)と私は上記の式に到着するまで、これを微調整するの漠然とした思い出がありますが、私に恥、私はしませんでしたそれがなぜこのようなのかをメモしてください。
データが受信されていない場合、最小のブロック遅延でInputStream.read()
コールに応答し、それ以外の場合はすでに受信した文字を返します。
私が覚えていないのは、理由/ enableReceiveThreshold(1)
の呼び出しが必要かどうかです。 既に受信タイムアウトがある場合、enableReceiveThreshold(1)
とdisableReceiveThreshold()
の違いは何ですか?
PureJavaCommはreceiveTimeout
あるので、あなたはvmin=1
にvmin=0
を比較する場合COMMTIMEOUTS
構造が異なる値を取得しますvmin
がreceiveThreshold
とvtime
あるsrc/jtermios/windows/JTermiosImpl.java
でのWindowsのためのこのコードを持っています(How do I use COMMTIMEOUTS to wait until bytes are available but read more than one byte?でいくつかの詳細な議論を)
COMMTIMEOUTS touts = port.m_Timeouts;
// There are really no write timeouts in classic unix termios
// FIXME test that we can still interrupt the tread
touts.WriteTotalTimeoutConstant = 0;
touts.WriteTotalTimeoutMultiplier = 0;
if (vmin == 0 && vtime == 0) {
// VMIN = 0 and VTIME = 0 => totally non blocking,if data is
// available, return it, ie this is poll operation
touts.ReadIntervalTimeout = MAXDWORD;
touts.ReadTotalTimeoutConstant = 0;
touts.ReadTotalTimeoutMultiplier = 0;
}
if (vmin == 0 && vtime > 0) {
// VMIN = 0 and VTIME > 0 => timed read, return as soon as data is
// available, VTIME = total time
touts.ReadIntervalTimeout = 0;
touts.ReadTotalTimeoutConstant = vtime;
touts.ReadTotalTimeoutMultiplier = 0;
}
if (vmin > 0 && vtime > 0) {
// VMIN > 0 and VTIME > 0 => blocks until VMIN chars has arrived or between chars expired,
// note that this will block if nothing arrives
touts.ReadIntervalTimeout = vtime;
touts.ReadTotalTimeoutConstant = 0;
touts.ReadTotalTimeoutMultiplier = 0;
}
if (vmin > 0 && vtime == 0) {
// VMIN > 0 and VTIME = 0 => blocks until VMIN characters have been
// received
touts.ReadIntervalTimeout = 0;
touts.ReadTotalTimeoutConstant = 0;
touts.ReadTotalTimeoutMultiplier = 0;
}
if (!SetCommTimeouts(port.m_Comm, port.m_Timeouts))
port.fail();
sigh。それで、テーブルマークアップを使用できないのは嬉しいですか? –