提交 b2113654 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 809833a6
...@@ -158,7 +158,6 @@ Requests the temporary permission for the application to access the USB device. ...@@ -158,7 +158,6 @@ Requests the temporary permission for the application to access the USB device.
}); });
``` ```
## usb.claimInterface ## usb.claimInterface
claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number
...@@ -243,14 +242,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -243,14 +242,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
console.log(`setConfiguration = ${ret}`); console.log(`setConfiguration = ${ret}`);
``` ```
## usb.setInterface ## usb.setInterface
setInterface(pipe: USBDevicePipe, iface: USBInterface): number setInterface(pipe: USBDevicePipe, iface: USBInterface): number
Sets a USB interface. Sets a USB interface.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, and call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter. Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and interfaces, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim a USB interface..
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
...@@ -290,7 +288,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -290,7 +288,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Uint8Array | Raw descriptor data. | | Uint8Array | Raw descriptor data. The value **undefined** indicates that the operation has failed. |
- **Example** - **Example**
```js ```js
...@@ -316,7 +314,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -316,7 +314,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | File descriptor of the USB device. | | number | File descriptor of the USB device. The value **-1** indicates that the operation has failed. |
- **Example** - **Example**
```js ```js
...@@ -360,7 +358,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim ...@@ -360,7 +358,7 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
Performs bulk transfer. Performs bulk transfer.
Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim the USB interface. Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB device list and endpoints, call [usb.requestRight](#usbrequestright) to request the device access permission, call [usb.connectDevice](#usbconnectdevice) to obtain **devicepipe** as an input parameter, and call [usb.claimInterface](#usbclaiminterface) to claim a USB interface.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
...@@ -381,7 +379,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -381,7 +379,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
```js ```js
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. // Call usb.claimInterface to claim a USB interface. After that, call usb.bulkTransfer to start bulk transfer.
usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => {
console.log(`bulkTransfer = ${JSON.stringify(ret)}`); console.log(`bulkTransfer = ${JSON.stringify(ret)}`);
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册