Repository navigation
go-serial v0.4.0
Date: 2026-11-14
Previous release: v0.3.0
Summary
Close cancels blocked I/O on POSIX systems, long timeouts are honoured on every platform, and the Windows backend returns available data with no timeout set.
Changes
Added
ErrClosed, returned on POSIX systems byReadandWriteon a closed port, and by aReadorWritethat was blocked whenCloseran in another goroutine.
Changed
- POSIX:
Closemay run concurrently withReadandWrite. It wakes them, waits until they have let go of the descriptor, then restores termios and closes it. Each port holds a pipe for this, so it uses two more descriptors. - POSIX:
ReadandWriteafterClosereturnErrClosedinstead of anEBADFerror. - macOS and the BSDs:
OpenwithConfig.RS485.Enabledfails withErrUnsupportedPlatforminstead of sending Linux's ioctl number. - Windows:
Closeis safe to call from several goroutines.
Fixes
- macOS:
Readfailed at once with "invalid argument" whenConfig.Timeoutwas above 10^8 seconds, whichselectdoes not accept. Longer waits are now made in several calls. - FreeBSD, NetBSD, OpenBSD: a
Config.Timeoutof 2^31 ms or more did not fitpoll's timeout argument. It is now clamped per call and waited in several calls. - Linux: the
ppolltimeout is clamped so 32-bit systems cannot truncate it. - Linux on MIPS: RS-485 used the wrong ioctl request number and could not be enabled.
- Windows: with
Timeout == 0,Readwaited for the whole buffer to fill. It now returns as soon as data arrives, as on POSIX. - Windows: a timeout below one millisecond turned into no timeout, and timeouts of 2^32 ms or more wrapped around. They are now rounded up and capped at 2^32-2 ms.
- Windows:
Openrejects baud rates above 2^32-1 instead of truncating them. - Windows: the DCB passed to
SetCommStatehas itsDCBlengthset; if setting the timeouts fails,Openrestores the previous DCB before closing. - Windows:
Readwith an empty buffer returns0, nilinstead ofErrTimeout. - The test package builds on 32-bit platforms.
Documentation
- LIMITATIONS.md: on Windows a
Writemay wait for a pendingRead(one synchronous handle), andReaddoes not report line errors (parity, framing, break).