serial

package module
v0.0.0-...-46f5dd1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package serial is a library for I/O over serial devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindUSB

func FindUSB(vendor, product int) (string, error)

FindUSB returns the /dev/tty* path corresponding to the USB serial device with the given vendor and product identifiers.

Types

type DeviceNotFoundError

type DeviceNotFoundError struct {
	Vendor  int
	Product int
}

DeviceNotFoundError indicates that no USB device was found with the given vendor and product identifiers.

func (DeviceNotFoundError) Error

func (e DeviceNotFoundError) Error() string

type NotCharDeviceError

type NotCharDeviceError string

NotCharDeviceError indicates that the given device pathname is not a character device.

func (NotCharDeviceError) Error

func (e NotCharDeviceError) Error() string

type Port

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

A Port represents an open serial device.

func Open

func Open(device string, speed int) (*Port, error)

Open opens the specified serial device.

func (*Port) Close

func (port *Port) Close() error

Close closes the given Port.

func (*Port) Read

func (port *Port) Read(buf []byte) error

Read reads from port into buf, blocking if necessary until exactly len(buf) bytes have been read.

func (*Port) ReadAvailable

func (port *Port) ReadAvailable(buf []byte) (int, error)

ReadAvailable reads available data from port into buf and returns the number of bytes read.

func (*Port) Write

func (port *Port) Write(buf []byte) error

Write writes len(buf) bytes from buf to port.

type TTYNotFoundError

type TTYNotFoundError string

TTYNotFoundError indicates that no tty device was associated with the given USB device, probably because the required cdc_acm kernel module has not been loaeded.

func (TTYNotFoundError) Error

func (e TTYNotFoundError) Error() string

Jump to

Keyboard shortcuts

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