From cceb52c3f76374a5618bba86fc45de4af5449808 Mon Sep 17 00:00:00 2001 From: king_he <6384784@qq.com> Date: Mon, 23 May 2022 10:08:39 +0000 Subject: [PATCH] update en/application-dev/reference/apis/js-apis-usb.md. Signed-off-by: king_he <6384784@qq.com> --- .../reference/apis/js-apis-usb.md | 310 +++++++++--------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index dfe9aac155..06aee1c2fe 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -18,9 +18,9 @@ Obtains the USB device list. **System capability**: SystemCapability.USB.USBManager - **Return value** - | Type | Description | - | -------- | -------- | - | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list. | + | Type| Description| + | -------- | -------- | + | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list. | - **Example** ```js @@ -90,14 +90,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | device | [USBDevice](#usbdevice) | Yes | USB device information. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | device | [USBDevice](#usbdevice) | Yes| USB device information. | - **Return value** - | Type | Description | - | -------- | -------- | - | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer. | + | Type| Description| + | -------- | -------- | + | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer. | - **Example** ```js @@ -115,14 +115,14 @@ Checks whether the application has the permission to access the device. **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | deviceName | string | Yes | Device name. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceName | string | Yes| Device name. | - **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise. | - **Example** ```js @@ -141,14 +141,14 @@ Requests the temporary permission for the application to access the USB device. **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | deviceName | string | Yes | Device name. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceName | string | Yes| Device name. | - **Return value** - | Type | Description | - | -------- | -------- | - | Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise. | + | Type| Description| + | -------- | -------- | + | Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise. | - **Example** ```js @@ -170,16 +170,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | - | iface | [USBInterface](#usbinterface) | Yes | USB interface, which is used to determine the index of the interface to claim. | - | force | boolean | No | Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim. | + | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. | + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. | - **Example** ```js @@ -199,15 +199,15 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | - | iface | [USBInterface](#usbinterface) | Yes | USB interface, which is used to determine the index of the interface to release. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise. | + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise. | - **Example** ```js @@ -227,15 +227,15 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | - | config | [USBConfig](#usbconfig) | Yes | USB configuration to set. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | config | [USBConfig](#usbconfig) | Yes| USB configuration to set. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise. | + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise. | - **Example** ```js @@ -255,15 +255,15 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | - | iface | [USBInterface](#usbinterface) | Yes | USB interface to set. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | + | iface | [USBInterface](#usbinterface) | Yes| USB interface to set. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise. | + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise. | - **Example** ```js @@ -283,14 +283,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | - **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Raw descriptor data. | + | Type| Description| + | -------- | -------- | + | Uint8Array | Raw descriptor data. | - **Example** ```js @@ -309,14 +309,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | Device pipe, which is used to determine the bus number and device address. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | File descriptor of the USB device. | + | Type| Description| + | -------- | -------- | + | number | File descriptor of the USB device. | - **Example** ```js @@ -335,16 +335,16 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | USB device pipe, which is used to determine the USB device. | - | contrlparam | [USBControlParams](#usbcontrolparams) | Yes | Control transfer parameters. | - | timeout | number | No | Timeout duration. The default value is **0**, indicating no timeout. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | + | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters. | + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | - **Return value** - | Type | Description | - | -------- | -------- | - | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | + | Type| Description| + | -------- | -------- | + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | - **Example** ```js @@ -365,17 +365,17 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | USB device pipe, which is used to determine the USB device. | - | endpoint | [USBEndpoint](#usbendpoint) | Yes | USB endpoint, which is used to determine the USB port for data transfer. | - | buffer | Uint8Array | Yes | Buffer for writing or reading data. | - | timeout | number | No | Timeout duration. The default value is **0**, indicating no timeout. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | + | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer. | + | buffer | Uint8Array | Yes| Buffer for writing or reading data. | + | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | - **Return value** - | Type | Description | - | -------- | -------- | - | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | + | Type| Description| + | -------- | -------- | + | Promise<number> | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | - **Example** ```js @@ -399,14 +399,14 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager - **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | pipe | [USBDevicePipe](#usbdevicepipe) | Yes | USB device pipe. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe. | - **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise. | + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise. | - **Example** ```js @@ -421,16 +421,16 @@ Represents the USB endpoint from which data is sent or received. You can obtain **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | address | number | Endpoint address. | - | attributes | number | Endpoint attributes. | - | interval | number | Endpoint interval. | - | maxPacketSize | number | Maximum size of data packets on the endpoint. | - | direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction. | - | number | number | Endpoint number. | - | type | number | Endpoint type. | - | interfaceId | number | Unique ID of the interface to which the endpoint belongs. | +| Name| Type| Description| +| -------- | -------- | -------- | +| address | number | Endpoint address. | +| attributes | number | Endpoint attributes. | +| interval | number | Endpoint interval. | +| maxPacketSize | number | Maximum size of data packets on the endpoint. | +| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction. | +| number | number | Endpoint number. | +| type | number | Endpoint type. | +| interfaceId | number | Unique ID of the interface to which the endpoint belongs. | ## USBInterface @@ -439,15 +439,15 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | id | number | Unique ID of the USB interface. | - | protocol | number | Interface protocol. | - | clazz | number | Device type. | - | subClass | number | Device subclass. | - | alternateSetting | number | Settings for alternating between descriptors of the same USB interface. | - | name | string | Interface name. | - | endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface. | +| Name| Type| Description| +| -------- | -------- | -------- | +| id | number | Unique ID of the USB interface. | +| protocol | number | Interface protocol. | +| clazz | number | Device type. | +| subClass | number | Device subclass. | +| alternateSetting | number | Settings for alternating between descriptors of the same USB interface. | +| name | string | Interface name. | +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface. | ## USBConfig @@ -456,15 +456,15 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | id | number | Unique ID of the USB configuration. | - | attributes | number | Configuration attributes. | - | maxPower | number | Maximum power consumption, in mA. | - | name | string | Configuration name, which can be left empty. | - | isRemoteWakeup | boolean | Support for remote wakeup. | - | isSelfPowered | boolean | Support for independent power supplies. | - | interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes. | +| Name| Type| Description| +| -------- | -------- | -------- | +| id | number | Unique ID of the USB configuration. | +| attributes | number | Configuration attributes. | +| maxPower | number | Maximum power consumption, in mA. | +| name | string | Configuration name, which can be left empty. | +| isRemoteWakeup | boolean | Support for remote wakeup. | +| isSelfPowered | boolean | Support for independent power supplies. | +| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes. | ## USBDevice @@ -473,21 +473,21 @@ Represents USB device information. **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | busNum | number | Bus address. | - | devAddress | number | Device address. | - | serial | string | Device SN. | - | name | string | Device name. | - | manufacturerName | string | Device manufacturer. | - | productName | string | Product information. | - | version | string | Version. | - | vendorId | number | Vendor ID. | - | productId | number | Product ID. | - | clazz | number | Device class. | - | subClass | number | Device subclass. | - | protocol | number | Device protocol code. | - | configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information. | +| Name| Type| Description| +| -------- | -------- | -------- | +| busNum | number | Bus address. | +| devAddress | number | Device address. | +| serial | string | Device SN. | +| name | string | Device name. | +| manufacturerName | string | Device manufacturer. | +| productName | string | Product information. | +| version | string | Version. | +| vendorId | number | Vendor ID. | +| productId | number | Product ID. | +| clazz | number | Device class. | +| subClass | number | Device subclass. | +| protocol | number | Device protocol code. | +| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information. | ## USBDevicePipe @@ -496,10 +496,10 @@ Represents a USB device pipe, which is used to determine a USB device. **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | busNum | number | Bus address. | - | devAddress | number | Device address. | +| Name| Type| Description| +| -------- | -------- | -------- | +| busNum | number | Bus address. | +| devAddress | number | Device address. | ## USBControlParams @@ -508,14 +508,14 @@ Represents control transfer parameters. **System capability**: SystemCapability.USB.USBManager - | Name | Type | Description | - | -------- | -------- | -------- | - | request | number | Request type. | - | target | [USBRequestTargetType](#usbrequesttargettype) | Type of the request target. | - | reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type. | - | value | number | Request parameters | - | index | number | Index of the request parameter value. | - | data | Uint8Array | Buffer for writing or reading data. | +| Name| Type| Description| +| -------- | -------- | -------- | +| request | number | Request type. | +| target | [USBRequestTargetType](#usbrequesttargettype) | Type of the request target. | +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type. | +| value | number | Request parameters| +| index | number | Index of the request parameter value. | +| data | Uint8Array | Buffer for writing or reading data. | ## USBRequestTargetType @@ -524,12 +524,12 @@ Represents the request target type. **System capability**: SystemCapability.USB.USBManager - | Name | Default Value | Description | - | -------- | -------- | -------- | - | USB_REQUEST_TARGET_DEVICE | 0 | Device. | - | USB_REQUEST_TARGET_INTERFACE | 1 | Interface. | - | USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint | - | USB_REQUEST_TARGET_OTHER | 3 | Others | +| Name| Default Value | Description| +| -------- | -------- | -------- | +| USB_REQUEST_TARGET_DEVICE | 0 | Device. | +| USB_REQUEST_TARGET_INTERFACE | 1 | Interface. | +| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint| +| USB_REQUEST_TARGET_OTHER | 3 | Others| ## USBControlRequestType @@ -538,11 +538,11 @@ Enumerates control request types. **System capability**: SystemCapability.USB.USBManager - | Name | Default Value | Description | - | -------- | -------- | -------- | - | USB_REQUEST_TYPE_STANDARD | 0 | Standard | - | USB_REQUEST_TYPE_CLASS | 1 | Class. | - | USB_REQUEST_TYPE_VENDOR | 2 | Vendor | +| Name| Default Value | Description| +| -------- | -------- | -------- | +| USB_REQUEST_TYPE_STANDARD | 0 | Standard| +| USB_REQUEST_TYPE_CLASS | 1 | Class. | +| USB_REQUEST_TYPE_VENDOR | 2 | Vendor| ## USBRequestDirection @@ -551,7 +551,7 @@ Enumerates request directions. **System capability**: SystemCapability.USB.USBManager - | Name | Default Value | Description | - | -------- | -------- | -------- | - | USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device. | - | USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host. | +| Name| Default Value | Description| +| -------- | -------- | -------- | +| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device. | +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host. | -- GitLab