PORTS Forum
Ports and Interfaces => Serial Ports => Topic started by: towlerg on November 05, 2016, 07:31:33 am
-
Hi
for reasons that I won't bore you with, I'm trying to use a PC serial port to a PIC, running a super simple data-ack protocol. I'm using the native functions of my compiler and I'm seeing a 20msec. ish delay/latency/timeout between the PIC sending and the PC responding. After wallowing about on several boards I've been guided toward using ReadFile/WriteFile and the comms timeout settings. Having read the MSDN page on comms timeouts (https://msdn.microsoft.com/en-us/library/windows/desktop/aa363190(v=vs.85).aspx) more times than I care to admit, I still don't understand them. I'm going to try using non-overlapped, just to see what the minimum latency is. What timeout settings will prevent timeouts from having any influence?
George
-
If you don't want any timeouts, use zero.
-
Thanks.
Does that apply to ReadIntervalTimeOut, word on the street was that he should be set to %MAXDWORD (ie -1)?
-
The documentation says:
A value of zero indicates that interval time-outs are not used.
A value of MAXDWORD, combined with zero values for both the ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members, specifies that the read operation is to return immediately with the bytes that have already been received, even if no bytes have been received.
So if you want to wait until data arrives, use zero. If you want to return immediately with whatever data has been received, use MAXDWORD.
-
Thanks for clearing that up. One less variable.
-
Happy to help.