From 2273ac77c7106c36536d17ee6f07d9492780a573 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 6 May 2015 14:38:32 +0200 Subject: Linux support --- usb.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'usb.go') 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() { -- cgit v1.2.3