From e5961a7cc41efc13b670885d8de43835d1a61dd1 Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Sat, 6 May 2017 02:40:09 +0200 Subject: [PATCH] rename ConfigInfo to ConfigDesc --- .travis.yml | 2 +- config.go | 9 +++++---- device.go | 2 +- fakelibusb_devices.go | 4 ++-- libusb.go => libusb_wrappers.go | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) rename libusb.go => libusb_wrappers.go (99%) diff --git a/.travis.yml b/.travis.yml index 9b82ddf..38bca31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 - |- - $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 diff --git a/config.go b/config.go index d357a6b..87b66c7 100644 --- a/config.go +++ b/config.go @@ -20,8 +20,9 @@ import ( "sync" ) -// ConfigInfo contains the information about a USB device configuration. -type ConfigInfo struct { +// ConfigInfo contains the information about a USB device configuration, +// extracted from the device descriptor. +type ConfigDesc struct { // Config is the configuration number. Config int // 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. -func (c ConfigInfo) String() string { +func (c ConfigDesc) String() string { 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 // setting number through a call to Interface(). type Config struct { - Info ConfigInfo + Info ConfigDesc dev *Device diff --git a/device.go b/device.go index 6d56bfc..f1d2fce 100644 --- a/device.go +++ b/device.go @@ -42,7 +42,7 @@ type DeviceDesc struct { Protocol Protocol // The protocol (within the sub-class) of this device // Configuration information - Configs map[int]ConfigInfo + Configs map[int]ConfigDesc } // String returns a human-readable version of the device descriptor. diff --git a/fakelibusb_devices.go b/fakelibusb_devices.go index 61ca14f..82f5b74 100644 --- a/fakelibusb_devices.go +++ b/fakelibusb_devices.go @@ -27,7 +27,7 @@ var fakeDevices = []*DeviceDesc{ Vendor: ID(0x9999), Product: ID(0x0001), Protocol: 255, - Configs: map[int]ConfigInfo{1: { + Configs: map[int]ConfigDesc{1: { Config: 1, MaxPower: Milliamperes(100), Interfaces: []InterfaceInfo{{ @@ -66,7 +66,7 @@ var fakeDevices = []*DeviceDesc{ Vendor: ID(0x8888), Product: ID(0x0002), Protocol: 255, - Configs: map[int]ConfigInfo{1: { + Configs: map[int]ConfigDesc{1: { Config: 1, MaxPower: Milliamperes(100), Interfaces: []InterfaceInfo{{ diff --git a/libusb.go b/libusb_wrappers.go similarity index 99% rename from libusb.go rename to libusb_wrappers.go index 901d6aa..0d566a4 100644 --- a/libusb.go +++ b/libusb_wrappers.go @@ -207,13 +207,13 @@ func (libusbImpl) getDeviceDesc(d *libusbDevice) (*DeviceDesc, error) { return nil, err } // Enumerate configurations - cfgs := make(map[int]ConfigInfo) + cfgs := make(map[int]ConfigDesc) for i := 0; i < int(desc.bNumConfigurations); i++ { 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 { return nil, err } - c := ConfigInfo{ + c := ConfigDesc{ Config: int(cfg.bConfigurationValue), SelfPowered: (cfg.bmAttributes & selfPoweredMask) != 0, RemoteWakeup: (cfg.bmAttributes & remoteWakeupMask) != 0,