make addr() part of EndpointInfo
This commit is contained in:
@@ -44,14 +44,18 @@ type EndpointInfo struct {
|
||||
UsageType UsageType
|
||||
}
|
||||
|
||||
// String returns the human-readable description of the endpoint.
|
||||
func (e EndpointInfo) String() string {
|
||||
func (e EndpointInfo) addr() uint8 {
|
||||
addr := e.Number
|
||||
if e.Direction == EndpointDirectionIn {
|
||||
addr |= 0x80
|
||||
}
|
||||
return addr
|
||||
}
|
||||
|
||||
// String returns the human-readable description of the endpoint.
|
||||
func (e EndpointInfo) String() string {
|
||||
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 {
|
||||
case TransferTypeIsochronous:
|
||||
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)
|
||||
}
|
||||
xfer.dev_handle = (*C.libusb_device_handle)(d)
|
||||
addr := ep.Number & endpointNumMask
|
||||
if ep.Direction == EndpointDirectionIn {
|
||||
addr |= endpointDirectionMask
|
||||
}
|
||||
xfer.endpoint = C.uchar(addr)
|
||||
xfer.endpoint = C.uchar(ep.addr())
|
||||
xfer.timeout = C.uint(timeout / time.Millisecond)
|
||||
xfer._type = C.uchar(ep.TransferType)
|
||||
xfer.num_iso_packets = C.int(isoPackets)
|
||||
|
Reference in New Issue
Block a user