Move files from gousb/usb to gousb

This commit is contained in:
Sebastian Zagrodzki
2017-05-06 00:11:11 +02:00
parent acb9ee3242
commit 5200a36191
33 changed files with 79 additions and 79 deletions

View File

@@ -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 usb/libusb.go,usb/error.go || true
$HOME/gopath/bin/goveralls -coverprofile=coverage.merged -service=travis-ci -ignore libusb.go,error.go || true

View File

@@ -53,11 +53,11 @@ If you installed the lsusb example, both libraries below are already installed.
Installing the primary gousb package is really easy:
go get -v github.com/google/gousb/usb
go get -v github.com/google/gousb
There is also a `usbid` package that will not be installed by default by this command, but which provides useful information including the human-readable vendor and product codes for detected hardware. It's not installed by default and not linked into the `usb` package by default because it adds ~400kb to the resulting binary. If you want both, they can be installed thus:
There is also a `usbid` package that will not be installed by default by this command, but which provides useful information including the human-readable vendor and product codes for detected hardware. It's not installed by default and not linked into the `gousb` package by default because it adds ~400kb to the resulting binary. If you want both, they can be installed thus:
go get -v github.com/google/gousb/usb{,id}
go get -v github.com/google/gousb{,/usbid}
Notes for installation on Windows
---------------------------------
@@ -78,5 +78,5 @@ Documentation
=============
The documentation can be viewed via local godoc or via the excellent [godoc.org](http://godoc.org/):
- [usb](http://godoc.org/github.com/google/gousb/usb)
- [usb](http://godoc.org/github.com/google/gousb)
- [usbid](http://godoc.org/pkg/github.com/google/gousb/usbid)

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
// #include <libusb.h>
import "C"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
// To enable internal debugging, set the GOUSB_DEBUG environment variable.

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"reflect"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
func (e *endpoint) newStream(size, count int, submit bool) (*stream, error) {
var ts []transferIntf

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import "testing"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"testing"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
// fake devices connected through the fakeLibusb stack.
var fakeDevices = []*Descriptor{

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"errors"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -1,4 +1,4 @@
package usb
package gousb
import "testing"

View File

@@ -21,7 +21,7 @@ import (
"fmt"
"log"
"github.com/google/gousb/usb"
"github.com/google/gousb"
"github.com/google/gousb/usbid"
)
@@ -33,14 +33,14 @@ func main() {
flag.Parse()
// Only one context should be needed for an application. It should always be closed.
ctx := usb.NewContext()
ctx := gousb.NewContext()
defer ctx.Close()
// Debugging can be turned on; this shows some of the inner workings of the libusb package.
ctx.Debug(*debug)
// ListDevices is used to find the devices to open.
devs, err := ctx.ListDevices(func(desc *usb.Descriptor) bool {
devs, err := ctx.ListDevices(func(desc *gousb.Descriptor) bool {
// The usbid package can be used to print out human readable information.
fmt.Printf("%03d.%03d %s:%s %s\n", desc.Bus, desc.Address, desc.Vendor, desc.Product, usbid.Describe(desc))
fmt.Printf(" Protocol: %s\n", usbid.Classify(desc))

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"fmt"

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"testing"

View File

@@ -25,7 +25,7 @@ import (
"strconv"
"strings"
"github.com/google/gousb/usb"
"github.com/google/gousb"
)
var (
@@ -41,7 +41,7 @@ var (
num = flag.Int("read_num", 0, "Number of read transactions to perform. 0 means infinite.")
)
func parseVIDPID(vidPid string) (usb.ID, usb.ID, error) {
func parseVIDPID(vidPid string) (gousb.ID, gousb.ID, error) {
s := strings.Split(vidPid, ":")
if len(s) != 2 {
return 0, 0, fmt.Errorf("want VID:PID, two 32-bit hex numbers separated by colon, e.g. 1d6b:0002")
@@ -54,7 +54,7 @@ func parseVIDPID(vidPid string) (usb.ID, usb.ID, error) {
if err != nil {
return 0, 0, fmt.Errorf("PID must be a hexadecimal 32-bit number, e.g. 1d6b")
}
return usb.ID(vid), usb.ID(pid), nil
return gousb.ID(vid), gousb.ID(pid), nil
}
func parseBusAddr(busAddr string) (int, int, error) {
@@ -77,13 +77,13 @@ func main() {
flag.Parse()
// Only one context should be needed for an application. It should always be closed.
ctx := usb.NewContext()
ctx := gousb.NewContext()
defer ctx.Close()
ctx.Debug(*debug)
var devName string
var vid, pid usb.ID
var vid, pid gousb.ID
var bus, addr int
switch {
case *vidPID == "" && *busAddr == "":
@@ -108,7 +108,7 @@ func main() {
log.Printf("Scanning for device %q...", devName)
// ListDevices is used to find the devices to open.
devs, err := ctx.ListDevices(func(desc *usb.Descriptor) bool {
devs, err := ctx.ListDevices(func(desc *gousb.Descriptor) bool {
switch {
case vid == desc.Vendor && pid == desc.Product:
return true

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"errors"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import "io"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"bytes"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import (
"testing"

View File

@@ -14,7 +14,7 @@
// limitations under the License.
// Package usb provides a wrapper around libusb-1.0.
package usb
package gousb
// Context is the libusb context instance.
type Context struct {

View File

@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package usb
package gousb
import "testing"

View File

@@ -27,17 +27,17 @@ package usbid
import (
"fmt"
"github.com/google/gousb/usb"
"github.com/google/gousb"
)
// Describe returns a human readable string describing the vendor and product
// of the given device.
//
// The given val must be one of the following:
// - *usb.Descriptor "Product (Vendor)"
// - *gousb.Descriptor "Product (Vendor)"
func Describe(val interface{}) string {
switch val := val.(type) {
case *usb.Descriptor:
case *gousb.Descriptor:
if v, ok := Vendors[val.Vendor]; ok {
if d, ok := v.Product[val.Product]; ok {
return fmt.Sprintf("%s (%s)", d, v)
@@ -53,17 +53,17 @@ func Describe(val interface{}) string {
// and protocol associated with a device or interface.
//
// The given val must be one of the following:
// - *usb.Descriptor "Class (SubClass) Protocol"
// - usb.InterfaceSetup "IfClass (IfSubClass) IfProtocol"
// - *gousb.Descriptor "Class (SubClass) Protocol"
// - gousb.InterfaceSetup "IfClass (IfSubClass) IfProtocol"
func Classify(val interface{}) string {
var (
class, sub usb.Class
proto usb.Protocol
class, sub gousb.Class
proto gousb.Protocol
)
switch val := val.(type) {
case *usb.Descriptor:
case *gousb.Descriptor:
class, sub, proto = val.Class, val.SubClass, val.Protocol
case usb.InterfaceSetting:
case gousb.InterfaceSetting:
class, sub, proto = val.Class, val.SubClass, val.Protocol
default:
return fmt.Sprintf("Unknown (%T)", val)

View File

@@ -21,20 +21,20 @@ import (
"strings"
"time"
"github.com/google/gousb/usb"
"github.com/google/gousb"
)
const (
// LinuxUsbDotOrg is one source of files in the format used by this package.
LinuxUsbDotOrg = "http://www.linux-usb.org/usb.ids"
LinuxUsbDotOrg = "http://www.linux-gousb.org/usb.ids"
)
var (
// Vendors stores the vendor and product ID mappings.
Vendors map[usb.ID]*Vendor
Vendors map[gousb.ID]*Vendor
// Classes stores the class, subclass and protocol mappings.
Classes map[usb.Class]*Class
Classes map[gousb.Class]*Class
)
// LoadFromURL replaces the built-in vendor and class mappings with ones loaded

Some files were not shown because too many files have changed in this diff Show More