Closed kennylevinsen closed 4 years ago
I fixed this problem domain entirely differently: https://github.com/raggi/goserial/commit/94030bfae5871e13aa9859b79542c52988292875
I'm not sure what the non-blocking semantics are for, but they're not all that useful, the go runtime handles blocking io multiplexing for us.
I was experiencing some quite severe difficulties with the "posix" handling on my OS X machines. After a while with a constant 115200baud datastream, the stream would stop, and usbd would have issues with 60% idle load.
I had pyserial in my toolbox which I knew worked just fine on the same machine with same speeds and payloads. So, I took serial_linux.go (The implementation was nicer to my eye), and mangled it so it was closer to pyserial's behaviour, both in flags and how to set baudrate on Darwin (Which happens using a special ioctl for IOKit, instead of the legacy posix approach).
I have now successfully run with a constant payload over several hours without it pausing randomly, while it would usually pause after 5 minutes before. It's not very scientific, but it works, and it's prettier than before. serial_posix.go is maintained for other platforms, but the platform-specific handling should probably be unified at some point, as it boils down to flag availability (Do we have an easy way to detect this?), and baudrate method/availability.