Add Device.Manufacturer(), .Product() and .SerialNumber() (#14)
This commit is contained in:

committed by
zagrodzki

parent
1aaa100bdb
commit
757722bf8e
22
device.go
22
device.go
@@ -45,6 +45,10 @@ type DeviceDesc struct {
|
||||
|
||||
// Configuration information
|
||||
Configs map[int]ConfigDesc
|
||||
|
||||
iManufacturer int // The Manufacturer descriptor index
|
||||
iProduct int // The Product descriptor index
|
||||
iSerialNumber int // The SerialNumber descriptor index
|
||||
}
|
||||
|
||||
// String returns a human-readable version of the device descriptor.
|
||||
@@ -211,6 +215,24 @@ func (d *Device) GetStringDescriptor(descIndex int) (string, error) {
|
||||
return libusb.getStringDesc(d.handle, descIndex)
|
||||
}
|
||||
|
||||
// Manufacturer returns the device's manufacturer name.
|
||||
// GetStringDescriptor's string conversion rules apply.
|
||||
func (d *Device) Manufacturer() (string, error) {
|
||||
return d.GetStringDescriptor(d.Desc.iManufacturer)
|
||||
}
|
||||
|
||||
// Product returns the device's product name.
|
||||
// GetStringDescriptor's string conversion rules apply.
|
||||
func (d *Device) Product() (string, error) {
|
||||
return d.GetStringDescriptor(d.Desc.iProduct)
|
||||
}
|
||||
|
||||
// SerialNumber returns the device's serial number.
|
||||
// GetStringDescriptor's string conversion rules apply.
|
||||
func (d *Device) SerialNumber() (string, error) {
|
||||
return d.GetStringDescriptor(d.Desc.iSerialNumber)
|
||||
}
|
||||
|
||||
// SetAutoDetach enables/disables automatic kernel driver detachment.
|
||||
// When autodetach is enabled gousb will automatically detach the kernel driver
|
||||
// on the interface and reattach it when releasing the interface.
|
||||
|
Reference in New Issue
Block a user