usbid

package
v0.0.0-...-18f4c1d Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package usbid provides human-readable text output for the usb package.

On load, the usbid package parses an embedded mapping of vendors/products and class/subclass/protocols. They can also be loaded from a URL or from a reader.

The bread and butter of this package are the following two functions:

Describe - Pretty-print the vendor and product of a device descriptor
Classify - Pretty-print the class/protocol info for a device/interface

Index

Constants

View Source
const (
	// LinuxUsbDotOrg is one source of files in the format used by this package.
	LinuxUsbDotOrg = "http://www.linux-usb.org/usb.ids"
)

Variables

View Source
var (
	// Vendors stores the vendor and product ID mappings.
	Vendors map[gousb.ID]*Vendor

	// Classes stores the class, subclass and protocol mappings.
	Classes map[gousb.Class]*Class
)
View Source
var LastUpdate = time.Unix(0, 1489154954940548227)

LastUpdate stores the latest time that the library was updated.

The baked-in data was last generated:

2017-03-10 09:09:14.940548227 -0500 EST

Functions

func Classify

func Classify(val interface{}) string

Classify returns a human-readable string describing the class, subclass, and protocol associated with a device or interface.

The given val must be one of the following:

  • *gousb.DeviceDesc "Class (SubClass) Protocol"
  • gousb.InterfaceSetup "IfClass (IfSubClass) IfProtocol"

func Describe

func Describe(val interface{}) string

Describe returns a human readable string describing the vendor and product of the given device.

The given val must be one of the following:

  • *gousb.DeviceDesc "Product (Vendor)"

func LoadFromURL

func LoadFromURL(url string) error

LoadFromURL replaces the built-in vendor and class mappings with ones loaded from the given URL.

This should usually only be necessary if the mappings in the library are stale. The contents of this file as of February 2012 are embedded in the library itself.

func ParseIDs

func ParseIDs(r io.Reader) (map[gousb.ID]*Vendor, map[gousb.Class]*Class, error)

ParseIDs parses and returns mappings from the given reader. In general, this should not be necessary, as a set of mappings is already embedded in the library. If a new or specialized file is obtained, this can be used to retrieve the mappings, which can be stored in the global Vendors and Classes map.

Types

type Class

type Class struct {
	Name     string
	SubClass map[gousb.Class]*SubClass
}

A Class contains the name of the class and mappings for each subclass.

func (Class) String

func (c Class) String() string

String returns the name of the class.

type Product

type Product struct {
	Name      string
	Interface map[gousb.ID]string
}

A Product contains the name of the product (from a particular vendor) and the names of any interfaces that were specified.

func (Product) String

func (p Product) String() string

String returns the name of the product.

type SubClass

type SubClass struct {
	Name     string
	Protocol map[gousb.Protocol]string
}

A SubClass contains the name of the subclass and any associated protocols.

func (SubClass) String

func (s SubClass) String() string

String returns the name of the SubClass.

type Vendor

type Vendor struct {
	Name    string
	Product map[gousb.ID]*Product
}

A Vendor contains the name of the vendor and mappings corresponding to all known products by their ID.

func (Vendor) String

func (v Vendor) String() string

String returns the name of the vendor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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