rename ConfigInfo to ConfigDesc
This commit is contained in:
@@ -23,4 +23,4 @@ script:
|
|||||||
- |-
|
- |-
|
||||||
echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -v -covermode=count -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp
|
echo 'mode: count' > coverage.merged && go list ./... | xargs -n1 -I{} sh -c ': > coverage.tmp; go test -v -covermode=count -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.merged' && rm coverage.tmp
|
||||||
- |-
|
- |-
|
||||||
$HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -ignore libusb.go,error.go || true
|
$HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -ignore libusb_wrappers.go,error.go || true
|
||||||
|
@@ -20,8 +20,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigInfo contains the information about a USB device configuration.
|
// ConfigInfo contains the information about a USB device configuration,
|
||||||
type ConfigInfo struct {
|
// extracted from the device descriptor.
|
||||||
|
type ConfigDesc struct {
|
||||||
// Config is the configuration number.
|
// Config is the configuration number.
|
||||||
Config int
|
Config int
|
||||||
// SelfPowered is true if the device is powered externally, i.e. not
|
// SelfPowered is true if the device is powered externally, i.e. not
|
||||||
@@ -37,7 +38,7 @@ type ConfigInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// String returns the human-readable description of the configuration descriptor.
|
// String returns the human-readable description of the configuration descriptor.
|
||||||
func (c ConfigInfo) String() string {
|
func (c ConfigDesc) String() string {
|
||||||
return fmt.Sprintf("Configuration %d", c.Config)
|
return fmt.Sprintf("Configuration %d", c.Config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ func (c ConfigInfo) String() string {
|
|||||||
// To access device endpoints, claim an interface and it's alternate
|
// To access device endpoints, claim an interface and it's alternate
|
||||||
// setting number through a call to Interface().
|
// setting number through a call to Interface().
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Info ConfigInfo
|
Info ConfigDesc
|
||||||
|
|
||||||
dev *Device
|
dev *Device
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ type DeviceDesc struct {
|
|||||||
Protocol Protocol // The protocol (within the sub-class) of this device
|
Protocol Protocol // The protocol (within the sub-class) of this device
|
||||||
|
|
||||||
// Configuration information
|
// Configuration information
|
||||||
Configs map[int]ConfigInfo
|
Configs map[int]ConfigDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human-readable version of the device descriptor.
|
// String returns a human-readable version of the device descriptor.
|
||||||
|
@@ -27,7 +27,7 @@ var fakeDevices = []*DeviceDesc{
|
|||||||
Vendor: ID(0x9999),
|
Vendor: ID(0x9999),
|
||||||
Product: ID(0x0001),
|
Product: ID(0x0001),
|
||||||
Protocol: 255,
|
Protocol: 255,
|
||||||
Configs: map[int]ConfigInfo{1: {
|
Configs: map[int]ConfigDesc{1: {
|
||||||
Config: 1,
|
Config: 1,
|
||||||
MaxPower: Milliamperes(100),
|
MaxPower: Milliamperes(100),
|
||||||
Interfaces: []InterfaceInfo{{
|
Interfaces: []InterfaceInfo{{
|
||||||
@@ -66,7 +66,7 @@ var fakeDevices = []*DeviceDesc{
|
|||||||
Vendor: ID(0x8888),
|
Vendor: ID(0x8888),
|
||||||
Product: ID(0x0002),
|
Product: ID(0x0002),
|
||||||
Protocol: 255,
|
Protocol: 255,
|
||||||
Configs: map[int]ConfigInfo{1: {
|
Configs: map[int]ConfigDesc{1: {
|
||||||
Config: 1,
|
Config: 1,
|
||||||
MaxPower: Milliamperes(100),
|
MaxPower: Milliamperes(100),
|
||||||
Interfaces: []InterfaceInfo{{
|
Interfaces: []InterfaceInfo{{
|
||||||
|
@@ -207,13 +207,13 @@ func (libusbImpl) getDeviceDesc(d *libusbDevice) (*DeviceDesc, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Enumerate configurations
|
// Enumerate configurations
|
||||||
cfgs := make(map[int]ConfigInfo)
|
cfgs := make(map[int]ConfigDesc)
|
||||||
for i := 0; i < int(desc.bNumConfigurations); i++ {
|
for i := 0; i < int(desc.bNumConfigurations); i++ {
|
||||||
var cfg *C.struct_libusb_config_descriptor
|
var cfg *C.struct_libusb_config_descriptor
|
||||||
if err := fromErrNo(C.libusb_get_config_descriptor((*C.libusb_device)(d), C.uint8_t(i), &cfg)); err != nil {
|
if err := fromErrNo(C.libusb_get_config_descriptor((*C.libusb_device)(d), C.uint8_t(i), &cfg)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c := ConfigInfo{
|
c := ConfigDesc{
|
||||||
Config: int(cfg.bConfigurationValue),
|
Config: int(cfg.bConfigurationValue),
|
||||||
SelfPowered: (cfg.bmAttributes & selfPoweredMask) != 0,
|
SelfPowered: (cfg.bmAttributes & selfPoweredMask) != 0,
|
||||||
RemoteWakeup: (cfg.bmAttributes & remoteWakeupMask) != 0,
|
RemoteWakeup: (cfg.bmAttributes & remoteWakeupMask) != 0,
|
Reference in New Issue
Block a user