gousb: github.com/google/gousb/usbid Index | Files | Directories

package usbid

import "github.com/google/gousb/usbid"

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


Package Files

describe.go load.go load_data.go parse.go


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


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
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

func Classify Uses

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 Uses

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 Uses

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 Uses

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.

type Class Uses

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 Uses

func (c Class) String() string

String returns the name of the class.

type Product Uses

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 Uses

func (p Product) String() string

String returns the name of the product.

type SubClass Uses

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 Uses

func (s SubClass) String() string

String returns the name of the SubClass.

type Vendor Uses

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 Uses

func (v Vendor) String() string

String returns the name of the vendor.



Package usbid imports 9 packages (graph) and is imported by 6 packages. Updated 2019-01-26. Refresh now. Tools for package owners.