Skip to content
Browse files

Added VMIN and VTIME fields, for #1.

  • Loading branch information...
1 parent 7a5c76a commit 363e2b4c43e736f738ef577d94e2bf1006c5ea57 @jacobsa jacobsa committed
Showing with 39 additions and 0 deletions.
  1. +39 −0 serial/serial.go
View
39 serial/serial.go
@@ -72,6 +72,45 @@ type OpenOptions struct {
// are simply ignored; that is, bytes are delivered to the user no matter
// whether they were received with a parity error or not.
ParityMode ParityMode
+
+ // An inter-character timeout value, in milliseconds, and a minimum number of
+ // bytes to block for on each read. A call to Read() that otherwise may block
+ // waiting for more data will return immediately if the specified amount of
+ // time elapses between successive bytes received from the device or if the
+ // minimum number of bytes has been exceeded.
+ //
+ // Note that the inter-character timeout value may be rounded to the nearest
+ // 100 ms on some systems, and that behavior is undefined if calls to Read
+ // supply a buffer whose length is less than the minimum read size.
+ //
+ // Behaviors for various settings for these values are described below. For
+ // more information, see the discussion of VMIN and VTIME here:
+ //
+ // http://www.unixwiz.net/techtips/termios-vmin-vtime.html
+ //
+ // InterCharacterTimeout = 0 and MinimumReadSize = 0 (the default):
+ // This arrangement is not legal; you must explicitly set at least one of
+ // these fields to a positive number. (If MinimumReadSize is zero then
+ // InterCharacterTimeout must be at least 100.)
+ //
+ // InterCharacterTimeout > 0 and MinimumReadSize = 0
+ // If data is already available on the read queue, it is transferred to
+ // the caller's buffer and the Read() call returns immediately.
+ // Otherwise, the call blocks until some data arrives or the
+ // InterCharacterTimeout milliseconds elapse from the start of the call.
+ //
+ // InterCharacterTimeout > 0 and MinimumReadSize > 0
+ // Calls to Read() return when at least MinimumReadSize bytes are
+ // available or when InterCharacterTimeout milliseconds elapse between
+ // received bytes. The inter-character timer is not started until the
+ // first byte arrives.
+ //
+ // InterCharacterTimeout = 0 and MinimumReadSize > 0
+ // Calls to Read() return only when at least MinimumReadSize bytes are
+ // available. The inter-character timer is not used.
+ //
+ InterCharacterTimeout uint
+ MinimumReadSize uint
}
// Open creates an io.ReadWriteCloser based on the supplied options struct.

0 comments on commit 363e2b4

Please sign in to comment.
Something went wrong with that request. Please try again.