fix: usbMgr request direction

Signed-off-by: wu <wuzhimin8@huawei.com>
This commit is contained in:
wu 2022-11-01 19:44:40 -07:00
parent 6c5ee0300c
commit b1b0693cb4
4 changed files with 13 additions and 15 deletions

View File

@ -813,7 +813,7 @@ declare namespace usb {
*
* @since 8
*/
USB_REQUEST_DIR_FROM_DEVICE = 1
USB_REQUEST_DIR_FROM_DEVICE = 0x80
}
/**

View File

@ -45,7 +45,7 @@ const int32_t USB_REQUEST_TYPE_CLASS = 1;
const int32_t USB_REQUEST_TYPE_VENDOR = 2;
const int32_t USB_REQUEST_DIR_TO_DEVICE = 0;
const int32_t USB_REQUEST_DIR_FROM_DEVICE = 1;
const int32_t USB_REQUEST_DIR_FROM_DEVICE = 0x80;
const int32_t ACM = 1;
const int32_t ECM = 1 << 1;

View File

@ -68,8 +68,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
testParam.maxOutSize = endpoint.maxPacketSize;
testParam.outEndpoint = endpoint;
// after 7 to the left of value, it shows data from device to host
} else if (endpoint.direction == (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)) {
} else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) {
testParam.maxInSize = endpoint.maxPacketSize;
testParam.inEndpoint = endpoint
}
@ -384,7 +383,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_01 GetDescriptor')
})
@ -403,7 +402,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_02 GetStatus')
})
@ -422,7 +421,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_03 GetConfiguration')
})
@ -441,7 +440,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_04 GetInterface')
})
@ -460,7 +459,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_05 ClearFeature')
})
@ -479,7 +478,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_06 ClearFeature')
})
@ -498,7 +497,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_07 ClearFeature')
})
@ -517,7 +516,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_08 ClearFeature')
})
@ -536,7 +535,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7)
var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0)
callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_09 ClearFeature')
})

View File

@ -69,8 +69,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
testParam.outEndpoint = endpoint;
testParam.maxOutSize = endpoint.maxPacketSize;
// after 7 to the left of value, it shows data from device to host
} else if (endpoint.direction == (usb.USB_REQUEST_DIR_FROM_DEVICE << 7)) {
} else if (endpoint.direction == (usb.USB_REQUEST_DIR_FROM_DEVICE)) {
testParam.inEndpoint = endpoint
testParam.maxInSize = endpoint.maxPacketSize;
}