Comments (2)
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.
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)
- How to set ioctl flags?
- Windows Timeout in Milliseconds HOT 1
- mipsle error
- mips error: serial.Open: SYS_IOCTL: inappropriate ioctl for device HOT 1
- windows pipe serial problem
- Feature Request: Send BREAK Signal HOT 1
- Help with preventing program from panicking out if no USB is found HOT 1
- 100% CPU on darwin
- On OpenWRT : error opening port:%!(EXTRA *os.SyscallError=SYS_IOCTL: inappropriate ioctl for device) HOT 17
- Linux and communication errors HOT 1
- Flush buffer HOT 3
- function read alway error on macOS
- Read cannot be interrupted by Close HOT 12
- How can I check CTS status?
- Linux 2 stop bits HOT 3
- Error opening serial port: SYS_IOCTL: inappropriate ioctl for device HOT 1
- Read() to buffer for specific time and then return
- Please release v1.0.0 HOT 1
- Unable to properly reopen serial device after it disappears
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-serial.