diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 5ec4d9e336475374b6519a4f724f3666931e4b6d..51a5615b69ef513c1c05d5fc13daa4a4948396a7 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -11,7 +11,7 @@ import usb from "@ohos.usb"; ## usb.getDevices -usb.getDevices(): Array<Readonly<USBDevice>> +getDevices(): Array<Readonly<USBDevice>> Obtains the USB device list. @@ -81,7 +81,7 @@ Obtains the USB device list. ## usb.connectDevice -usb.connectDevice(device: USBDevice): Readonly<USBDevicePipe> +connectDevice(device: USBDevice): Readonly<USBDevicePipe> Connects to a USB device. @@ -108,7 +108,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.hasRight -usb.hasRight(deviceName: string): boolean +hasRight(deviceName: string): boolean Checks whether the application has the permission to access the device. @@ -134,7 +134,7 @@ Checks whether the application has the permission to access the device. ## usb.requestRight -usb.requestRight(deviceName: string): Promise<boolean> +requestRight(deviceName: string): Promise<boolean> Requests the temporary permission for the application to access the USB device. @@ -161,7 +161,7 @@ Requests the temporary permission for the application to access the USB device. ## usb.claimInterface -usb.claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number +claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number Claims a USB interface. @@ -190,7 +190,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.releaseInterface -usb.releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number +releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number Releases a USB interface. @@ -218,7 +218,7 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ## usb.setConfiguration -usb.setConfiguration(pipe: USBDevicePipe, config: USBConfig): number +setConfiguration(pipe: USBDevicePipe, config: USBConfig): number Sets the device configuration. @@ -246,7 +246,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.setInterface -usb.setInterface(pipe: USBDevicePipe, iface: USBInterface): number +setInterface(pipe: USBDevicePipe, iface: USBInterface): number Sets a USB interface. @@ -274,7 +274,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.getRawDescriptor -usb.getRawDescriptor(pipe: USBDevicePipe): Uint8Array +getRawDescriptor(pipe: USBDevicePipe): Uint8Array Obtains the raw USB descriptor. @@ -300,7 +300,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.getFileDescriptor -usb.getFileDescriptor(pipe: USBDevicePipe): number +getFileDescriptor(pipe: USBDevicePipe): number Obtains the file descriptor. @@ -326,7 +326,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.controlTransfer -usb.controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise<number> Performs control transfer. @@ -356,7 +356,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.bulkTransfer -usb.bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> +bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise<number> Performs bulk transfer. @@ -390,7 +390,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ## usb.closePipe -usb.closePipe(pipe: USBDevicePipe): number +closePipe(pipe: USBDevicePipe): number Closes a USB device pipe. @@ -421,14 +421,14 @@ Represents the USB endpoint from which data is sent or received. You can obtain | Name| Type| Description| | -------- | -------- | -------- | -| address | number | Endpoint address.
**System capability**: SystemCapability.USB.USBManager| -| attributes | number | Endpoint attributes.
**System capability**: SystemCapability.USB.USBManager| -| interval | number | Endpoint interval.
**System capability**: SystemCapability.USB.USBManager| -| maxPacketSize | number | Maximum size of data packets on the endpoint.
**System capability**: SystemCapability.USB.USBManager| -| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction.
**System capability**: SystemCapability.USB.USBManager| -| number | number | Endpoint number.
**System capability**: SystemCapability.USB.USBManager| -| type | number | Endpoint type.
**System capability**: SystemCapability.USB.USBManager| -| interfaceId | number | Unique ID of the interface to which the endpoint belongs.
**System capability**: SystemCapability.USB.USBManager| +| address | number | Endpoint address.
**System capability**: SystemCapability.USB.USBManager| +| attributes | number | Endpoint attributes.
**System capability**: SystemCapability.USB.USBManager| +| interval | number | Endpoint interval.
**System capability**: SystemCapability.USB.USBManager| +| maxPacketSize | number | Maximum size of data packets on the endpoint.
**System capability**: SystemCapability.USB.USBManager| +| direction | [USBRequestDirection](#usbrequestdirection) | Endpoint direction.
**System capability**: SystemCapability.USB.USBManager| +| number | number | Endpoint number.
**System capability**: SystemCapability.USB.USBManager| +| type | number | Endpoint type.
**System capability**: SystemCapability.USB.USBManager| +| interfaceId | number | Unique ID of the interface to which the endpoint belongs.
**System capability**: SystemCapability.USB.USBManager| ## USBInterface @@ -437,13 +437,13 @@ Represents a USB interface. One [USBConfig](#usbconfig) can contain multiple **U | Name| Type| Description| | -------- | -------- | -------- | -| id | number | Unique ID of the USB interface.
**System capability**: SystemCapability.USB.USBManager| -| protocol | number | Interface protocol.
**System capability**: SystemCapability.USB.USBManager| -| clazz | number | Device type.
**System capability**: SystemCapability.USB.USBManager| -| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| -| alternateSetting | number | Settings for alternating between descriptors of the same USB interface.
**System capability**: SystemCapability.USB.USBManager| -| name | string | Interface name.
**System capability**: SystemCapability.USB.USBManager| -| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface.
**System capability**: SystemCapability.USB.USBManager| +| id | number | Unique ID of the USB interface.
**System capability**: SystemCapability.USB.USBManager| +| protocol | number | Interface protocol.
**System capability**: SystemCapability.USB.USBManager| +| clazz | number | Device type.
**System capability**: SystemCapability.USB.USBManager| +| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| +| alternateSetting | number | Settings for alternating between descriptors of the same USB interface.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Interface name.
**System capability**: SystemCapability.USB.USBManager| +| endpoints | Array<[USBEndpoint](#usbendpoint)> | Endpoints that belong to the USB interface.
**System capability**: SystemCapability.USB.USBManager| ## USBConfig @@ -452,13 +452,13 @@ Represents the USB configuration. One [USBDevice](#usbdevice) can contain multip | Name| Type| Description| | -------- | -------- | -------- | -| id | number | Unique ID of the USB configuration.
**System capability**: SystemCapability.USB.USBManager| -| attributes | number | Configuration attributes.
**System capability**: SystemCapability.USB.USBManager| -| maxPower | number | Maximum power consumption, in mA.
**System capability**: SystemCapability.USB.USBManager| -| name | string | Configuration name, which can be left empty.
**System capability**: SystemCapability.USB.USBManager| -| isRemoteWakeup | boolean | Support for remote wakeup.
**System capability**: SystemCapability.USB.USBManager| -| isSelfPowered | boolean | Support for independent power supplies.
**System capability**: SystemCapability.USB.USBManager| -| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes.
**System capability**: SystemCapability.USB.USBManager| +| id | number | Unique ID of the USB configuration.
**System capability**: SystemCapability.USB.USBManager| +| attributes | number | Configuration attributes.
**System capability**: SystemCapability.USB.USBManager| +| maxPower | number | Maximum power consumption, in mA.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Configuration name, which can be left empty.
**System capability**: SystemCapability.USB.USBManager| +| isRemoteWakeup | boolean | Support for remote wakeup.
**System capability**: SystemCapability.USB.USBManager| +| isSelfPowered | boolean | Support for independent power supplies.
**System capability**: SystemCapability.USB.USBManager| +| interfaces | Array <[USBInterface](#usbinterface)> | Supported interface attributes.
**System capability**: SystemCapability.USB.USBManager| ## USBDevice @@ -467,19 +467,19 @@ Represents the USB device information. | Name| Type| Description| | -------- | -------- | -------- | -| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| -| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| -| serial | string | Device SN.
**System capability**: SystemCapability.USB.USBManager| -| name | string | Device name.
**System capability**: SystemCapability.USB.USBManager| -| manufacturerName | string | Device manufacturer.
**System capability**: SystemCapability.USB.USBManager| -| productName | string | Product information.
**System capability**: SystemCapability.USB.USBManager| -| version | string | Version.
**System capability**: SystemCapability.USB.USBManager| -| vendorId | number | Vendor ID.
**System capability**: SystemCapability.USB.USBManager| -| productId | number | Product ID.
**System capability**: SystemCapability.USB.USBManager| -| clazz | number | Device class.
**System capability**: SystemCapability.USB.USBManager| -| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| -| protocol | number | Device protocol code.
**System capability**: SystemCapability.USB.USBManager| -| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information.
**System capability**: SystemCapability.USB.USBManager| +| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| +| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| +| serial | string | Device SN.
**System capability**: SystemCapability.USB.USBManager| +| name | string | Device name.
**System capability**: SystemCapability.USB.USBManager| +| manufacturerName | string | Device manufacturer.
**System capability**: SystemCapability.USB.USBManager| +| productName | string | Product information.
**System capability**: SystemCapability.USB.USBManager| +| version | string | Version.
**System capability**: SystemCapability.USB.USBManager| +| vendorId | number | Vendor ID.
**System capability**: SystemCapability.USB.USBManager| +| productId | number | Product ID.
**System capability**: SystemCapability.USB.USBManager| +| clazz | number | Device class.
**System capability**: SystemCapability.USB.USBManager| +| subClass | number | Device subclass.
**System capability**: SystemCapability.USB.USBManager| +| protocol | number | Device protocol code.
**System capability**: SystemCapability.USB.USBManager| +| configs | Array<[USBConfig](#usbconfig)> | Device configuration descriptor information.
**System capability**: SystemCapability.USB.USBManager| ## USBDevicePipe @@ -488,8 +488,8 @@ Represents a USB device pipe, which is used to determine a USB device. | Name| Type| Description| | -------- | -------- | -------- | -| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| -| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| +| busNum | number | Bus address.
**System capability**: SystemCapability.USB.USBManager| +| devAddress | number | Device address.
**System capability**: SystemCapability.USB.USBManager| ## USBControlParams @@ -499,11 +499,11 @@ Represents control transfer parameters. | Name| Type| Description| | -------- | -------- | -------- | | request | number | Request type.| -| target | [USBRequestTargetType](#usbrequesttargettype) | Request target type.
**System capability**: SystemCapability.USB.USBManager| -| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type.
**System capability**: SystemCapability.USB.USBManager| -| value | number | Request parameters
**System capability**: SystemCapability.USB.USBManager| -| index | number | Index of the request parameter value.
**System capability**: SystemCapability.USB.USBManager| -| data | Uint8Array | Buffer for writing or reading data.
**System capability**: SystemCapability.USB.USBManager| +| target | [USBRequestTargetType](#usbrequesttargettype) | Represents the request target type.
**System capability**: SystemCapability.USB.USBManager| +| reqType | [USBControlRequestType](#usbcontrolrequesttype) | Request control type.
**System capability**: SystemCapability.USB.USBManager| +| value | number | Request parameters
**System capability**: SystemCapability.USB.USBManager| +| index | number | Index of the request parameter value.
**System capability**: SystemCapability.USB.USBManager| +| data | Uint8Array | Buffer for writing or reading data.
**System capability**: SystemCapability.USB.USBManager| ## USBRequestTargetType @@ -511,30 +511,30 @@ Represents control transfer parameters. Represents the request target type. -| Name| Default Value| Description| +| Name| Default Value | Description| | -------- | -------- | -------- | -| USB\_REQUEST\_TARGET\_DEVICE | 0 | Device.
**System capability**: SystemCapability.USB.USBManager| -| USB\_REQUEST\_TARGET\_INTERFACE | 1 | Interface.
**System capability**: SystemCapability.USB.USBManager| -| USB\_REQUEST\_TARGET\_ENDPOINT | 2 | Endpoint
**System capability**: SystemCapability.USB.USBManager| -| USB_REQUEST_TARGET_OTHER | 3 | Others
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TARGET_DEVICE | 0 | Device.
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TARGET_INTERFACE | 1 | Interface.
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TARGET_ENDPOINT | 2 | Endpoint
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TARGET_OTHER | 3 | Others
**System capability**: SystemCapability.USB.USBManager| ## USBControlRequestType Enumerates control request types. -| Name| Default Value| Description| +| Name| Default Value | Description| | -------- | -------- | -------- | -| USB\_REQUEST\_TYPE\_STANDARD | 0 | Standard
**System capability**: SystemCapability.USB.USBManager| -| USB\_REQUEST\_TYPE\_CLASS | 1 | Class
**System capability**: SystemCapability.USB.USBManager| -| USB\_REQUEST\_TYPE\_VENDOR | 2 | Vendor
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TYPE_STANDARD | 0 | Standard
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TYPE_CLASS | 1 | Class.
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_TYPE_VENDOR | 2 | Vendor
**System capability**: SystemCapability.USB.USBManager| ## USBRequestDirection Enumerates request directions. -| Name| Default Value| Description| +| Name| Default Value | Description| | -------- | -------- | -------- | -| USB\_REQUEST\_TYPE\_STANDARD | 0 | Request for writing data from the host to the device.
**System capability**: SystemCapability.USB.USBManager| -| USB\_REQUEST\_TYPE\_CLASS | 0x80 | Request for reading data from the device to the host.
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device.
**System capability**: SystemCapability.USB.USBManager| +| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host.
**System capability**: SystemCapability.USB.USBManager|