From 0729d3b3174de5f0802276172dc46383de1447f2 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 6 May 2015 15:37:57 +0200 Subject: Runtime OS detection --- usb.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usb.go') 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) } -- cgit v1.2.3