usbserial

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package usbserial provides a simple USB CDC ACM serial driver. The main goal is simplicity, small code size and robustness but not speed.

The USB protocol is packet-oriented. This package simulates a stream-oriented device using a packet-oriented protocol. If all you want to do is sending and/or receiving packets of data over an USB its better and quite easy to use the CDC ACM data endponts with the usb package directly. Such approach will use the native packet/transaction oriented interface with the minimal overhead and maximum possible speed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

A Serial is a simple CDC ACM driver.

func NewDriver

func NewDriver(d *usb.Device, interf uint8, rxe, txe int8, maxPkt int) *Driver

NewDriver... rxe (host out), txe (host in). MaxPkt must be power of two and equal or multiple of the maximum packet size declared in the OUT endpoint descriptor used by this driver as Rx endpoint.

func (*Driver) Flush

func (s *Driver) Flush() error

Flush ensures that the last data written were sent to the USB host.

func (*Driver) Read

func (s *Driver) Read(p []byte) (n int, err error)

Read implements io.Reader interface.

func (*Driver) SetAutoFlush

func (s *Driver) SetAutoFlush(af bool)

SetAutoFlush enables/disables the AutoFlush mode. If AutoFlush is enabled, Write calls Flush before exit.

func (*Driver) SetWriteSink

func (s *Driver) SetWriteSink(ws bool)

SetWriteSink the WriteSink mode. Enabled WriteSink mode ensures that writes will not block if the USB serial device is not open for reading on the host side.

func (*Driver) Write

func (s *Driver) Write(p []byte) (n int, err error)

Write implements io.Writer interface.

func (*Driver) WriteString

func (s *Driver) WriteString(p string) (n int, err error)

WriteString implements io.StringWriter interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL