Documentation ¶
Index ¶
- Constants
- Variables
- type Generic
- func (this *Generic) AddChange(f, o, n string)
- func (this *Generic) AuditFile(fn string) (err error)
- func (this *Generic) AuditJSON(j []byte) (err error)
- func (this *Generic) CSV() ([]byte, error)
- func (this *Generic) CompareFile(fn string) (ss [][]string, err error)
- func (this *Generic) CompareJSON(b []byte) (ss [][]string, err error)
- func (this *Generic) Filename() string
- func (this *Generic) GetChanges() [][]string
- func (this *Generic) Host() string
- func (this *Generic) ID() string
- func (this *Generic) Init() (errs map[string]bool)
- func (this *Generic) JSON() ([]byte, error)
- func (this *Generic) Legacy() []byte
- func (this *Generic) NVP() ([]byte, error)
- func (this *Generic) PID() string
- func (this *Generic) PrettyJSON() ([]byte, error)
- func (this *Generic) PrettyXML() ([]byte, error)
- func (this *Generic) Refresh() (errs map[string]bool)
- func (this *Generic) RestoreFile(fn string) error
- func (this *Generic) RestoreJSON(j []byte) error
- func (this *Generic) Save(fn string) error
- func (this *Generic) SetChanges(ss [][]string)
- func (this *Generic) Type() string
- func (this *Generic) VID() string
- func (this *Generic) XML() ([]byte, error)
- type Magtek
- func (this *Magtek) CopyFactorySN(n int) error
- func (this *Magtek) EraseDeviceSN() error
- func (this *Magtek) GetBufferSize() (size int, err error)
- func (this *Magtek) GetDeviceSN() (string, error)
- func (this *Magtek) GetFactorySN() (string, error)
- func (this *Magtek) GetProductVer() (string, error)
- func (this *Magtek) GetSoftwareID() (string, error)
- func (this *Magtek) Init() (errs map[string]bool)
- func (this *Magtek) Refresh() (errs map[string]bool)
- func (this *Magtek) Reset() error
- func (this *Magtek) SetDeviceSN(val string) error
- func (this *Magtek) SetFactorySN(val string) error
- func (this *Magtek) Type() string
Constants ¶
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" )
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 ¶
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 ¶
NewGeneric instantiates a Generic wrapper for an existing gousb Device.
func (*Generic) AuditFile ¶
AuditFile calls CompareFile and places the results in the Changes field.
func (*Generic) AuditJSON ¶
AuditJSON calls CompareJSON and places the results in the Changes field.
func (*Generic) CompareFile ¶
CompareFile compares fields and properties and returns an array of differences.
func (*Generic) CompareJSON ¶
CompareJSON compares fields and properties and returns an array of differences.
func (*Generic) Filename ¶
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 ¶
GetChanges returns the device Changes slice.
func (*Generic) PrettyJSON ¶
PrettyJSON reports all unfiltered fields in formatted JSON format.
func (*Generic) RestoreFile ¶
RestoreFile restores the object from a JSON file.
func (*Generic) RestoreJSON ¶
RestoreJSON restores the object from a JSON file.
func (*Generic) SetChanges ¶
SetChanges sets the device Changes slice to the results of an audit.
type Magtek ¶
type Magtek struct {
*Generic
}
Magtek decorates a gousb Device with Generic and Magtek Properties and API.
func (*Magtek) CopyFactorySN ¶
CopyFactorySN copies 'length' characters from the device factory serial number to the configurable serial number in NVRAM.
func (*Magtek) EraseDeviceSN ¶
EraseDeviceSN removes the device configurable serial number from NVRAM.
func (*Magtek) GetBufferSize ¶
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 ¶
DeviceSN retrieves the device configurable serial number from NVRAM.
func (*Magtek) GetFactorySN ¶
FactorySN retrieves the device factory serial number from NVRAM.
func (*Magtek) GetProductVer ¶
ProductVer retrieves the product version of the device from NVRAM.
func (*Magtek) GetSoftwareID ¶
SoftwareID retrieves the software ID of the device from NVRAM.
func (*Magtek) SetDeviceSN ¶
SetDeviceSN sets the device configurable serial number in NVRAM.
func (*Magtek) SetFactorySN ¶
SetFactorySN sets the device factory device serial number in NVRAM. This will fail with result code 07 if serial number is already set.