nyholku / purejavacomm

Pure Java implementation of JavaComm SerialPort
http://www.sparetimelabs.com/purejavacomm/index.html
BSD 3-Clause "New" or "Revised" License
366 stars 146 forks source link

Maximum receive timeout value #125

Open rhaabu opened 5 years ago

rhaabu commented 5 years ago

Is there a reason why the maximum receive timeout is 25500ms (25.5s) or can this limit be changed to a larger value without unexpected behaviour?

@Override
synchronized public void enableReceiveTimeout(int value) throws UnsupportedCommOperationException {
    if (value < 0)
        throw new IllegalArgumentException("threshold" + value + " < 0 ");
    if (value > 25500)
        throw new UnsupportedCommOperationException("threshold" + value + " > 25500 ");

    checkState();
    synchronized (m_ThresholdTimeoutLock) {
        m_ReceiveTimeoutEnabled = true;
        m_ReceiveTimeoutValue = value;
        thresholdOrTimeoutChanged();
    }
}
nyholku commented 5 years ago

IIRC (it has been years since I implemented this) but at least on some platform this is a byte value by the time it gets to the native API call where it is the timeout in 100m seconds. You can easily see where that happens in the code. To extend that beyond the 100x255 value would require some work, probably not much.