Remove "libusb" from the comments.

This commit is contained in:
Sebastian Zagrodzki
2017-05-06 00:31:04 +02:00
parent 9623c1ba8d
commit 1c9a11b1ce
3 changed files with 15 additions and 10 deletions

View File

@@ -172,8 +172,8 @@ func (d *Device) GetStringDescriptor(descIndex int) (string, error) {
return libusb.getStringDesc(d.handle, descIndex) return libusb.getStringDesc(d.handle, descIndex)
} }
// SetAutoDetach enables/disables libusb's automatic kernel driver detachment. // SetAutoDetach enables/disables automatic kernel driver detachment.
// When autodetach is enabled libusb will automatically detach the kernel driver // When autodetach is enabled gousb will automatically detach the kernel driver
// on the interface and reattach it when releasing the interface. // on the interface and reattach it when releasing the interface.
// Automatic kernel driver detachment is disabled on newly opened device handles by default. // Automatic kernel driver detachment is disabled on newly opened device handles by default.
func (d *Device) SetAutoDetach(autodetach bool) error { func (d *Device) SetAutoDetach(autodetach bool) error {

View File

@@ -22,7 +22,7 @@ import (
// #include <libusb.h> // #include <libusb.h>
import "C" import "C"
// Error is an error code returned by libusb. // Error is an error code from a USB operation. See the list of Error constants below.
type Error C.int type Error C.int
// Error implements the error interface. // Error implements the error interface.
@@ -38,7 +38,7 @@ func fromErrNo(errno C.int) error {
return err return err
} }
// Error codes defined by libusb. // Defined result codes.
const ( const (
Success Error = C.LIBUSB_SUCCESS Success Error = C.LIBUSB_SUCCESS
ErrorIO Error = C.LIBUSB_ERROR_IO ErrorIO Error = C.LIBUSB_ERROR_IO
@@ -48,6 +48,8 @@ const (
ErrorNotFound Error = C.LIBUSB_ERROR_NOT_FOUND ErrorNotFound Error = C.LIBUSB_ERROR_NOT_FOUND
ErrorBusy Error = C.LIBUSB_ERROR_BUSY ErrorBusy Error = C.LIBUSB_ERROR_BUSY
ErrorTimeout Error = C.LIBUSB_ERROR_TIMEOUT ErrorTimeout Error = C.LIBUSB_ERROR_TIMEOUT
// ErrorOverflow indicates that the device tried to send more data than was
// requested and that could fit in the packet buffer.
ErrorOverflow Error = C.LIBUSB_ERROR_OVERFLOW ErrorOverflow Error = C.LIBUSB_ERROR_OVERFLOW
ErrorPipe Error = C.LIBUSB_ERROR_PIPE ErrorPipe Error = C.LIBUSB_ERROR_PIPE
ErrorInterrupted Error = C.LIBUSB_ERROR_INTERRUPTED ErrorInterrupted Error = C.LIBUSB_ERROR_INTERRUPTED
@@ -76,7 +78,7 @@ var errorString = map[Error]string{
// TransferStatus contains information about the result of a transfer. // TransferStatus contains information about the result of a transfer.
type TransferStatus uint8 type TransferStatus uint8
// Transfer status values provided by libusb. // Defined Transfer status values.
const ( const (
TransferCompleted TransferStatus = C.LIBUSB_TRANSFER_COMPLETED TransferCompleted TransferStatus = C.LIBUSB_TRANSFER_COMPLETED
TransferError TransferStatus = C.LIBUSB_TRANSFER_ERROR TransferError TransferStatus = C.LIBUSB_TRANSFER_ERROR

13
usb.go
View File

@@ -13,21 +13,24 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// Package usb provides a wrapper around libusb-1.0. // Package gousb provides an low-level interface to attached USB devices.
//
// A Context represents a new
package gousb package gousb
// Context is the libusb context instance. // Context manages all resources related to USB device handling.
type Context struct { type Context struct {
ctx *libusbContext ctx *libusbContext
done chan struct{} done chan struct{}
} }
// Debug changes the libusb debug level. // Debug changes the debug level. Level 0 means no debug, higher levels
// will print out more debugging information.
func (c *Context) Debug(level int) { func (c *Context) Debug(level int) {
libusb.setDebug(c.ctx, level) libusb.setDebug(c.ctx, level)
} }
// NewContext initializes libusb and returns a new context instance. // NewContext returns a new Context instance.
func NewContext() *Context { func NewContext() *Context {
c, err := libusb.init() c, err := libusb.init()
if err != nil { if err != nil {
@@ -100,7 +103,7 @@ func (c *Context) OpenDeviceWithVIDPID(vid, pid ID) (*Device, error) {
return devs[0], nil return devs[0], nil
} }
// Close releases the libusb context. // Close releases the Context and all associated resources.
func (c *Context) Close() error { func (c *Context) Close() error {
c.done <- struct{}{} c.done <- struct{}{}
if c.ctx != nil { if c.ctx != nil {