make addr() part of EndpointInfo
This commit is contained in:
@@ -44,14 +44,18 @@ type EndpointInfo struct {
|
|||||||
UsageType UsageType
|
UsageType UsageType
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the human-readable description of the endpoint.
|
func (e EndpointInfo) addr() uint8 {
|
||||||
func (e EndpointInfo) String() string {
|
|
||||||
addr := e.Number
|
addr := e.Number
|
||||||
if e.Direction == EndpointDirectionIn {
|
if e.Direction == EndpointDirectionIn {
|
||||||
addr |= 0x80
|
addr |= 0x80
|
||||||
}
|
}
|
||||||
|
return addr
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns the human-readable description of the endpoint.
|
||||||
|
func (e EndpointInfo) String() string {
|
||||||
ret := make([]string, 0, 3)
|
ret := make([]string, 0, 3)
|
||||||
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, addr, e.TransferType))
|
ret = append(ret, fmt.Sprintf("Endpoint #%d %s (address 0x%02x) %s", e.Number, e.Direction, e.addr(), e.TransferType))
|
||||||
switch e.TransferType {
|
switch e.TransferType {
|
||||||
case TransferTypeIsochronous:
|
case TransferTypeIsochronous:
|
||||||
ret = append(ret, fmt.Sprintf("- %s %s", e.IsoSyncType, e.UsageType))
|
ret = append(ret, fmt.Sprintf("- %s %s", e.IsoSyncType, e.UsageType))
|
||||||
|
@@ -374,11 +374,7 @@ func (libusbImpl) alloc(d *libusbDevHandle, ep *EndpointInfo, timeout time.Durat
|
|||||||
return nil, fmt.Errorf("libusb_alloc_transfer(%d) failed", isoPackets)
|
return nil, fmt.Errorf("libusb_alloc_transfer(%d) failed", isoPackets)
|
||||||
}
|
}
|
||||||
xfer.dev_handle = (*C.libusb_device_handle)(d)
|
xfer.dev_handle = (*C.libusb_device_handle)(d)
|
||||||
addr := ep.Number & endpointNumMask
|
xfer.endpoint = C.uchar(ep.addr())
|
||||||
if ep.Direction == EndpointDirectionIn {
|
|
||||||
addr |= endpointDirectionMask
|
|
||||||
}
|
|
||||||
xfer.endpoint = C.uchar(addr)
|
|
||||||
xfer.timeout = C.uint(timeout / time.Millisecond)
|
xfer.timeout = C.uint(timeout / time.Millisecond)
|
||||||
xfer._type = C.uchar(ep.TransferType)
|
xfer._type = C.uchar(ep.TransferType)
|
||||||
xfer.num_iso_packets = C.int(isoPackets)
|
xfer.num_iso_packets = C.int(isoPackets)
|
||||||
|
Reference in New Issue
Block a user