Coder Social home page Coder Social logo

Comments (2)

chinenual avatar chinenual commented on September 4, 2024

I still believe this is probably a bug -- Nonzero InterCharacterTimeout and non-zero MinimumReadSize is supposed to cause read to block, but what I'm actually seeing is an immediate return of the Read with n=0 and err=nil.

My workaround is to treat that condition as a "block", like this in my goroutine:

	go func () {
		var arr []byte = make([]byte,1);
		for {
			select {
			case <- readerChannelQuit:
				close(readerChannelQuit)
				close(readerChannel)
				return
			default:
				var response serialReadResponse
				var n int
				n, response.err = stream.Read(arr);
				if err != nil {
					response.data = 0
					readerChannel <- response
				} else if n == 1 {
					response.data = arr[0]
					readerChannel <- response
				} else if err == nil {
					// on windows, despite asking for blocking IO
					// the Read is returning immediately with
					// n == 0, but no error.  Sleep for a
					// while so we don't chew up infinite CPU
					time.Sleep(time.Duration(500) * time.Millisecond)
				}
			}
		}
	}()

from go-serial.

chinenual avatar chinenual commented on September 4, 2024

My work around (above) is not really practical. While this does emulate blocking IO, it results in SUPER SLOW reads -- apparently even when there is data on the line, I'm getting at least as many empty reads that good ones - so that 1/2 second delay is effectively happening on every byte.

Hoping someone else using the library on Windows has some insights...

from go-serial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.