more comments
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Endpoint identifies a USB endpoint opened for transfer.
|
||||||
type Endpoint struct {
|
type Endpoint struct {
|
||||||
h *libusbDevHandle
|
h *libusbDevHandle
|
||||||
|
|
||||||
@@ -30,10 +31,12 @@ type Endpoint struct {
|
|||||||
writeTimeout time.Duration
|
writeTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a human-readable description of the endpoint.
|
||||||
func (e *Endpoint) String() string {
|
func (e *Endpoint) String() string {
|
||||||
return e.Info.String()
|
return e.Info.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read reads data from an IN endpoint.
|
||||||
func (e *Endpoint) Read(buf []byte) (int, error) {
|
func (e *Endpoint) Read(buf []byte) (int, error) {
|
||||||
if e.Info.Direction != EndpointDirectionIn {
|
if e.Info.Direction != EndpointDirectionIn {
|
||||||
return 0, fmt.Errorf("usb: read: not an IN endpoint")
|
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)
|
return e.transfer(buf, e.readTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write writes data to an OUT endpoint.
|
||||||
func (e *Endpoint) Write(buf []byte) (int, error) {
|
func (e *Endpoint) Write(buf []byte) (int, error) {
|
||||||
if e.Info.Direction != EndpointDirectionOut {
|
if e.Info.Direction != EndpointDirectionOut {
|
||||||
return 0, fmt.Errorf("usb: write: not an OUT endpoint")
|
return 0, fmt.Errorf("usb: write: not an OUT endpoint")
|
||||||
|
Reference in New Issue
Block a user