aboutsummaryrefslogtreecommitdiff
path: root/usb.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-15 17:41:19 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-15 17:41:19 +0200
commit9a65aafab104564fb64e5b97f9628ef809a10379 (patch)
tree0eed6c1db0ba6aa0f781a3883ed5566d908ae3a7 /usb.go
parente2640ff058e077bf9de9a80394e649bbd819586c (diff)
Refactor Devicer
Diffstat (limited to 'usb.go')
-rw-r--r--usb.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/usb.go b/usb.go
index 50351e9..660ca29 100644
--- a/usb.go
+++ b/usb.go
@@ -13,7 +13,7 @@ type Devicer interface {
Handle() *bufio.ReadWriter
}
-type Device struct {
+type USB struct {
ctx *usb.Context
dev *usb.Device
}
@@ -48,7 +48,7 @@ func cc100(desc *usb.Descriptor) bool {
return false
}
-func NewDevice() (Devicer, error) {
+func NewUSB() (USB, error) {
ctx := usb.NewContext()
ctx.Debug(debug)
devs, err := ctx.ListDevices(cc100)
@@ -59,17 +59,17 @@ func NewDevice() (Devicer, error) {
for _, dev := range devs {
dev.Close()
}
- return Device{}, errors.New("Cannot find " + craftRobo)
+ return USB{}, errors.New("Cannot find " + craftRobo)
}
- return Device{ctx, devs[0]}, nil
+ return USB{ctx, devs[0]}, nil
}
-func (d Device) Close() {
+func (d USB) Close() {
d.dev.Close()
d.ctx.Close()
}
-func (d Device) Handle() *bufio.ReadWriter {
+func (d USB) Handle() *bufio.ReadWriter {
var (
r *bufio.Reader
w *bufio.Writer