diff --git a/en/application-dev/device/usb-guidelines.md b/en/application-dev/device/usb-guidelines.md index 56e63cd47e1267a1acb08b240162dd96396c2215..bb8785c26d8ba1f13d174da1c1fa3f8393ca6df4 100644 --- a/en/application-dev/device/usb-guidelines.md +++ b/en/application-dev/device/usb-guidelines.md @@ -20,13 +20,13 @@ The following table lists the USB APIs currently available. For details, see the | getDevices(): Array> | Obtains the list of USB devices connected to the USB host. If no USB device is connected, an empty list is returned. | | setConfiguration(pipe: USBDevicePipe, config: USBConfig): number | Sets the USB device configuration. | | setInterface(pipe: USBDevicePipe, iface: USBInterface): number | Sets a USB interface. | -| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number | Claims a USB interface. | -| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout?: number): Promise\ | Performs bulk transfer. | +| claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number | Claims a USB interface. | +| bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, timeout ?: number): Promise\ | Performs bulk transfer. | | closePipe(pipe: USBDevicePipe): number | Closes a USB device pipe. | | releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number | Releases a USB interface. | | getFileDescriptor(pipe: USBDevicePipe): number | Obtains the file descriptor. | | getRawDescriptor(pipe: USBDevicePipe): Uint8Array | Obtains the raw USB descriptor. | -| controlTransfer(pipe: USBDevicePipe, contrlparam: USBControlParams, timeout?: number): Promise\ | Performs control transfer. | +| controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> | Performs control transfer. | ## How to Develop @@ -51,7 +51,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat vendorId: 7531, productId: 2, clazz: 9, - subclass: 0, + subClass: 0, protocol: 1, devAddress: 1, busNum: 1, @@ -68,7 +68,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat id: 0, protocol: 0, clazz: 9, - subclass: 0, + subClass: 0, alternateSetting: 0, name: "1-1", endpoints: [ @@ -93,7 +93,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat ``` -2. Obtain the device operation permissions. +2. Obtain the device operation permissions. ```js let deviceName = deviceList[0].name; @@ -105,11 +105,11 @@ You can set a USB device as the USB host to connect to other USB devices for dat }); ``` -3. Open the device. +3. Open the device. ```js // Open the device, and obtain the USB device pipe for data transfer. - let pipe = usb.connectDevice(deviceList[0]); + let interface1 = deviceList[0].configs[0].interfaces[0]; /* Claim the corresponding interface from deviceList. interface1 must be one present in the device configuration. @@ -117,14 +117,16 @@ You can set a USB device as the USB host to connect to other USB devices for dat usb.claimInterface(pipe, interface1, true); ``` -4. Perform data transfer. +4. Perform data transfer. ```js /* Read data. Select the corresponding RX endpoint from deviceList for data transfer. (endpoint.direction == 0x80); dataUint8Array indicates the data to read. The data type is Uint8Array. */ - + let inEndpoint = interface1.endpoints[2]; + let outEndpoint = interface1.endpoints[1]; + let dataUint8Array = new Uint8Array(1024); usb.bulkTransfer(pipe, inEndpoint, dataUint8Array, 15000).then(dataLength => { if (dataLength >= 0) { console.info("usb readData result Length : " + dataLength); @@ -137,7 +139,7 @@ You can set a USB device as the USB host to connect to other USB devices for dat console.info("usb readData error : " + JSON.stringify(error)); }); // Send data. Select the corresponding TX endpoint from deviceList for data transfer. (endpoint.direction == 0) - usb.bulkTransfer(pipe, endpoint, dataUint8Array, 15000).then(dataLength => { + usb.bulkTransfer(pipe, outEndpoint, dataUint8Array, 15000).then(dataLength => { if (dataLength >= 0) { console.info("usb writeData result write length : " + dataLength); } else { diff --git a/en/application-dev/dfx/Readme-EN.md b/en/application-dev/dfx/Readme-EN.md index b8a4496e09420b3a7557e5c8b8996deaf14ce1c9..4ed700a49b94ef0c296ec27eaf9c5cde96575234 100644 --- a/en/application-dev/dfx/Readme-EN.md +++ b/en/application-dev/dfx/Readme-EN.md @@ -1,8 +1,13 @@ # DFX -- [Development of Application Event Logging](hiappevent-guidelines.md) -- [Development of Performance Tracing](hitracemeter-guidelines.md) -- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md) +- Application Event Logging + - [Development of Application Event Logging](hiappevent-guidelines.md) +- Distributed Call Chain Tracing + - [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md) +- HiLog + - [HiLog Development](hilog-guidelines.md) +- Performance Tracing + - [Development of Performance Tracing](hitracemeter-guidelines.md) - Error Management - [Development of Error Manager](errormanager-guidelines.md) - [Development of Application Recovery](apprecovery-guidelines.md) diff --git a/en/application-dev/dfx/hilog-guidelines.md b/en/application-dev/dfx/hilog-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..f2a2fc7debf9b924d1b8db8894316adc6a826876 --- /dev/null +++ b/en/application-dev/dfx/hilog-guidelines.md @@ -0,0 +1,37 @@ +# HiLog Development +## Introduction +HiLog is the log system of OpenHarmony that provides logging for the system framework, services, and applications to record information on user operations and system running status. +> **NOTE** +> This development guide is applicable only when you use Native APIs for application development. For details about the APIs, see [HiLog Native API Reference](https://gitee.com/openharmony-sig/interface_native_header/blob/master/en/native_sdk/dfx/log.h). + +## Available APIs +| API/Macro| Description| +| -------- | -------- | +| int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...) | Outputs logs based on the specified log type, log level, service domain, log tag, and variable parameters determined by the format specifier and privacy identifier in the printf format.| +| #define OH_LOG_DEBUG(type, ...) ((void)OH_LOG_Print((type), LOG_DEBUG, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__))| Outputs DEBUG logs. This is a function-like macro.| +| #define OH_LOG_INFO(type, ...) ((void)OH_LOG_Print((type), LOG_INFO, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs INFO logs. This is a function-like macro.| +| #define OH_LOG_WARN(type, ...) ((void)OH_LOG_Print((type), LOG_WARN, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs WARN logs. This is a function-like macro.| +| #define OH_LOG_ERROR(type, ...) ((void)OH_LOG_Print((type), LOG_ERROR, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs ERROR logs. This is a function-like macro.| +| #define OH_LOG_FATAL(type, ...) ((void)OH_LOG_Print((type), LOG_FATAL, LOG_DOMAIN, LOG_TAG, \_*VA*ARGS__)) | Outputs FATAL logs. This is a function-like macro.| +| bool OH_LOG_IsLoggable(unsigned int domain, const char *tag, LogLevel level) | Checks whether logs of the specified service domain, tag, and level can be printed.
Input arguments:
- **domain**: service domain.
- **tag**: log tag.
- **level**: log level.
Output arguments: none
Return value: Returns **true** if the specified logs can be printed; returns **false** otherwise.| + +## Development Examples +1. Include the **hilog** header file in the source file. +```c++ +#include "hilog/log.h" +``` +2. Define the **domain** and **tag** macros. +```c++ +#undef LOG_DOMAIN +#undef LOG_TAG +#define LOG_DOMAIN 0x3200 // Service domain. The value ranges from 0xD0000 to 0xDFFFF. +#define LOG_TAG "MY_TAG" +``` +3. Print logs. For example, to print INFO logs, use the following code: +```c++ +OH_LOG_INFO(LOG_APP, "Failed to visit %{private}s, reason:%{public}d.", url, errno); +``` +4. View the output log information. +``` +12-11 12:21:47.579 2695 2695 I A03200/MY_TAG: Failed to visit , reason:11. +``` diff --git a/en/application-dev/dfx/hitracechain-guidelines.md b/en/application-dev/dfx/hitracechain-guidelines.md index affd260b0503f3c4f4c4b748d5911d94f7fef9e3..37ca65ece66a124eb8a72f1fd865f30d26024627 100644 --- a/en/application-dev/dfx/hitracechain-guidelines.md +++ b/en/application-dev/dfx/hitracechain-guidelines.md @@ -2,9 +2,7 @@ ## Introduction -The hiTraceChain module provides APIs to implement call chain tracing throughout a service process. This can help you quickly obtain the run log for the call chain of a specified service process and locate faults in inter-device, inter-process, or inter-thread communications. - -hiTraceChain is a lightweight implementation of the cloud-based distributed call chain tracing. It allows applications to trace cross-thread, cross-process, and cross-device service calls. The hiTraceChain module generates a unique **chainId** for a service process and passes it to various information (including application events, system time, and logs) specific to the service process. During debugging and fault locating, you can use the unique **chainId** to quickly correlate various information related to the service process. +hiTraceChain is a lightweight implementation of the cloud-based distributed call chain tracing. It allows applications to trace cross-thread, cross-process, and cross-device service calls. The hiTraceChain module generates a unique **chainId** for a service process and passes it to various information (including application events, system time, and logs) specific to the service process. During debugging and fault locating, you can use the unique **chainId** to quickly correlate various information related to the service process. The hiTraceChain module provides APIs to implement call chain tracing throughout a service process. This can help you quickly obtain the run log for the call chain of a specified service process and locate faults in inter-device, inter-process, or inter-thread communications. ## Basic Concepts @@ -18,47 +16,106 @@ The APIs for distributed call chain tracing are provided by the **hiTraceChain** **APIs for distributed call chain tracing** -| API| Return Value| Description| -| ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ | -| hiTraceChain.begin(name: string, flags: number = HiTraceFlag.DEFAULT) | HiTraceId | Starts call chain tracing.| -| hiTraceChain.tracepoint(mode: HiTraceCommunicationMode, type: HiTraceTracepointType, id: HiTraceId, msg?: string) | void | Creates a trace point.| -| hiTraceChain.end(id: HiTraceId) | void | Stops call chain tracing.| +| API | Return Value | Description | +| ------------------------------------------------------------------------------------------------------------------- | -------------- | ------------ | +| hiTraceChain.begin(name: string, flags: number = HiTraceFlag.DEFAULT) | HiTraceId | Starts call chain tracing. | +| hiTraceChain.end(id: HiTraceId) | void | Stops call chain tracing. | ## How to Develop -In this example, distributed call chain tracing begins when the application startup execution page is loaded and stops when the service usage is completed. - -1. Create a JS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **js** > **default** > **pages** > **index**, and double-click **index.js**. Add the code to implement call chain tracing upon page loading. The sample code is as follows: - - ``` - import hiTraceChain from '@ohos.hiTraceChain' - - export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - - // 1. Enable distributed call chain tracing. - let asyncTraceId = hiTraceChain.begin("business", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC | hiTraceChain.HiTraceFlag.DONOT_CREATE_SPAN); - - // 2. Start the service process. - console.log(`business start`); - - // 3. Add a trace point. - hiTraceChain.tracepoint(hiTraceChain.HiTraceCommunicationMode.THREAD, hiTraceChain.HiTraceTracepointType.SS, asyncTraceId, "Just an example"); - - // 4. Keep the service process running. - console.log(`business running`); - - // 5. End the service process. - console.log(`business end`); - - // 6. Stop call chain tracing. - hiTraceChain.end(asyncTraceId); - } - } +The following example illustrates how to simulate one-time [system event logging](../reference/apis/js-apis-hisysevent.md) to implement cross-thread distributed call chain tracing in a single HAP service. + +1. Create an eTS application project. In the displayed **Project** window, choose **entry** > **src** > **main** > **ets** > **pages** > **index.ets**, and double-click **index.ets**. Then, add a button to trigger system event logging. + + ```ts + import hiTraceChain from '@ohos.hiTraceChain'; + import hiSysEvent from '@ohos.hiSysEvent'; + + @Entry + @Component + struct Index { + @State message: string = 'Start writing system event'; + + build() { + Row() { + Column() { + Button(this.message) + .fontSize(20) + .margin(5) + .width(350) + .height(60) + .fontWeight(FontWeight.Bold) + .onClick(() => { + try { + // Enable distributed call chain tracing before the service starts. + let traceId = hiTraceChain.begin("Write a new system event", hiTraceChain.HiTraceFlag.INCLUDE_ASYNC); + // Implement one-time system event logging when the service starts. + hiSysEvent.write({ + domain: "RELIABILITY", + name: "STACK", + eventType: hiSysEvent.EventType.FAULT, + params: { + PID: 1, + UID: 1, + PACKAGE_NAME: "com.demo.hitracechain", + PROCESS_NAME: "hitracechaindemo", + MSG: "no msg." + } + }).then((val) => { + console.info(`write result is ${val}`); + // Disable distributed call chain tracing when the service ends. + hiTraceChain.end(traceId); + }).catch((err) => { + console.error(`error message is ${err.message}`); + }); + } catch (err) { + console.error(`error message is ${err.message}`); + } + }) + } + .width('100%') + } + .height('100%') + } + } + ``` + +2. Touch the run button on the IDE to run the project. Then, touch the **Start writing system event** button on the application UI to trigger system event logging. + +3. View the information printed in the **Log** window. You can use **.*: \[([0-9a-zA-Z]{15}),.*].*** to access distributed call chain tracing information specific to the HAP service. The process ID of the HAP service is **8801**. Two threads, whose IDs are **8801** and **8819**, are involved in the system event logging. Based on the chain ID **edcfa53017a88e3**, you can then effectively trace the log information of the two threads. + ```text + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain I C02d03/HiTraceC: [edcfa53017a88e3, 0, 0] HiTraceBegin name:Write a new system event flags:0x01. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: chainId is edcfa53017a88e3. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: spanId is 0. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: parentSpanId is 0. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 0, 0] Native2Js: flags is 1. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] domain is RELIABILITY. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] name is STACK. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] eventType is 1. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=3, typeName=6. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=3, typeName=6. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain E C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] napi value type not match: valueType=4, typeName=6. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] create napi value of string type, value is JSHiSysEventWrite. + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain I C03900/Ace: [edcfa53017a88e3, 0, 0] [flutter_ace_view.cpp(operator())-(0)] Mark 0 id Touch Event Processed + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ClientMsgHandler: [edcfa53017a88e3, 0, 0] in OnDispatchEventProcessed, enter + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, enter + 07-05 19:50:47.690 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] size=312, sysevent={"domain_":"RELIABILITY","name_":"STACK","type_":1,"time_":47591447690,"tz_":"+0000","pid_":8801,"tid_":8819,"uid_":20010045,"traceid_":"edcfa53017a88e3","spanid_":"0","pspanid_":"0","trace_flag_":1,"UID":1,"PID":1,"MSG":"no msg.","PROCESS_NAME":"hitracechaindemo","PACKAGE_NAME":"com.demo.hitracechain"} + 07-05 19:50:47.690 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, Processed event type:0, id:831, actionTime:6694499314, currentTime:6694501330, timeoutTime:4997984 + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02800/ANRHandler: [edcfa53017a88e3, 0, 0] in SetLastProcessedEventId, leave + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02800/ClientMsgHandler: [edcfa53017a88e3, 0, 0] in OnDispatchEventProcessed, leave + 07-05 19:50:47.691 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] reset send buffer size old=245760, new=524288 + 07-05 19:50:47.691 8801-8819/com.demo.hitracechain D C02d08/HISYSEVENT: [edcfa53017a88e3, 0, 0] HiSysEvent send data successful + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d08/NAPI_HISYSEVENT_UTIL: [edcfa53017a88e3, 0, 0] create napi value of int32 type, value is 0. + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain E A0fefe/JsApp: [edcfa53017a88e3, 399db38, 0] write result is 0 + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: chainId is edcfa53017a88e3. + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: spanId is 0. + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: parentSpanId is 0. + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain D C02d03/HITRACE_UTIL_NAPI: [edcfa53017a88e3, 399db38, 0] Js2Native: flags is 1. + 07-05 19:50:47.691 8801-8801/com.demo.hitracechain I C02d03/HiTraceC: [edcfa53017a88e3, 399db38, 0] HiTraceEnd. ``` -2. Click the run button on the application page. Then, you'll obtain the log information for service analysis. +## About Cross-Process/Cross-Device Distributed Call Chain Tracing + +Cross-process/cross-device distributed call chain tracing depends on the NAPI implementation of the corresponding service APIs of each OpenHarmony module. For details, see the [HiTraceChain Development](../../device-dev/subsystems/subsys-dfx-hitracechain.md). diff --git a/en/application-dev/reference/apis/js-apis-usb-deprecated.md b/en/application-dev/reference/apis/js-apis-usb-deprecated.md index 68a127a08bdfd1df0ca558866dc3cde577e2b25a..95eb105b0a25fc824b4f7762a73e035283097ddc 100644 --- a/en/application-dev/reference/apis/js-apis-usb-deprecated.md +++ b/en/application-dev/reference/apis/js-apis-usb-deprecated.md @@ -43,7 +43,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); vendorId: 7531, productId: 2, clazz: 9, - subclass: 0, + subClass: 0, protocol: 1, devAddress: 1, busNum: 1, @@ -60,7 +60,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); id: 0, protocol: 0, clazz: 9, - subclass: 0, + subClass: 0, alternateSetting: 0, name: "1-1", endpoints: [ @@ -171,7 +171,7 @@ usb.requestRight(devicesName).then((ret) => { ## usb.claimInterface -claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number +claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number Claims a USB interface. @@ -348,7 +348,7 @@ let ret = usb.getFileDescriptor(devicepipe); ## usb.controlTransfer -controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> Performs control transfer. @@ -380,7 +380,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { ## usb.bulkTransfer -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. diff --git a/en/application-dev/reference/apis/js-apis-usb.md b/en/application-dev/reference/apis/js-apis-usb.md index a0a0dc40c837d45da72209b5faa6a57ed0b95909..521fef517823a160e22a17b752fdc62443eeba7a 100644 --- a/en/application-dev/reference/apis/js-apis-usb.md +++ b/en/application-dev/reference/apis/js-apis-usb.md @@ -42,7 +42,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); vendorId: 7531, productId: 2, clazz: 9, - subclass: 0, + subClass: 0, protocol: 1, devAddress: 1, busNum: 1, @@ -59,7 +59,7 @@ console.log(`devicesList = ${JSON.stringify(devicesList)}`); id: 0, protocol: 0, clazz: 9, - subclass: 0, + subClass: 0, alternateSetting: 0, name: "1-1", endpoints: [ @@ -252,7 +252,7 @@ if (usb.addRight(bundleName, devicesName) { ## usb.claimInterface -claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number +claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): number Claims a USB interface. @@ -429,7 +429,7 @@ let ret = usb.getFileDescriptor(devicepipe); ## usb.controlTransfer -controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number> +controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?: number): Promise<number> Performs control transfer. @@ -461,7 +461,7 @@ usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { ## usb.bulkTransfer -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. diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md index cb0f8cead65cd1faed98c723d30f557b4302bbab..1369bb7bc6f4fe3c5aeb24693c72b550a387b60c 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @@ -9,7 +9,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for subscribing to real-time system events: - ``` + ```shell hisysevent -r ``` @@ -21,7 +21,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for enabling the debugging mode: - ``` + ```shell hisysevent -r -d ``` @@ -29,11 +29,11 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -d | Subscription to real-time system events in debugging mode.| + | -d | Subscribes to real-time system events in debugging mode.| - Command for subscribing to real-time system events by event tag: - ``` + ```shell hisysevent -r -t [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` @@ -42,12 +42,12 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | | -t | Event tag used to filter subscribed real-time system events.| - | -c | Matching rule for event tags. The option can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| + | -c | Matching rule for event tags. The options can be **WHOLE_WORD**, **PREFIX**, or **REGULAR**.| Example: - ``` - # hisysevent -r -t "STA" -c PREFIX + ```shell + # hisysevent -r -t "STA" -c PREFIX {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963670809,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805200750","HAPPEN_TIME":1501963670809,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"4973863135535405472","info_":""} # hisysevent -r -t "STAw{0,6}" -c REGULAR {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963793206,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805200953","HAPPEN_TIME":1501963793206,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} @@ -57,7 +57,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for subscribing to real-time system events by event domain and event name: - ``` + ```shell hisysevent -r -o -n [-c [WHOLE_WORD|PREFIX|REGULAR]] ``` @@ -67,11 +67,11 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | -------- | -------- | | -o | Event domain used to filter subscribed real-time system events.| | -n | Event name used to filter subscribed real-time system events.| - | -c | Matching rule for event domains and event names. The option can be **WHOLE_WORD**, PREFIX, or **REGULAR**.| + | -c | Matching rule for event domains and event names. The options can be **WHOLE_WORD**, PREFIX, or **REGULAR**.| Example: - ``` + ```shell # hisysevent -r -o "RELIABILITY" -n "APP_FREEZE" {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201309","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} # hisysevent -r -o "RELIABI\w{0,8}" -n "APP_FREEZE" -c REGULAR @@ -85,7 +85,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for subscribing to real-time system events by event type: - ``` + ```shell hisysevent -r -g [FAULT|STATISTIC|SECURITY|BEHAVIOR] ``` @@ -97,7 +97,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Example: - ``` + ```shell # hisysevent -r -o "RELIABILITY" -n "APP_FREEZE" -g FAULT {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201309","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} # hisysevent -r -o "POWER\w{0,8}" -n "POWER_RUNNINGLOCK" -c REGULAR -g STATISTIC @@ -108,11 +108,12 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** {"domain_":"MULTIMODALINPUT","name_":"Z_ORDER_WINDOW_CHANGE","type_":4,"time_":1667549852735,"tz_":"+0000","pid_":2577,"tid_":2588,"uid_":6696,"OLD_ZORDER_FIRST_WINDOWID":-1,"NEW_ZORDER_FIRST_WINDOWID":2,"OLD_ZORDER_FIRST_WINDOWPID":-1,"NEW_ZORDER_FIRST_WINDOWPID":1458,"MSG":"The ZorderFirstWindow changing succeeded","level_":"MINOR","tag_":"PowerStats","id_":"16847308118559691400","info_":""} ``` + ## Querying Historical System Events - Command for querying historical system events: - ``` + ```shell hisysevent -l ``` @@ -124,7 +125,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Command for querying historical system events within the specified period of time: - ``` + ```shell hisysevent -l -s -e ``` @@ -132,21 +133,46 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -s | Start time for querying historical system events. Only system events generated after the start time are returned.| - | -e | End time for querying historical system events. Only system events generated before the end time are returned.| + | -s | Original start timestamp for querying historical system events. Only system events generated after the start time are returned.| + | -e | Original end timestamp for querying historical system events. Only system events generated before the end time are returned.| Example: - ``` + ```shell # hisysevent -l -s 1501964222980 -e 1501964222996 {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""} {"domain_":"GRAPHIC","name_":"NO_DRAW","type_":1,"time_":1501964222980,"tz_":"+0000","pid_":1505,"tid_":1585,"uid_":10002,"PID":1505,"UID":10002,"ABILITY_NAME":"","MSG":"It took 1957104259905ns to draw, UI took 0ns to draw, RSRenderThread took 8962625ns to draw, RSRenderThread dropped 0 UI Frames","level_":"MINOR","id_":"1708287249901948387","info_":"isResolved,eventId:0"} {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222994,"tz_":"+0000","pid_":623,"tid_":1445,"uid_":1201,"SUB_EVENT_TYPE":"NO_DRAW","EVENT_TIME":"20170805201702","MODULE":"NO_DRAW","PNAME":"NO_DRAW","REASON":"NO_DRAW","DIAG_INFO":"","STACK":"SUMMARY:\n","HIVIEW_LOG_FILE_PATHS":["/data/log/faultlog/faultlogger/appfreeze-NO_DRAW-10002-20170805201702"],"DOMAIN":"GRAPHIC","STRING_ID":"NO_DRAW","PID":1505,"UID":10002,"PACKAGE_NAME":"NO_DRAW","PROCESS_NAME":"","MSG":"It took 1956945826265ns to draw, UI took 0ns to draw, RSRenderThread took 9863293ns to draw, RSRenderThread dropped 0 UI Frames\n","level_":"CRITICAL","tag_":"STABILITY","id_":"10448522101019619655","info_":""} ``` -- Command for setting the maximum number of historical events that can be queried: +- Command for querying historical system events within the specified period of time: + ```shell + hisysevent -l -S -E ``` + + Description of command options: + + | Option| Description| + | -------- | -------- | + | -S | Original start timestamp for querying historical system events. Only system events generated after the start time are returned.| + | -E | Original end timestamp for querying historical system events. Only system events generated after the start time are returned.| + + Example: + + ```shell + # hisysevent -l -S "2023-01-05 14:12:50" -E "2023-01-05 14:12:51" + {"domain_":"GRAPHIC","name_":"JANK_FRAME_SKIP","type_":1,"time_":1672899170022,"tz_":"+0800","pid_":1499,"tid_":1573,"uid_":20010037,"PID":1499,"UID":20010037,"ABILITY_NAME":"com.ohos.launcher","MSG":"It took 587948726ns to draw, UI took 483016382ns to draw, RSRenderThread took 96616051ns to draw, RSRenderThread dropped 0 UI Frames","level_":"MINOR","id_":"11351278822867091090","info_":"","seq_":307} + {"domain_":"AAFWK","name_":"START_ABILITY_ERROR","type_":1,"time_":1672899170108,"tz_":"+0800","pid_":550,"tid_":1127,"uid_":5523,"USER_ID":-1,"BUNDLE_NAME":"com.ohos.wallpaper","MODULE_NAME":"","ABILITY_NAME":"WallpaperExtAbility","ERROR_CODE":2097152,"level_":"MINOR","tag_":"ability","id_":"53589395004188308060","info_":"","seq_":313} + {"domain_":"GRAPHIC","name_":"JANK_FRAME_SKIP","type_":1,"time_":1672899170305,"tz_":"+0800","pid_":1293,"tid_":1632,"uid_":10006,"PID":1293,"UID":10006,"ABILITY_NAME":"com.ohos.systemui","MSG":"It took 309597490ns to draw, UI took 92364718ns to draw, RSRenderThread took 205874105ns to draw, RSRenderThread dropped 1 UI Frames","level_":"MINOR","id_":"14843220972178010722","info_":"","seq_":314} + {"domain_":"GRAPHIC","name_":"JANK_FRAME_SKIP","type_":1,"time_":1672899170350,"tz_":"+0800","pid_":1293,"tid_":1632,"uid_":10006,"PID":1293,"UID":10006,"ABILITY_NAME":"com.ohos.systemui","MSG":"It took 259782859ns to draw, UI took 33909753ns to draw, RSRenderThread took 44849879ns to draw, RSRenderThread dropped 5 UI Frames","level_":"MINOR","id_":"66610006717219916560","info_":"","seq_":315} + {"domain_":"AAFWK","name_":"CONNECT_SERVICE_ERROR","type_":1,"time_":1672899170733,"tz_":"+0800","pid_":550,"tid_":1127,"uid_":5523,"USER_ID":100,"BUNDLE_NAME":"com.ohos.wallpaper","MODULE_NAME":"","ABILITY_NAME":"WallpaperExtAbility","ERROR_CODE":2097152,"level_":"MINOR","tag_":"ability","id_":"10040008376311927188","info_":"","seq_":317} + {"domain_":"COMMONEVENT","name_":"PUBLISH","type_":2,"time_":1672899170063,"tz_":"+0800","pid_":550,"tid_":937,"uid_":5523,"USER_ID":-1,"PUBLISHER_BUNDLE_NAME":"","PID":0,"UID":1101,"EVENT_NAME":"usual.event.SCREEN_ON","level_":"MINOR","id_":"80996758983032931610","info_":"","seq_":308} + ``` + +- Command for setting the maximum number of historical events that can be queried: + + ```shell hisysevent -l -m ``` @@ -158,14 +184,14 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Example: - ``` + ```shell # hisysevent -l -s 1501964222980 -e 1501964222996 -m 1 {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""} ``` - Command for querying historical system events by event domain and event name: - ``` + ```shell hisysevent -l -o -n [-c WHOLE_WORD] ``` @@ -173,24 +199,24 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -o | Domain based on which historical system events are queried.| - | -n | Name based on which historical system events are queried.| + | -o | Event domain based on which historical system events are queried.| + | -n | Event name based on which historical system events are queried.| | -c | Rule for matching the domain and name of historical system events. The option can only be **WHOLE_WORD**.| Example: - ``` + ```shell # hisysevent -l -n "APP_FREEZE" {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201309","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} - # hisysevent -r -o "RELIABILITY" + # hisysevent -l -o "RELIABILITY" {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201544","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"13456525196455104060","info_":""} - # hisysevent -r -o "RELIABILITY" -n "APP_FREEZE" -c WHOLE_WORD + # hisysevent -l -o "RELIABILITY" -n "APP_FREEZE" -c WHOLE_WORD {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201633","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"12675246910904037271","info_":""} ``` - Command for querying historical system events by event type: - ``` + ```shell hisysevent -l -g [FAULT|STATISTIC|SECURITY|BEHAVIOR] ``` @@ -202,7 +228,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Example: - ``` + ```shell # hisysevent -l -o "RELIABILITY" -g FAULT {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501963989773,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201309","HAPPEN_TIME":1501963989773,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"16367997008075110557","info_":""} # hisysevent -l -n "POWER_RUNNINGLOCK" -c WHOLE_WORD -g STATISTIC @@ -217,7 +243,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** - Enabling system event validity check - ``` + ```shell hisysevent -v ``` @@ -229,7 +255,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** Example: - ``` + ```shell # hisysevent -v -l -s 1501964222980 -e 1501964222996 # The **HAPPEN_TIME** and **VERSION** fields are not configured in the YAML file for the **APP_FREEZE** event that belongs to the **RELIABILITY** domain. Therefore, the two fields are highlighted in red. {"domain_":"RELIABILITY","name_":"APP_FREEZE","type_":1,"time_":1501964222980,"pid_":1505,"uid_":10002,"FAULT_TYPE":"4","MODULE":"com.ohos.screenlock","REASON":"NO_DRAW","SUMMARY":"SUMMARY:\n","LOG_PATH":"/data/log/faultlog/faultlogger/appfreeze-com.ohos.screenlock-10002-20170805201702","HAPPEN_TIME":1501964222980,"VERSION":"1.0.0","level_":"CRITICAL","tag_":"STABILITY","id_":"10435592800188571430","info_":""}