usbci

package
v1.0.0-1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestDirectionOut       uint8 = 0x00
	RequestDirectionIn        uint8 = 0x80
	RequestTypeStandard       uint8 = 0x00
	RequestTypeClass          uint8 = 0x20
	RequestTypeVendor         uint8 = 0x40
	RequestRecipientDevice    uint8 = 0x00
	RequestRecipientInterface uint8 = 0x01
	RequestRecipientEndpoint  uint8 = 0x02
	RequestRecipientOther     uint8 = 0x03

	RequestGetReport     uint8 = 0x01
	RequestSetReport     uint8 = 0x09
	RequestGetDescriptor uint8 = 0x06

	TypeDeviceDescriptor uint16 = 0x0100
	TypeConfigDescriptor uint16 = 0x0200
	TypeHidDescriptor    uint16 = 0x2200
	TypeFeatureReport    uint16 = 0x0300

	ControlInterface uint16 = 0x0000

	BufferSizeDeviceDescriptor int = 18
	BufferSizeConfigDescriptor int = 9

	FieldNameIx int = 0
	OldValueIx  int = 1
	NewValueIx  int = 2

	MarshalPrefix string = ""
	MarshalIndent string = "\t"
)
View Source
const (
	MagtekVID uint16 = 0x0801
	MagtekPID uint16 = 0x0001

	SureswipeKbPID          uint16 = 0x0001
	SureswipeHidPID         uint16 = 0x0002
	MagnesafeSwipeKbPID     uint16 = 0x0001
	MagnesafeInsertKbPID    uint16 = 0x0001
	MagnesafeSwipeHidPID    uint16 = 0x0011
	MagnesafeInsertHidPID   uint16 = 0x0013
	MagnesafeWirelessHidPID uint16 = 0x0014

	BufferSizeSureswipe int = 24
	BufferSizeMagnesafe int = 60

	CommandGetProp     uint8 = 0x00
	CommandSetProp     uint8 = 0x01
	CommandResetDevice uint8 = 0x02

	ResultCodeSuccess  uint8 = 0x00
	ResultCodeFailure  uint8 = 0x01
	ResultCodeBadParam uint8 = 0x02

	PropSoftwareID uint8 = 0x00
	PropDeviceSN   uint8 = 0x01
	PropFactorySN  uint8 = 0x03
	PropProductVer uint8 = 0x04

	DefaultSNLength int = 7
)

Variables

View Source
var (
	BufferSizes = []int{24, 60}
)

Functions

This section is empty.

Types

type Generic

type Generic struct {
	*gousb.Device `json:"-" xml:"-" csv:"-" nvp:"-" cmp:"-"`

	HostName    string `json:"host_name"     csv:"host_name"`
	VendorID    string `json:"vendor_id"     csv:"vendor_id"`
	ProductID   string `json:"product_id"    csv:"product_id"`
	SerialNum   string `json:"serial_number" csv:"serial_number"`
	VendorName  string `json:"vendor_name"   csv:"vendor_name"`
	ProductName string `json:"product_name"  csv:"product_name"`
	ProductVer  string `json:"product_ver"   csv:"product_ver"`
	FirmwareVer string `json:"firmware_ver"  csv:"firmware_ver"`
	SoftwareID  string `json:"software_id"   csv:"software_id"`

	PortNumber  int    `json:"port_number"   csv:"-" nvp:"-" cmp:"-"`
	BusNumber   int    `json:"bus_number"    csv:"-" nvp:"-" cmp:"-"`
	BusAddress  int    `json:"bus_address"   csv:"-" nvp:"-" cmp:"-"`
	BufferSize  int    `json:"buffer_size"   csv:"-" nvp:"-"`
	MaxPktSize  int    `json:"max_pkt_size"  csv:"-" nvp:"-"`
	USBSpec     string `json:"usb_spec"      csv:"-" nvp:"-"`
	USBClass    string `json:"usb_class"     csv:"-" nvp:"-"`
	USBSubClass string `json:"usb_subclass"  csv:"-" nvp:"-"`
	USBProtocol string `json:"usb_protocol"  csv:"-" nvp:"-"`
	DeviceSpeed string `json:"device_speed"  csv:"-" nvp:"-"`
	DeviceVer   string `json:"device_ver"    csv:"-" nvp:"-"`
	ObjectType  string `json:"object_type"   csv:"-" nvp:"-"`

	DeviceSN     string `json:"device_sn"     csv:"-" nvp:"-"`
	FactorySN    string `json:"factory_sn"    csv:"-" nvp:"-"`
	DescriptorSN string `json:"descriptor_sn" csv:"-" nvp:"-"`

	Changes [][]string        `json:"-" csv:"-" xml:"-" nvp:"-" cmp:"-"`
	Vendor  map[string]string `json:"-" csv:"-" xml:"-" nvp:"-" cmp:"-"`
}

Generic decorates a gousb Device with Generic Properties and API.

func NewGeneric

func NewGeneric(gd *gousb.Device) (*Generic, error)

NewGeneric instantiates a Generic wrapper for an existing gousb Device.

func (*Generic) AddChange

func (this *Generic) AddChange(f, o, n string)

AddChange appends manual changes to the devices Changes slice.

func (*Generic) AuditFile

func (this *Generic) AuditFile(fn string) (err error)

AuditFile calls CompareFile and places the results in the Changes field.

func (*Generic) AuditJSON

func (this *Generic) AuditJSON(j []byte) (err error)

AuditJSON calls CompareJSON and places the results in the Changes field.

func (*Generic) CSV

func (this *Generic) CSV() ([]byte, error)

CSV reports all unfiltered fields in CSV format.

func (*Generic) CompareFile

func (this *Generic) CompareFile(fn string) (ss [][]string, err error)

CompareFile compares fields and properties and returns an array of differences.

func (*Generic) CompareJSON

func (this *Generic) CompareJSON(b []byte) (ss [][]string, err error)

CompareJSON compares fields and properties and returns an array of differences.

func (*Generic) Filename

func (this *Generic) Filename() string

Filename constructs a convenient filename from the bus number, bus address, vendor ID, and product ID. Filenames guaranteed unique on a single computer.

func (*Generic) GetChanges

func (this *Generic) GetChanges() [][]string

GetChanges returns the device Changes slice.

func (*Generic) Host

func (this *Generic) Host() string

Host is a convenience method to retrieve the device hostname.

func (*Generic) ID

func (this *Generic) ID() string

ID is a convenience method to retrieve the device serial number.

func (*Generic) Init

func (this *Generic) Init() (errs map[string]bool)

Init initializes API properties.

func (*Generic) JSON

func (this *Generic) JSON() ([]byte, error)

JSON reports all unfiltered fields in JSON format.

func (*Generic) Legacy

func (this *Generic) Legacy() []byte

Legacy reports the hostname and serial number in CSV format.

func (*Generic) NVP

func (this *Generic) NVP() ([]byte, error)

NVP reports all unfiltered fields as name-value pairs.

func (*Generic) PID

func (this *Generic) PID() string

PID is a convenience method to retrieve the device product ID.

func (*Generic) PrettyJSON

func (this *Generic) PrettyJSON() ([]byte, error)

PrettyJSON reports all unfiltered fields in formatted JSON format.

func (*Generic) PrettyXML

func (this *Generic) PrettyXML() ([]byte, error)

PrettyXML reports all unfiltered fields in formatted XML format.

func (*Generic) Refresh

func (this *Generic) Refresh() (errs map[string]bool)

Refresh updates properties whose underlying values may have changed.

func (*Generic) RestoreFile

func (this *Generic) RestoreFile(fn string) error

RestoreFile restores the object from a JSON file.

func (*Generic) RestoreJSON

func (this *Generic) RestoreJSON(j []byte) error

RestoreJSON restores the object from a JSON file.

func (*Generic) Save

func (this *Generic) Save(fn string) error

Save saves the object to a JSON file.

func (*Generic) SetChanges

func (this *Generic) SetChanges(ss [][]string)

SetChanges sets the device Changes slice to the results of an audit.

func (*Generic) Type

func (this *Generic) Type() string

Type is a convenience method to help identify object type to other apps.

func (*Generic) VID

func (this *Generic) VID() string

VID is a convenience method to retrieve the device vendor ID.

func (*Generic) XML

func (this *Generic) XML() ([]byte, error)

XML reports all unfiltered fields in XML format.

type Magtek

type Magtek struct {
	*Generic
}

Magtek decorates a gousb Device with Generic and Magtek Properties and API.

func NewMagtek

func NewMagtek(gd *gousb.Device) (*Magtek, error)

NewMagtek instantiates a Magtek wrapper for an existing gousb Device.

func (*Magtek) CopyFactorySN

func (this *Magtek) CopyFactorySN(n int) error

CopyFactorySN copies 'length' characters from the device factory serial number to the configurable serial number in NVRAM.

func (*Magtek) EraseDeviceSN

func (this *Magtek) EraseDeviceSN() error

EraseDeviceSN removes the device configurable serial number from NVRAM.

func (*Magtek) GetBufferSize

func (this *Magtek) GetBufferSize() (size int, err error)

GetBufferSize uses trial and error to find the control transfer data buffer size of the device. Failure to use the correct size for control transfers carrying vendor commands will result in a LIBUSB_ERROR_PIPE error.

func (*Magtek) GetDeviceSN

func (this *Magtek) GetDeviceSN() (string, error)

DeviceSN retrieves the device configurable serial number from NVRAM.

func (*Magtek) GetFactorySN

func (this *Magtek) GetFactorySN() (string, error)

FactorySN retrieves the device factory serial number from NVRAM.

func (*Magtek) GetProductVer

func (this *Magtek) GetProductVer() (string, error)

ProductVer retrieves the product version of the device from NVRAM.

func (*Magtek) GetSoftwareID

func (this *Magtek) GetSoftwareID() (string, error)

SoftwareID retrieves the software ID of the device from NVRAM.

func (*Magtek) Init

func (this *Magtek) Init() (errs map[string]bool)

Init initializes API properties.

func (*Magtek) Refresh

func (this *Magtek) Refresh() (errs map[string]bool)

Refresh updates API properties whose values may have changed.

func (*Magtek) Reset

func (this *Magtek) Reset() error

Reset overides inherited Reset method with a low-level vendor reset.

func (*Magtek) SetDeviceSN

func (this *Magtek) SetDeviceSN(val string) error

SetDeviceSN sets the device configurable serial number in NVRAM.

func (*Magtek) SetFactorySN

func (this *Magtek) SetFactorySN(val string) error

SetFactorySN sets the device factory device serial number in NVRAM. This will fail with result code 07 if serial number is already set.

func (*Magtek) Type

func (this *Magtek) Type() string

Type is a convenience method to help identify object type to other apps.

Jump to

Keyboard shortcuts

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