Documentation
¶
Overview ¶
Package serial allows communication with serial ports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RemotePort ¶
type RemotePort struct {
// contains filtered or unexported fields
}
RemotePort allows communication with a serial port on a remote dut.
func (*RemotePort) Close ¶
func (p *RemotePort) Close(ctx context.Context) error
Close the connection. The port should not be used afterwards.
func (*RemotePort) Flush ¶
func (p *RemotePort) Flush(ctx context.Context) error
Flush un-read/written data on the port.
func (*RemotePort) Read ¶
Read bytes into buffer and returns the number of bytes read. Bytes already written to the port shall be moved into buf, up to its size. In blocking mode (port opened without ReadTimeout), it blocks until at least one byte is read. In non-blocking mode, it may return an error with zero bytes read if ReadTimeout is exceeded, however this is not guaranteed on all platforms and so a context deadline exceeded error may be returned even though the deadline is greater than the ReadTimeout.
type RemotePortOpener ¶
type RemotePortOpener struct {
// contains filtered or unexported fields
}
RemotePortOpener holds data needed to open a RemotePort.
func NewRemotePortOpener ¶
func NewRemotePortOpener(client pb.SerialPortServiceClient, name string, baud int, readTimeout time.Duration) *RemotePortOpener
NewRemotePortOpener creates a RemotePortOpener.
Example:
rpcClient, err := rpc.Dial(ctx, s.DUT(), s.RPCHint()) defer rpcClient.Close(ctx) if err != nil { s.Fatal("rpcDial: ", err) } defer rpcClient.Close(ctx) serviceClient := pb.NewSerialPortServiceClient(rpcClient.Conn) opener := NewRemotePortOpener(serviceClient, "/path/to/device", 115200, 2 * time.Second) port := opener.OpenPort(ctx)