aboutsummaryrefslogtreecommitdiff
path: root/usb.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-06 15:37:57 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-06 15:37:57 +0200
commit0729d3b3174de5f0802276172dc46383de1447f2 (patch)
tree885a32ec48b5604bb994e4f6a82993916c480818 /usb.go
parentfbe34fac1e62617cd9d160e41f6730c550d95580 (diff)
Runtime OS detection
Diffstat (limited to 'usb.go')
-rw-r--r--usb.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/usb.go b/usb.go
index 8d89274..18b2b5c 100644
--- a/usb.go
+++ b/usb.go
@@ -8,6 +8,11 @@ import (
"github.com/kylelemons/gousb/usb"
)
+type Devicer interface {
+ Close()
+ Handle() *bufio.ReadWriter
+}
+
type Device struct {
ctx *usb.Context
dev *usb.Device
@@ -30,7 +35,7 @@ func init() {
usb.DefaultWriteTimeout *= 60
}
-func CC100(desc *usb.Descriptor) bool {
+func cc100(desc *usb.Descriptor) bool {
if desc.Vendor == graphtec {
switch desc.Product {
case cc200_20, cc300_20,
@@ -43,10 +48,10 @@ func CC100(desc *usb.Descriptor) bool {
return false
}
-func NewDevice() (Device, error) {
+func NewDevice() (Devicer, error) {
ctx := usb.NewContext()
ctx.Debug(debug)
- devs, err := ctx.ListDevices(CC100)
+ devs, err := ctx.ListDevices(cc100)
if err != nil {
log.Fatal(err)
}