go-serial
go-serial copied to clipboard
Port.Write() returns nil error after partial write; does not adhere to the io.Writer contract
Describe the problem
(see https://github.com/bugst/go-serial/pull/192)
From the io.Writer GoDoc:
Write must return a non-nil error if it returns n < len(p).
The docs (doc.go
) indicate that serial.Port
implements the io.Writer
interface:
The port object implements the io.ReadWriteCloser interface, so we can use the usual Read, Write and Close functions to send and receive data from the serial port...
However, I have seen instances where serial.Port.Write()
reports success after a partial write. It seems the unix implementation forwards the data to the write syscall, but the syscall does not provide the same guarantee as io.Writer.
To reproduce
It varies by hardware/driver, but the steps would just be to open a port and write lots of data.
Please double-check that you have reported each of the following
before submitting the issue.
- [X] I've provided the FULL source code that causes the problem
- [X] I've provided all the actions required to reproduce the problem
Expected behavior
Write()
should either write the entire buffer and return err=nil, or it should return an error.
Operating system and version
Linux, seen on multiple versions
Please describe your hardware setup
No response
Additional context
No response
Issue checklist
- [X] I searched for previous requests in the issue tracker
- [X] My request contains all necessary details