more comments

This commit is contained in:
Sebastian Zagrodzki
2017-04-09 19:18:11 +02:00
parent b09de1cf09
commit 54aed557d8

View File

@@ -20,6 +20,7 @@ import (
"time"
)
// Endpoint identifies a USB endpoint opened for transfer.
type Endpoint struct {
h *libusbDevHandle
@@ -30,10 +31,12 @@ type Endpoint struct {
writeTimeout time.Duration
}
// String returns a human-readable description of the endpoint.
func (e *Endpoint) String() string {
return e.Info.String()
}
// Read reads data from an IN endpoint.
func (e *Endpoint) Read(buf []byte) (int, error) {
if e.Info.Direction != EndpointDirectionIn {
return 0, fmt.Errorf("usb: read: not an IN endpoint")
@@ -42,6 +45,7 @@ func (e *Endpoint) Read(buf []byte) (int, error) {
return e.transfer(buf, e.readTimeout)
}
// Write writes data to an OUT endpoint.
func (e *Endpoint) Write(buf []byte) (int, error) {
if e.Info.Direction != EndpointDirectionOut {
return 0, fmt.Errorf("usb: write: not an OUT endpoint")