-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timeout for RX and TX on ISerialIOStream #23
Comments
|
Hello, thank you for your answer. So I came to the Windows doc here: And in the Remark parts it say:
So it seem that it's what I'm looking for get a simple read timeout.
But it's not possible since it's a negative number with int parameter type and so the function fire an exception. I tried with Integer.MAX_VALUE, it seem to work but by reading the documentation, it imply multiplyer depending on number of byte to read which is not what I want... So is there any solution to use the MAXDWORD in your function? PS: In your example of function for Windows you says that's it's for 500ms tiemout:
How is it possible with all parameters to 0? Regards |
A quick thought, try this: Ignore that all 0 code, it was under development. I will update. |
I cannot say if this works for the moment but reading the documentation involve that this set the ReadTotalTimeoutMultiplier and so:
So it seem not what I expect. Also I always have problem to determine if a timeout occur:
So what if I read on the _inputStream with:
If it return -1, End of stream occured, but how to detect timeout on this case? How to know that no byte was read because of timeout and not because the port was closed? Regards |
Another issue appear: Very often I get the following exception
This occur only when receiving byte in serial port and the function fineTuneReadBehaviour was previously called on the port. If I don't call fineTuneReadBehaviour after opening the port, then this error seem to not occur. Also it seem that on Windows RX timeout is not working since read with a tab never reurn 0. |
There are two goals. One timed read and second port close. Configure finetuneread as mentioned and use non blocking mode when creating stream. This will address goal one. For second goal you will need hardware and driver support. So first we close item one then move to item two. |
Hi! The timeout with fineTuneReadBehaviour on Linux is working, but on Windows it seem to not works properly, I tryed with many parameters: fineTuneReadBehaviour(_handle, 0, 0, 3000, 0, 0); |
|
I have also updated example application for timed read TimeoutReadCallApp.java |
Hello,
I settled your lib which seem to works (I can transmit and receive in BLOCKING mode) I'm currently on Windows but project will need to work on Linux Desktop and Windows.
I wanted to add timeout for the receive parts, so it seem I need to use NONBLOCKING mode:
_outputStream = (SerialComOutByteStream) _serial.getIOStreamInstance(SerialComManager.OutputStream, _handle, SMODE.NONBLOCKING);
_inputStream = (SerialComInByteStream) _serial.getIOStreamInstance(SerialComManager.InputStream, _handle, SMODE.NONBLOCKING);
Now I'm stuck because I cannot find a place where I can set the Timeout for RX parts.
I saw the following function:
But I don't know how to use it. What are the parameters values. I need for example 3000ms of read timeout.
Also I need to differenciate a timeout exception from an error on the stream (ie: if read function on byteStream return -1 for error on stream, what is returned when it timeout? An exception?).
Any help or answer will be appreciated :-)
Regards.
The text was updated successfully, but these errors were encountered: