未验证 提交 6c687aa2 编写于 作者: O openharmony_ci 提交者: Gitee

!12758 fix: USB document update

Merge pull request !12758 from 罗巍/master
......@@ -17,17 +17,17 @@ USB类开放能力如下,具体请查阅[API参考文档](../reference/apis/js
| 接口名 | 描述 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| hasRight(deviceName: string): boolean | 如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。 |
| requestRight(deviceName: string): Promise<boolean> | 请求给定软件包的临时权限以访问设备。 |
| hasRight(deviceName: string): boolean | 判断是否有权访问该设备 |
| requestRight(deviceName: string): Promise<boolean> | 请求软件包的临时权限以访问设备。使用Promise异步回调。 |
| removeRight(deviceName: string): boolean | 移除软件包对设备的访问权限。|
| connectDevice(device: USBDevice): Readonly<USBDevicePipe> | 根据`getDevices()`返回的设备信息打开USB设备。 |
| getDevices(): Array<Readonly<USBDevice>> | 返回USB设备列表。 |
| getDevices(): Array<Readonly<USBDevice>> | 获取接入主设备的USB设备列表。如果没有设备接入,那么将会返回一个空的列表。 |
| setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | 设置设备的配置。 |
| setInterface(pipe: USBDevicePipe, iface: USBInterface): number | 设置设备的接口。 |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface,force?: boolean): number | 获取接口。 |
| claimInterface(pipe: USBDevicePipe, iface: USBInterface,force?: boolean): number | 注册通信接口。 |
| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> | 批量传输。 |
| closePipe(pipe: USBDevicePipe): number | 关闭设备消息控制通道。 |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放接口。 |
| releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | 释放注册过的通信接口。 |
| getFileDescriptor(pipe: USBDevicePipe): number | 获取文件描述符。 |
| getRawDescriptor(pipe: USBDevicePipe): Uint8Array | 获取原始的USB描述符。 |
| controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> | 控制传输。 |
......@@ -42,7 +42,7 @@ USB设备可作为Host设备连接Device设备进行数据传输。开发示例
```js
// 导入USB接口api包。
import usb from '@ohos.usb';
import usb from '@ohos.usbV9';
// 获取设备列表。
let deviceList = usb.getDevices();
/*
......
......@@ -87,7 +87,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`);
connectDevice(device: USBDevice): Readonly<USBDevicePipe>
打开USB设备。
根据getDevices()返回的设备信息打开USB设备。
需要调用[usb.getDevices](#usbgetdevices)获取设备信息以及device,再调用[usb.requestRight](#usbrequestright)请求使用该设备的权限。
......@@ -134,6 +134,8 @@ hasRight(deviceName: string): boolean
判断是否有权访问该设备。
如果“使用者”(如各种App或系统)有权访问设备则返回true;无权访问设备则返回false。
**系统能力:** SystemCapability.USB.USBManager
**参数:**
......@@ -187,7 +189,7 @@ usb.requestRight(devicesName).then((ret) => {
## usb.removeRight
removeRight(deviceName: string): boolean;
removeRight(deviceName: string): boolean
移除软件包访问设备的权限。
......@@ -216,7 +218,7 @@ if (usb.removeRight(devicesName) {
## usb.addRight
addRight(bundleName: string, deviceName: string): boolean;
addRight(bundleName: string, deviceName: string): boolean
添加软件包访问设备的权限。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册