hid

package module
v0.0.0-...-e1626f1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: MIT Imports: 12 Imported by: 22

README

hid

Simple HID driver for Go (pure golang, no dependencies, no cgo)

Currently only Linux (386/amd64) is supported.

Documentation

Index

Constants

View Source
const (
	USBDEVFS_IOCTL   = 0xc0105512
	USBDEVFS_BULK    = 0xc0185502
	USBDEVFS_CONTROL = 0xc0185500
)
View Source
const (
	USBDEVFS_CONNECT    = 0x5517
	USBDEVFS_DISCONNECT = 0x5516
	USBDEVFS_CLAIM      = 0x8004550f
	USBDEVFS_RELEASE    = 0x80045510
)
View Source
const (
	UsbDescTypeDevice    = 1
	UsbDescTypeConfig    = 2
	UsbDescTypeString    = 3
	UsbDescTypeInterface = 4
	UsbDescTypeEndpoint  = 5
	UsbDescTypeReport    = 33
)
View Source
const DevBusUsb = "/dev/bus/usb"
View Source
const UsbHidClass = 3

Variables

View Source
var Logger = log.New(ioutil.Discard, "hid", log.LstdFlags)

Default Logger setting

Functions

func UsbWalk

func UsbWalk(cb func(Device))

Types

type Device

type Device interface {
	Open() error
	Close()
	Info() Info
	HIDReport() ([]byte, error)
	SetReport(int, []byte) error
	GetReport(int) ([]byte, error)
	Read(size int, ms time.Duration) ([]byte, error)
	Write(data []byte, ms time.Duration) (int, error)
	Ctrl(rtype, req, val, index int, data []byte, t int) (int, error)
}

A common HID device interace

type Info

type Info struct {
	Vendor   uint16
	Product  uint16
	Revision uint16

	SubClass uint8
	Protocol uint8

	Interface uint8
	Bus       int
	Device    int
}

General information about the HID device

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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