serenum

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: MIT Imports: 8 Imported by: 2

README

GoDoc

Go package for the enumeration of a system's serial ports.

Documentation

Overview

Package serenum implements enumeration of a system's serial ports.

Index

Constants

View Source
const StdFormat = `` /* 358-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type PortInfo

type PortInfo struct {
	Desc   string
	Device string
	Driver string

	VendorID     string
	ProductID    string
	Manufacturer string
	SerialNumber string

	Enumerator string
}

func Lookup

func Lookup(portName string) *PortInfo

Lookup returns information about the named serial port. On failure, a PortInfo with just the Device field set to portName will be returned.

func Ports

func Ports() (ports []*PortInfo)

Ports gathers information about the serial ports present on a system, by examining information from sysfs, especially from /sys/class/tty. Devices that have no driver entry are skipped, as well as devices that symlink into /sys/devices/platform. If a device is an USB device, additional information like VID, PID will be extracted. The resulting list containing one item for each serial port is sorted in the following order:

  • PL2303 devices
  • USB devices
  • ACM devices
  • other devices

func (*PortInfo) Format

func (p *PortInfo) Format(t *template.Template) string

Format creates a string from the information found in a PortInfo struct, making use of a template. If t is nil, the StdFormat will be used.

func (*PortInfo) String

func (p *PortInfo) String() string

String returns just the device name, e.g. /dev/ttyUSB0 or COM1.

Jump to

Keyboard shortcuts

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