diff --git a/en/application-dev/reference/apis/js-apis-hidebug.md b/en/application-dev/reference/apis/js-apis-hidebug.md index c0844b51cbcc220251492c04c2d2d222b0f7f018..1a60d7d8e44145f22df7a25328f371e578fcc302 100644 --- a/en/application-dev/reference/apis/js-apis-hidebug.md +++ b/en/application-dev/reference/apis/js-apis-hidebug.md @@ -1,13 +1,13 @@ # HiDebug -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. You can run the hidebug command to obtain the memory usage of an application, including the static heap memory (native heap) and proportional set size (PSS) occupied by the application process. You can also export VM memory slices and collect VM CPU profiling data. ## Modules to Import -``` +```js import hidebug from '@ohos.hidebug'; ``` @@ -18,9 +18,11 @@ getNativeHeapSize(): bigint Obtains the total size of the native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | --------------------------- | @@ -28,7 +30,7 @@ Obtains the total size of the native heap memory. **Example** - ``` + ```js let nativeHeapSize = hidebug.getNativeHeapSize(); ``` @@ -39,17 +41,19 @@ getNativeHeapAllocatedSize(): bigint Obtains the size of the allocated native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | --------------------------------- | | bigint | Size of the allocated native heap memory.| **Example** - ``` + ```js let nativeHeapAllocatedSize = hidebug.getNativeHeapAllocatedSize(); ``` @@ -60,17 +64,19 @@ getNativeHeapFreeSize(): bigint Obtains the size of the free native heap memory. +This API is defined but not implemented in OpenHarmony 3.1 Release. + **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | ------------------------------- | | bigint | Size of the free native heap memory.| **Example** - ``` + ```js let nativeHeapFreeSize = hidebug.getNativeHeapFreeSize(); ``` @@ -84,14 +90,14 @@ Obtains the PSS of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | ------------------------- | | bigint | PSS of the process.| **Example** - ``` + ```js let pss = hidebug.getPss(); ``` @@ -105,17 +111,58 @@ Obtains the size of the shared dirty memory of this process. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug -**Return Value** +**Return value** | Type | Description | | ------ | -------------------------- | | bigint | Size of the shared dirty memory of the process.| **Example** - ``` + ```js let sharedDirty = hidebug.getSharedDirty(); ``` +## hidebug.getPrivateDirty9+ + +getPrivateDirty(): bigint + +Obtains the size of the private dirty memory of this process. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| bigint | Size of the private dirty memory of the process.| + + +**Example** + ```js + let privateDirty = hidebug.getPrivateDirty(); + ``` + +## hidebug.getCpuUsage9+ + +getCpuUsage(): number + +Obtains the CPU usage of this process. + +For example, if the CPU usage is **50%**, **0.5** is returned. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| number | CPU usage of the process.| + + +**Example** + ```js + let cpuUsage = hidebug.getCpuUsage(); + ``` ## hidebug.startProfiling @@ -135,9 +182,9 @@ Starts the profiling method. `startProfiling()` and `stopProfiling()` are called ```js hidebug.startProfiling("cpuprofiler-20220216"); -// Code block +// code block // ... -// Code block +// code block hidebug.stopProfiling(); ``` @@ -147,7 +194,7 @@ hidebug.stopProfiling(); stopProfiling() : void -Stops the profiling method. `stopProfiling()` and `startProfiling()` are called in pairs. `stopProfiling()` always occurs after `startProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. +Stops the profiling method. `startProfiling()` and `stopProfiling()` are called in pairs. `startProfiling()` always occurs before `stopProfiling()`; that is, calling the functions in the following sequences is prohibited: `start->start->stop`, `start->stop->stop`, and `start->start->stop->stop`. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug @@ -155,9 +202,9 @@ Stops the profiling method. `stopProfiling()` and `startProfiling()` are called ```js hidebug.startProfiling("cpuprofiler-20220216"); -// Code block +// code block // ... -// Code block +// code block hidebug.stopProfiling(); ``` @@ -165,13 +212,13 @@ hidebug.stopProfiling(); dumpHeapData(filename : string) : void -Exports the heap data. +Exports data from the specified heap file. **System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug **Parameters** -| Name | Type | Mandatory| Description | +| Name | Type | Mandatory | Description | | -------- | ------ | ---- | ------------------------------------------------------------ | | filename | string | Yes | User-defined heap file name. The `filename.heapsnapshot` file is generated in the `files` directory of the app based on the specified `filename`.| @@ -180,3 +227,31 @@ Exports the heap data. ```js hidebug.dumpHeapData("heap-20220216"); ``` + +## hidebug.getServiceDump9+ + +getServiceDump(serviceid : number) : string + +Obtains information on the specified system service. + +This is a system API and cannot be called by third-party applications. + +**System capability**: SystemCapability.HiviewDFX.HiProfiler.HiDebug + +**Parameters** + +| Name | Type | Mandatory| Description | +| -------- | ------ | ---- | ------------------------------------------------------------ | +| serviceid | number | Yes | ID of the system service. | + +**Return value** +| Type | Description | +| ------ | -------------------------- | +| string | Absolute path of the file that contains the service information to dump. | + +**Example** + +```js +let serviceId = 10; +let pathName = hidebug.getServiceDump(serviceId); +``` diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index 6e01a04d39cb77575893a77937dfa65d9c0d3461..5a1bd85196e27394a0dcb8225df846e6aa52b541 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -1,12 +1,11 @@ # USB -> **NOTE** -> +> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import -``` +```js import usb from "@ohos.usb"; ``` @@ -18,68 +17,66 @@ Obtains the USB device list. **System capability**: SystemCapability.USB.USBManager -**Return value** - -| Type| Description| -| -------- | -------- | -| Array<Readonly<[USBDevice](#usbdevice)>> | Device information list.| - -**Example** - -``` -let devicesList = usb.getDevices(); -console.log(`devicesList = ${JSON.stringify(devicesList)}`); -// devicesList is a list of USB devices. -// A simple example of devicesList is provided as follows: -[ - { - name: "1-1", - serial: "", - manufacturerName: "", - productName: "", - version: "", - vendorId: 7531, - productId: 2, - clazz: 9, - subclass: 0, - protocol: 1, - devAddress: 1, - busNum: 1, - configs: [ - { - id: 1, - attributes: 224, - isRemoteWakeup: true, - isSelfPowered: true, - maxPower: 0, - name: "1-1", - interfaces: [ - { - id: 0, - protocol: 0, - clazz: 9, - subclass: 0, - alternateSetting: 0, - name: "1-1", - endpoints: [ - { - address: 129, - attributes: 3, - interval: 12, - maxPacketSize: 4, - direction: 128, - number: 1, - type: 3, - interfaceId: 0, - }, - ], - }, - ], - }, - ], - }, -] -``` +- **Return value** + | Type| Description| + | -------- | -------- | + | Array<Readonly<[USBDevice](#usbdevice)>> | Device information list.| + +- **Example** + ```js + let devicesList = usb.getDevices(); + console.log(`devicesList = ${JSON.stringify(devicesList)}`); + // devicesList is a list of USB devices. + // A simple example of devicesList is provided as follows: + [ + { + name: "1-1", + serial: "", + manufacturerName: "", + productName: "", + version: "", + vendorId: 7531, + productId: 2, + clazz: 9, + subclass: 0, + protocol: 1, + devAddress: 1, + busNum: 1, + configs: [ + { + id: 1, + attributes: 224, + isRemoteWakeup: true, + isSelfPowered: true, + maxPower: 0, + name: "1-1", + interfaces: [ + { + id: 0, + protocol: 0, + clazz: 9, + subclass: 0, + alternateSetting: 0, + name: "1-1", + endpoints: [ + { + address: 129, + attributes: 3, + interval: 12, + maxPacketSize: 4, + direction: 128, + number: 1, + type: 3, + interfaceId: 0, + }, + ], + }, + ], + }, + ], + }, + ] + ``` ## usb.connectDevice @@ -92,24 +89,21 @@ 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.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | device | [USBDevice](#usbdevice) | Yes| USB device information.| -**Example** +- **Return value** + | Type| Description| + | -------- | -------- | + | Readonly<[USBDevicePipe](#usbdevicepipe)> | USB device pipe for data transfer.| -``` -let devicepipe= usb.connectDevice(device); -console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); -``` +- **Example** + ```js + let devicepipe= usb.connectDevice(device); + console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); + ``` ## usb.hasRight @@ -120,25 +114,22 @@ 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.| +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | deviceName | string | Yes| Device name.| -**Return value** +- **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** - -``` -let divicesName="1-1"; -let bool = usb.hasRight(divicesName); -console.log(bool); -``` +- **Example** + ```js + let divicesName="1-1"; + let bool = usb.hasRight(divicesName); + console.log(bool); + ``` ## usb.requestRight @@ -149,26 +140,23 @@ Requests the temporary permission for the application to access the USB device. **System capability**: SystemCapability.USB.USBManager -**Parameters** +- **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.| -**Return value** - -| Type| Description| -| -------- | -------- | -| Promise<boolean> | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.| - -**Example** - -``` -let divicesName="1-1"; -usb.requestRight(divicesName).then((ret) => { - console.log(`requestRight = ${JSON.stringify(ret)}`); -}); -``` +- **Example** + ```js + let divicesName="1-1"; + usb.requestRight(divicesName).then((ret) => { + console.log(`requestRight = ${JSON.stringify(ret)}`); + }); + ``` ## usb.claimInterface @@ -181,26 +169,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -**Parameters** +- **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.| -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.| - -**Example** - -``` -let ret = usb.claimInterface(devicepipe, interfaces); -console.log(`claimInterface = ${ret}`); -``` +- **Example** + ```js + let ret = usb.claimInterface(devicepipe, interfaces); + console.log(`claimInterface = ${ret}`); + ``` ## usb.releaseInterface @@ -213,25 +198,22 @@ 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.| +- **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.| -**Return value** +- **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** - -``` -let ret = usb.releaseInterface(devicepipe, interfaces); -console.log(`releaseInterface = ${ret}`); -``` +- **Example** + ```js + let ret = usb.releaseInterface(devicepipe, interfaces); + console.log(`releaseInterface = ${ret}`); + ``` ## usb.setConfiguration @@ -244,25 +226,22 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -**Parameters** +- **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.| -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| - -**Example** - -``` -let ret = usb.setConfiguration(devicepipe, config); -console.log(`setConfiguration = ${ret}`); -``` +- **Example** + ```js + let ret = usb.setConfiguration(devicepipe, config); + console.log(`setConfiguration = ${ret}`); + ``` ## usb.setInterface @@ -275,25 +254,22 @@ 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.| - -**Return value** +- **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.| -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| +- **Return value** + | Type| Description| + | -------- | -------- | + | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.| -**Example** - -``` -let ret = usb.setInterface(devicepipe, interfaces); -console.log(`setInterface = ${ret}`); -``` +- **Example** + ```js + let ret = usb.setInterface(devicepipe, interfaces); + console.log(`setInterface = ${ret}`); + ``` ## usb.getRawDescriptor @@ -306,23 +282,20 @@ 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.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| Uint8Array | Raw descriptor data.| +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| -**Example** +- **Return value** + | Type| Description| + | -------- | -------- | + | Uint8Array | Raw descriptor data.| -``` -let ret = usb.getRawDescriptor(devicepipe); -``` +- **Example** + ```js + let ret = usb.getRawDescriptor(devicepipe); + ``` ## usb.getFileDescriptor @@ -335,23 +308,20 @@ 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.| +- **Parameters** + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| -**Return value** +- **Return value** + | Type| Description| + | -------- | -------- | + | number | File descriptor of the USB device.| -| Type| Description| -| -------- | -------- | -| number | File descriptor of the USB device.| - -**Example** - -``` -let ret = usb.getFileDescriptor(devicepipe); -``` +- **Example** + ```js + let ret = usb.getFileDescriptor(devicepipe); + ``` ## usb.controlTransfer @@ -364,27 +334,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi **System capability**: SystemCapability.USB.USBManager -**Parameters** +- **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.| -**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.| - -**Example** - -``` -usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { - console.log(`controlTransfer = ${JSON.stringify(ret)}`); -}) -``` +- **Example** + ```js + usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { + console.log(`controlTransfer = ${JSON.stringify(ret)}`); + }) + ``` ## usb.bulkTransfer @@ -397,31 +364,28 @@ 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.| - -**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.| - -**Example** - -``` -// 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. -// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. -usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { - console.log(`bulkTransfer = ${JSON.stringify(ret)}`); -}); -``` +- **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.| + +- **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.| + +- **Example** + ```js + // 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. + // Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. + usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { + console.log(`bulkTransfer = ${JSON.stringify(ret)}`); + }); + ``` ## usb.closePipe @@ -434,24 +398,21 @@ 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.| - -**Return value** - -| Type| Description| -| -------- | -------- | -| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| - -**Example** - -``` -let ret = usb.closePipe(devicepipe); -console.log(`closePipe = ${ret}`); -``` +- **Parameters** + | 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.| + +- **Example** + ```js + let ret = usb.closePipe(devicepipe); + console.log(`closePipe = ${ret}`); + ``` ## USBEndpoint