replace uint32 in MaxPacketSize with int
This commit is contained in:
@@ -33,7 +33,7 @@ type EndpointInfo struct {
|
|||||||
// Direction defines whether the data is flowing IN or OUT from the host perspective.
|
// Direction defines whether the data is flowing IN or OUT from the host perspective.
|
||||||
Direction EndpointDirection
|
Direction EndpointDirection
|
||||||
// MaxPacketSize is the maximum USB packet size for a single frame/microframe.
|
// MaxPacketSize is the maximum USB packet size for a single frame/microframe.
|
||||||
MaxPacketSize uint32
|
MaxPacketSize int
|
||||||
// TransferType defines the endpoint type - bulk, interrupt, isochronous.
|
// TransferType defines the endpoint type - bulk, interrupt, isochronous.
|
||||||
TransferType TransferType
|
TransferType TransferType
|
||||||
// PollInterval is the maximum time between transfers for interrupt and isochronous transfer,
|
// PollInterval is the maximum time between transfers for interrupt and isochronous transfer,
|
||||||
|
@@ -44,7 +44,7 @@ func (ep libusbEndpoint) endpointInfo(dev *Descriptor) EndpointInfo {
|
|||||||
Number: int(ep.bEndpointAddress & endpointNumMask),
|
Number: int(ep.bEndpointAddress & endpointNumMask),
|
||||||
Direction: EndpointDirection((ep.bEndpointAddress & endpointDirectionMask) != 0),
|
Direction: EndpointDirection((ep.bEndpointAddress & endpointDirectionMask) != 0),
|
||||||
TransferType: TransferType(ep.bmAttributes & transferTypeMask),
|
TransferType: TransferType(ep.bmAttributes & transferTypeMask),
|
||||||
MaxPacketSize: uint32(ep.wMaxPacketSize),
|
MaxPacketSize: int(ep.wMaxPacketSize),
|
||||||
}
|
}
|
||||||
if ei.TransferType == TransferTypeIsochronous {
|
if ei.TransferType == TransferTypeIsochronous {
|
||||||
// bits 0-10 identify the packet size, bits 11-12 are the number of additional transactions per microframe.
|
// bits 0-10 identify the packet size, bits 11-12 are the number of additional transactions per microframe.
|
||||||
@@ -52,7 +52,7 @@ func (ep libusbEndpoint) endpointInfo(dev *Descriptor) EndpointInfo {
|
|||||||
// regardless of alternative setting used, where different alternative settings might define different
|
// regardless of alternative setting used, where different alternative settings might define different
|
||||||
// max packet sizes.
|
// max packet sizes.
|
||||||
// See http://libusb.org/ticket/77 for more background.
|
// See http://libusb.org/ticket/77 for more background.
|
||||||
ei.MaxPacketSize = uint32(ep.wMaxPacketSize) & 0x07ff * (uint32(ep.wMaxPacketSize)>>11&3 + 1)
|
ei.MaxPacketSize = int(ep.wMaxPacketSize) & 0x07ff * (int(ep.wMaxPacketSize)>>11&3 + 1)
|
||||||
ei.IsoSyncType = IsoSyncType(ep.bmAttributes & isoSyncTypeMask)
|
ei.IsoSyncType = IsoSyncType(ep.bmAttributes & isoSyncTypeMask)
|
||||||
switch ep.bmAttributes & usageTypeMask {
|
switch ep.bmAttributes & usageTypeMask {
|
||||||
case C.LIBUSB_ISO_USAGE_TYPE_DATA:
|
case C.LIBUSB_ISO_USAGE_TYPE_DATA:
|
||||||
|
@@ -112,14 +112,13 @@ func (t *usbTransfer) data() []byte {
|
|||||||
// newUSBTransfer allocates a new transfer structure for communication with a
|
// newUSBTransfer allocates a new transfer structure for communication with a
|
||||||
// given device/endpoint, with buf as the underlying transfer buffer.
|
// given device/endpoint, with buf as the underlying transfer buffer.
|
||||||
func newUSBTransfer(dev *libusbDevHandle, ei *EndpointInfo, buf []byte, timeout time.Duration) (*usbTransfer, error) {
|
func newUSBTransfer(dev *libusbDevHandle, ei *EndpointInfo, buf []byte, timeout time.Duration) (*usbTransfer, error) {
|
||||||
var isoPackets int
|
var isoPackets, isoPktSize int
|
||||||
var isoPktSize uint32
|
|
||||||
if ei.TransferType == TransferTypeIsochronous {
|
if ei.TransferType == TransferTypeIsochronous {
|
||||||
isoPktSize = ei.MaxPacketSize
|
isoPktSize = ei.MaxPacketSize
|
||||||
if len(buf) < int(isoPktSize) {
|
if len(buf) < isoPktSize {
|
||||||
isoPktSize = uint32(len(buf))
|
isoPktSize = len(buf)
|
||||||
}
|
}
|
||||||
isoPackets = len(buf) / int(isoPktSize)
|
isoPackets = len(buf) / isoPktSize
|
||||||
debug.Printf("New isochronous transfer - buffer length %d, using %d packets of %d bytes each", len(buf), isoPackets, isoPktSize)
|
debug.Printf("New isochronous transfer - buffer length %d, using %d packets of %d bytes each", len(buf), isoPackets, isoPktSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +129,7 @@ func newUSBTransfer(dev *libusbDevHandle, ei *EndpointInfo, buf []byte, timeout
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ei.TransferType == TransferTypeIsochronous {
|
if ei.TransferType == TransferTypeIsochronous {
|
||||||
libusb.setIsoPacketLengths(xfer, isoPktSize)
|
libusb.setIsoPacketLengths(xfer, uint32(isoPktSize))
|
||||||
}
|
}
|
||||||
|
|
||||||
t := &usbTransfer{
|
t := &usbTransfer{
|
||||||
|
@@ -27,7 +27,7 @@ func TestNewTransfer(t *testing.T) {
|
|||||||
desc string
|
desc string
|
||||||
dir EndpointDirection
|
dir EndpointDirection
|
||||||
tt TransferType
|
tt TransferType
|
||||||
maxPkt uint32
|
maxPkt int
|
||||||
buf int
|
buf int
|
||||||
timeout time.Duration
|
timeout time.Duration
|
||||||
wantIso int
|
wantIso int
|
||||||
|
Reference in New Issue
Block a user