Documentation
¶
Overview ¶
Package serialport opens and configures a physical serial port on the host. It is the host end of `clawk serial` — internal/serialfwd carries the bytes, internal/cli/serial_proxy.go brokers them, and this is what actually talks to the tty.
Only what forwarding needs is here: open a port (possibly named by a glob), put it in raw mode, apply a line configuration the guest asked for, and read and write bytes until someone closes it. No enumeration, no modem-line control, no flow control — see the serialfwd package comment for why the last of those can't be plumbed through a PTY anyway.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoMatch = errors.New("serialport: no device matches")
ErrNoMatch reports a device path that matched nothing. It is worth distinguishing because it is the ordinary "the board is unplugged, or is mid-reset" case, and the caller retries on it rather than giving up.
Functions ¶
Types ¶
type Port ¶
type Port struct {
// contains filtered or unexported fields
}
Port is an open serial port.
It embeds no lock: Read and Write may be called concurrently (they are, by the two halves of the proxy's pump), which is safe on an *os.File, but two concurrent Writes will interleave and two concurrent Reads will race for bytes. The proxy runs exactly one of each.
func Open ¶
Open resolves pattern, opens the device, and puts it in raw mode with mode's line configuration.
pattern may be a literal path or a glob. A glob is resolved here, at open time, rather than when the device was configured: a board that reboots into its bootloader disappears from /dev and comes back — often under a neighbouring name — and re-globbing on each open is what lets a forward survive that. A glob matching several devices is an error rather than a guess, because picking the wrong board silently is worse than saying so.
func (*Port) Close ¶
Close releases the port. On a tty configured by Open this lowers DTR, which on a board wired for auto-reset is half of the reset pulse the next Open completes — see the serialfwd package comment.