more comments

This commit is contained in:
Sebastian Zagrodzki
2017-04-09 20:27:37 +02:00
parent 56162d0105
commit 188fd8382d
2 changed files with 5 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ func (t *usbTransfer) submit() error {
t.mu.Lock()
defer t.mu.Unlock()
if t.submitted {
return errors.New("transfer was already submitted and is not finished yet.")
return errors.New("transfer was already submitted and is not finished yet")
}
t.done = make(chan struct{})
if err := libusb.submit(t.xfer, t.done); err != nil {

View File

@@ -16,15 +16,18 @@
// Package usb provides a wrapper around libusb-1.0.
package usb
// Context is the libusb context instance.
type Context struct {
ctx *libusbContext
done chan struct{}
}
// Debug changes the libusb debug level.
func (c *Context) Debug(level int) {
libusb.setDebug(c.ctx, level)
}
// NewContext initializes libusb and returns a new context instance.
func NewContext() *Context {
c, err := libusb.init()
if err != nil {
@@ -97,6 +100,7 @@ func (c *Context) OpenDeviceWithVidPid(vid, pid int) (*Device, error) {
return devs[0], nil
}
// Close releases the libusb context.
func (c *Context) Close() error {
c.done <- struct{}{}
if c.ctx != nil {