Fix ActualLength=0 for OUT transfers in BuildRetSubmit
This commit is contained in:
@@ -267,8 +267,11 @@ func BuildImportReply(status uint32, dev *DeviceDescriptor) ([]byte, error) {
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// BuildRetSubmit builds a RET_SUBMIT message
|
||||
func BuildRetSubmit(seqNum, devID, direction, endpoint uint32, status int32, data []byte) ([]byte, error) {
|
||||
// BuildRetSubmit builds a RET_SUBMIT message.
|
||||
// actualLength must be set for BOTH directions: it reports how many bytes
|
||||
// were actually transferred. For OUT transfers the kernel driver checks this
|
||||
// (e.g. UVC probe control expects actualLength == 26).
|
||||
func BuildRetSubmit(seqNum, devID, direction, endpoint uint32, status int32, actualLength uint32, data []byte) ([]byte, error) {
|
||||
buf := &bytes.Buffer{}
|
||||
|
||||
hdr := &URBHeader{
|
||||
@@ -282,14 +285,9 @@ func BuildRetSubmit(seqNum, devID, direction, endpoint uint32, status int32, dat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actualLen := uint32(0)
|
||||
if direction == DirIn && data != nil {
|
||||
actualLen = uint32(len(data))
|
||||
}
|
||||
|
||||
body := &RetSubmitBody{
|
||||
Status: status,
|
||||
ActualLength: actualLen,
|
||||
ActualLength: actualLength,
|
||||
NumberOfPackets: 0xFFFFFFFF,
|
||||
}
|
||||
if err := WriteRetSubmit(buf, body); err != nil {
|
||||
@@ -307,7 +305,7 @@ func BuildRetSubmit(seqNum, devID, direction, endpoint uint32, status int32, dat
|
||||
// BuildRetSubmitISO builds a RET_SUBMIT message for isochronous transfers.
|
||||
// The transfer data must already be packed (compact, no gaps).
|
||||
func BuildRetSubmitISO(seqNum, devID, direction, endpoint uint32, status int32,
|
||||
packedData []byte, startFrame uint32, numPackets int32, errorCount int32,
|
||||
actualLength uint32, packedData []byte, startFrame uint32, numPackets int32, errorCount int32,
|
||||
isoDescs []ISOPacketDescriptor) ([]byte, error) {
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
@@ -323,14 +321,9 @@ func BuildRetSubmitISO(seqNum, devID, direction, endpoint uint32, status int32,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
actualLen := uint32(0)
|
||||
if direction == DirIn && packedData != nil {
|
||||
actualLen = uint32(len(packedData))
|
||||
}
|
||||
|
||||
body := &RetSubmitBody{
|
||||
Status: status,
|
||||
ActualLength: actualLen,
|
||||
ActualLength: actualLength,
|
||||
StartFrame: startFrame,
|
||||
NumberOfPackets: uint32(numPackets),
|
||||
ErrorCount: uint32(errorCount),
|
||||
|
||||
Reference in New Issue
Block a user