Skip to content

Commit

Permalink
Windows: use MAXDWORD - 1 for ReadTotalTimeoutConstant for the Blocki…
Browse files Browse the repository at this point in the history
…ng case.

The MSDN documentation is unclear on what happens when it's set to
MAXDWORD.  I don't have the capability to test across different
windows versions with multiple serial devices, so this seems to be the
safer option since this is what other libraries seem to do.

For example here:
http://forums.ni.com/attachments/ni/140/18925/1/SerialENETWrite.cpp

This link suggests another option for Blocking:
http://stackoverflow.com/questions/10390151/how-do-i-use-commtimeouts-to-wait-until-bytes-are-available-but-read-more-than-o

The documentation is poor about these different corner cases, but
MAXDWORD-1 seems to be a fairly safe choice.
  • Loading branch information
Tarmigan Casebolt committed Nov 13, 2015
1 parent 96dc705 commit edb6653
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion serial_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func setCommTimeouts(h syscall.Handle, readTimeout time.Duration) error {
const MAXDWORD = 1<<32 - 1

// blocking read by default
var timeoutMs int64 = MAXDWORD
var timeoutMs int64 = MAXDWORD - 1

if readTimeout > 0 {
// non-blocking read
Expand Down

0 comments on commit edb6653

Please sign in to comment.