aboutsummaryrefslogtreecommitdiff
path: root/usb.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-06 14:38:32 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-06 14:38:32 +0200
commit2273ac77c7106c36536d17ee6f07d9492780a573 (patch)
treea8fc8079c87029d22157dd26583753c4334d8e15 /usb.go
parent670a733b2202558a0970d225abd7088f6d68a01e (diff)
Linux support
Diffstat (limited to 'usb.go')
-rw-r--r--usb.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/usb.go b/usb.go
index a935810..8d89274 100644
--- a/usb.go
+++ b/usb.go
@@ -2,6 +2,7 @@ package main
import (
"bufio"
+ "errors"
"log"
"github.com/kylelemons/gousb/usb"
@@ -42,7 +43,7 @@ func CC100(desc *usb.Descriptor) bool {
return false
}
-func NewDevice() (d Device) {
+func NewDevice() (Device, error) {
ctx := usb.NewContext()
ctx.Debug(debug)
devs, err := ctx.ListDevices(CC100)
@@ -53,9 +54,9 @@ func NewDevice() (d Device) {
for _, dev := range devs {
dev.Close()
}
- log.Fatal("Cannot find ", craftRobo)
+ return Device{}, errors.New("Cannot find " + craftRobo)
}
- return Device{ctx, devs[0]}
+ return Device{ctx, devs[0]}, nil
}
func (d Device) Close() {