USB exception monitoring and automatic soft repair method and device based on HarmonyOS

By identifying USB fault types on the HarmonyOS platform and importing USB basic resource information, finding the key-value pair relationship between VID, PID and USB port, the problem of USB exception monitoring and repair is solved, and efficient USB soft fault repair is achieved, saving resources.

CN120179449APending Publication Date: 2025-06-20GUANGDONG TELEPOWER TELECOM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510347352.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

The existing technology cannot effectively monitor and automatically repair abnormal failures of USB devices, especially on the HarmonyOS platform. The detailed information of the USB interface cannot be obtained directly, resulting in the inability to determine whether the USB port is plugged into the device, and the inability to monitor and automatically repair USB abnormalities.

Method used

By identifying the USB fault type, if it is a soft fault, import the USB basic resource information of HarmonyOS, find the key-value pair relationship between VID, PID and USB port, and perform reset or dynamic configuration to repair the fault.

Benefits of technology

It realizes automated monitoring and repair of USB abnormalities, improves USB soft fault repair efficiency, reduces dependence on R&D personnel, and saves human and material resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179449A_ABST
    Figure CN120179449A_ABST
Patent Text Reader

Abstract

The invention provides a USB abnormity monitoring and automatic soft repair method and device based on HarmonyOS, and the method comprises the steps: automatically recognizing the current USB fault type, including a soft fault and a hard fault, if the current USB fault type is the hard fault, informing research and development personnel to repair the hard fault, and if the current USB fault type is the soft fault, informing the research and development personnel to repair the hard fault, and if the current USB fault type is the hard fault, informing the research and development personnel to repair the hard fault. And if yes, importing USB basic resource information of the HarmonyOS, searching a key value pair relationship among the VID, the PID and the USB port according to the USB basic resource information, and performing resetting or dynamic configuration according to a search result. According to the method, whether the fault is a soft fault or a hard fault can be automatically identified, USB abnormity monitoring and automatic soft repair are carried out on the soft fault through an asynchronous double-process technology, the USB soft fault repair efficiency is improved, the method is non-inductive to a user, the user experience is improved, research and development personnel do not need to go to the scene to check and repair the soft fault, and the cost is reduced. And a lot of manpower and material resources are saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of USB devices, and particularly to a method for USB exception monitoring and automatic soft repair based on HarmonyOS, a device for USB exception monitoring and automatic soft repair based on HarmonyOS, an electronic device, and a computer-readable medium. Background Art

[0002] Some old devices may have faults such as non-hot-pluggable USB or inability to reset, which require R & D personnel to go to the site for troubleshooting and repair, consuming a large amount of human and material resources and having low efficiency. This not only increases the maintenance cost but also may affect the normal use of the device.

[0003] At the operating system support level, the traditional HarmonyOS development framework cannot directly obtain detailed information of the USB interface, such as the physical location or port number. Although the Android system provides USB APIs, these APIs are mainly used for communicating with connected USB devices rather than directly accessing the information of the USB interface itself. Therefore, it is impossible to determine whether a device is inserted into a certain USB port, and it is impossible to monitor USB exceptions and perform automatic soft repair. Summary of the Invention

[0004] In view of the above problems, the present invention is proposed to provide a method for USB exception monitoring and automatic soft repair based on HarmonyOS and a corresponding device for USB exception monitoring and automatic soft repair based on HarmonyOS, an electronic device, and a computer-readable medium that overcome or at least partially solve the above problems.

[0005] The present invention discloses a method for USB exception monitoring and automatic soft repair based on HarmonyOS, the method comprising:

[0006] Identifying the current USB fault type; the USB fault type includes soft faults and hard faults;

[0007] If the current USB fault type is a hard fault, notifying R & D personnel to repair the hard fault;

[0008] If the current USB fault type is a soft fault, importing the USB basic resource information of HarmonyOS, and according to the USB basic resource information, finding the key-value pair relationship between the VID, PID and the USB port, and performing a reset or dynamic configuration according to the search result.

[0009] Optionally, identifying the current USB fault type includes:

[0010] Load the preset battery information access module and obtain the current voltage through the battery information access interface;

[0011] Judge whether the current USB fault type is a soft fault or a hard fault according to the current voltage.

[0012] Optionally, import the USB basic resource information of HarmonyOS, including:

[0013] Load the preset USB basic resource information access module, obtain the USB device list through the USB device list acquisition interface, and traverse the USB device list to parse the VID information and PID information.

[0014] Optionally, according to the USB basic resource information, find the key-value pair relationship between the VID, PID and the USB port, and perform a reset or dynamic configuration according to the search result, including:

[0015] Detect whether the VID information and PID information of the USB device are empty;

[0016] If the VID information and PID information are not empty, query the database to judge whether there is a key-value pair of the VID information and PID information and the USB port;

[0017] If the database has a key-value pair of the VID information and PID information and the USB port, perform a reset operation on the bound USB port according to the key-value pair of the VID information and PID information and the USB port; the key-value pair relationship between the VID, PID and the corresponding USB port is obtained by listening to the USB plug and unplug broadcast of the system in advance and binding the PID, VID and the corresponding port position.

[0018] Optionally, the method further includes:

[0019] If the database does not record the key-value pair of the VID information and PID information and the USB port, read and parse the configuration file under the preset system path, obtain the new key-value pair relationship between the VID, PID and the USB port according to the modification record in the configuration file, perform the configuration of the USB device node symbol and the port power-on and power-off node based on the new key-value pair relationship between the VID, PID and the USB port, and update the new key-value pair relationship between the VID, PID and the USB port in the database.

[0020] Optionally, the method further includes:

[0021] If the VID information and PID information are empty, read the predefined device node symbol and port power-on and power-off node information in the configuration file under the preset system path, automatically configure the device node symbol and port power-on and power-off node information, and write the mapping relationship of the device node symbol and port power-on and power-off node into the database after the configuration is completed.

[0022] The present invention also discloses a USB exception monitoring and automatic soft repair device based on HarmonyOS, and the device includes:

[0023] A fault type identification module, configured to identify the current USB fault type; the USB fault type includes soft faults and hard faults;

[0024] A hard fault repair notification module, configured to, if the current USB fault type is a hard fault, notify the R & D personnel to repair the hard fault;

[0025] A soft fault automatic repair module, configured to, if the current USB fault type is a soft fault, import the USB basic resource information of HarmonyOS, and according to the USB basic resource information, find the key - value pair relationship between the VID, PID and the USB port, and perform a reset or dynamic configuration according to the search result.

[0026] Optionally, the fault type identification module includes:

[0027] A current voltage acquisition sub - module, configured to load a preset battery information access module and obtain the current voltage through a battery information access interface;

[0028] A fault type judgment sub - module, configured to judge whether the current USB fault type is a soft fault or a hard fault according to the current voltage.

[0029] Optionally, the soft fault automatic repair module includes:

[0030] A VID and PID parsing sub - module, configured to load a preset USB basic resource information access module, obtain a USB device list through a USB device list acquisition interface, and traverse the USB device list to parse the VID information and PID information.

[0031] Optionally, the soft fault automatic repair module includes:

[0032] A null value detection sub - module, configured to detect whether the VID information and PID information of the USB device are null;

[0033] A binding relationship search sub - module, configured to, if the VID information and PID information are non - null, query the database to determine whether there is a key - value pair of the VID information and PID information and the USB port;

[0034] The first non-empty value repair sub-module is used to perform a reset operation on the bound USB port according to the key-value pair of VID information and PID information and the USB port if there is a key-value pair of VID information and PID information and the USB port in the database; the key-value pair relationship between VID, PID and the corresponding USB port is obtained by listening to the USB plug-and-play broadcast of the system in advance and binding PID, VID and the corresponding port position.

[0035] Optionally, the device further includes:

[0036] The second non-empty value repair sub-module is used to read and parse the configuration file under the preset system path if the database does not record the key-value pair of VID information and PID information and the USB port, obtain the new key-value pair relationship between VID, PID and the USB port according to the modification record in the configuration file, perform the configuration of the USB device node symbol and the port power-on / off node based on the new key-value pair relationship between VID, PID and the USB port, and update the new key-value pair relationship between VID, PID and the USB port in the database.

[0037] Optionally, the device further includes:

[0038] The null value repair sub-module is used to read the predefined device node symbol and port power-on / off node information in the configuration file under the preset system path if the VID information and PID information are null, automatically configure the device node symbol and port power-on / off node information, and write the mapping relationship of the device node symbol and port power-on / off node into the database after the configuration is completed.

[0039] The present invention also discloses an electronic device, including a processor, a communication interface, a memory and a communication bus. Among them, the processor, the communication interface and the memory complete mutual communication through the communication bus;

[0040] The memory is used to store a computer program;

[0041] When the processor is used to execute the program stored on the memory, it realizes the HarmonyOS-based USB exception monitoring and automatic soft repair method as described in the present invention.

[0042] The present invention also discloses one or more computer-readable media, on which instructions are stored. When executed by one or more processors, the instructions cause the processors to execute the HarmonyOS-based USB exception monitoring and automatic soft repair method as described in the present invention.

[0043] The present invention has the following advantages:

[0044] The USB exception monitoring and automatic soft repair method based on HarmonyOS of the present invention automatically identifies the current USB fault type. The USB fault type includes soft faults and hard faults. If the current USB fault type is a hard fault, the R & D personnel are notified to repair the hard fault. If the current USB fault type is a soft fault, the USB basic resource information of HarmonyOS is imported, and according to the USB basic resource information, the key-value pair relationship between the VID, PID and the USB port is found, and a reset or dynamic configuration is performed according to the search result. This method can automatically identify whether it is a soft fault or a hard fault. For soft faults, asynchronous dual-process technology is used for USB exception monitoring and automatic soft repair, which improves the repair efficiency of USB soft faults, is imperceptible to users, enhances the user experience, and does not require R & D personnel to travel to the site to troubleshoot and repair soft faults, saving a lot of manpower and material resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 FIG. is a flowchart of steps of a USB exception monitoring and automatic soft repair method based on HarmonyOS provided by an embodiment of the present invention;

[0046] Figure 2 FIG. is a flowchart of monitoring and repairing soft faults provided by an embodiment of the present invention;

[0047] Figure 3 FIG. is a structural block diagram of a USB exception monitoring and automatic soft repair device based on HarmonyOS provided by an embodiment of the present invention;

[0048] Figure 4 FIG. is a block diagram of an electronic device provided by an embodiment of the present invention;

[0049] Figure 5 FIG. is a schematic diagram of a computer-readable medium provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0050] In order to make the above objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0051] Referring to Figure 1 , a flowchart of steps of a USB exception monitoring and automatic soft repair method based on HarmonyOS provided by an embodiment of the present invention is shown, and specifically may include the following steps:

[0052] Step 101, identify the current USB fault type; the USB fault type includes soft faults and hard faults;

[0053] Step 102, if the current USB fault type is a hard fault, notify the R & D personnel to repair the hard fault;

[0054] Step 103: If the current USB fault type is a soft fault, import the USB basic resource information of HarmonyOS, and based on the USB basic resource information, find the key-value pair relationship between the VID, PID, and the USB port, and perform a reset or dynamic configuration according to the search result.

[0055] The present invention monitors the USB to promptly detect USB anomalies and accurately identify the USB fault type, distinguishing whether the USB fault is a soft fault or a hard fault. When the system detects a USB fault, it immediately determines the fault type. If it is determined to be a hard fault, which usually means there is a hardware-level damage or physical connection problem, the system will promptly notify the R & D personnel to intervene and repair. Since hard faults often involve the replacement or repair of hardware entities, professional on-site handling is required. By promptly notifying the R & D personnel, it can ensure that hard faults are resolved quickly and professionally, thus maintaining the stability and reliability of the entire system.

[0056] If the system identifies the USB fault as a soft fault, it will start an automated repair process based on HarmonyOS. First, import the USB basic resource information of HarmonyOS, which contains detailed information about the USB device, including the device's vendor ID, product ID, device path, USB interface, and endpoints. The system will then, based on this basic resource information, deeply search for the key-value pair relationship between the VID, PID, and the USB port. This search process is a crucial step in the automated repair and can help the system accurately locate the problematic USB device and port. Once the problem is found, the system will perform a reset operation or make dynamic configuration adjustments according to the preset strategy to attempt to restore the normal function of the USB. This process requires no manual intervention and greatly improves the efficiency and accuracy of fault repair.

[0057] In the automated repair process of soft faults, the asynchronous dual-process technology is adopted. For different search result situations, the corresponding process is selected for asynchronous processing, that is, perform a reset or dynamic configuration according to different search results, and the unselected process can be not started, saving the consumption of system space and power.

[0058] It can be seen that the method of the present invention can automatically identify whether it is a soft fault or a hard fault. For soft faults, through the asynchronous dual-process technology, it monitors USB anomalies and performs automated soft repair, improving the repair efficiency of USB soft faults, being imperceptible to users, enhancing the user experience, and eliminating the need for R & D personnel to travel to the site to troubleshoot and repair soft faults, saving a large amount of manpower and material resources.

[0059] In an optional embodiment of the present invention, identifying the current USB fault type includes:

[0060] Load the preset battery information access module and obtain the current voltage through the battery information access interface;

[0061] Judge whether the current USB fault type is a soft fault or a hard fault according to the current voltage.

[0062] In this embodiment, in order to identify the current USB fault type, a preset battery information access module can be loaded, the current voltage can be obtained through the battery information access interface, and it can be judged whether the current USB fault type is a soft fault or a hard fault according to the current voltage. The specific implementation method is as follows: load the battery information access module through "import batteryInfo from '@ohos.batteryInfo';", and then obtain the current voltage value through the batterySOC interface. If the obtained voltage value is greater than 0, it is determined that the current USB fault type is a soft fault; if the voltage value is less than or equal to 0, it is determined to be a hard fault. Different types of USB faults can be effectively distinguished by this method, providing an accurate basis for subsequent fault handling.

[0063] In an alternative embodiment of the present invention, import the USB basic resource information of HarmonyOS, including:

[0064] Load the preset USB basic resource information access module, obtain the USB device list through the USB device list acquisition interface, and traverse the USB device list to parse the VID information and PID information.

[0065] In this embodiment, in order to import the USB basic resource information of HarmonyOS, a preset USB basic resource information access module can be loaded, the USB device list can be obtained through the USB device list acquisition interface, and the USB device list can be traversed to parse the VID information and PID information. The specific implementation method is as follows: load the preset USB basic resource information access module through "import usb from '@ohos.usbManager'", import the USB basic resources related to HarmonyOS, and then obtain the USB device list through the getDeviceList interface. Then, perform a for loop traversal operation on the device list, parse the VID of each device through the idVendor() method, and parse the PID through the idProduct() method. In addition, the device path information and other related device information (such as device name, serial number, etc.) can also be parsed through the getDevicePath method.

[0066] In an alternative embodiment of the present invention, according to the USB basic resource information, find the key-value pair relationship between the VID, PID and the USB port, and perform a reset or dynamic configuration according to the search result, including:

[0067] Check whether the VID information and PID information of the USB device are empty;

[0068] If the VID information and PID information are not empty, query the database to determine whether there is a key-value pair of VID information and PID information and the USB port;

[0069] If the database has a key-value pair of VID information, PID information and the USB port, perform a reset operation on the bound USB port according to the key-value pair of VID information, PID information and the USB port; the key-value pair relationship of VID, PID and the corresponding USB port is obtained by listening to the USB plug-and-play broadcast of the system in advance and binding the PID, VID and the corresponding port position.

[0070] For the automatic repair of soft faults, the present invention first realizes efficient monitoring and processing through Process 1. The focus of Process 1 is on the real-time monitoring of the system USB plug-and-play broadcast. When a USB device is inserted or removed, the service will immediately capture relevant events, and through the listening mechanism, dynamically bind the PID and VID of the device to the corresponding USB port position. This binding process is the basis for subsequent anomaly detection and repair, ensuring that the system can accurately track the connection status of USB devices and port ownership. Through the binding operation, the service can not only record the detailed information of the device (such as vendor ID, product ID, device path, USB interface and endpoints), but also quickly locate the problem port when the device is abnormal, providing data support for the targeted repair of soft faults.

[0071] After parsing the VID information and PID information, Process 1 first checks whether the VID and PID are empty. If both are not empty, further query the pre-constructed database to verify whether there is a USB port key-value pair corresponding to the VID / PID. The database pre-stores the mapping relationship between the VID / PID and the port of all recognized devices through historical listening data, enabling the query process to be completed quickly. If there is a matching key-value pair in the database, the system directly performs a reset operation on the target USB port according to the binding relationship, effectively solving the soft fault. This reset operation does not require user intervention and is completed asynchronously in the background, ensuring the continuity of device use.

[0072] Refer to Figure 2 , the specific process is as follows:

[0073] Judge whether the VID information and PID information are empty. If the VID information and PID information are not empty, continue to the next step;

[0074] Query the database to determine whether there is already a key-value pair relationship between the VID, PID, and the USB port. If it exists, then according to the binding relationship between the VID, PID, and the USB port, power on again for reset.

[0075] During the execution of Process 1, if Process 2 does not need to be started, then continue to execute Process 1; if Process 2 needs to be started (such as for dynamic configuration or other operations), then destroy Process 2 after Process 2 finishes execution, and continue to execute Process 1.

[0076] Through the above method, the USB soft fault problem can be effectively solved, while ensuring the stability of the system and the normal operation of the USB device.

[0077] In an alternative embodiment of the present invention, the method further includes:

[0078] If the database does not record the key-value pair of the VID information, PID information, and the USB port, then read and parse the configuration file under the preset system path, obtain the new key-value pair relationship of the VID, PID, and the USB port according to the modification records in the configuration file, perform the configuration of the USB device node symbol and the port power-on / off node based on the new key-value pair relationship of the VID, PID, and the USB port, and update the new key-value pair relationship of the VID, PID, and the USB port in the database.

[0079] Since Process 1 depends on the fixed binding relationship of the PID, VID, and the port, if the USB peripheral is replaced later, and it is detected that the PID and VID are not bound or the PID and VID are detected to change, it may cause the monitoring to fail or misjudge an exception, and then trigger an unnecessary port reset. For this reason, the present invention also designs Process 2 to further improve the flexibility and compatibility of the method of the present invention.

[0080] The first situation processed by Process 2: When the system detects that the VID and PID information of the current USB device exist but the database does not record the key-value pair with the port, Process 2 will be triggered. At this time, Process 2 will read the Usb.conf configuration file under the preset system path (such as / sys / ). This file records the modification records and key parameters of the historical USB device configuration. By parsing the information in the file, the system can deduce the new key-value pair relationship of the current device's VID, PID, and the USB port. Subsequently, Process 2 automatically completes the dynamic configuration of the USB device node symbol and the port power-on / off node according to the configuration content, and updates the new key-value pair relationship to the database. After completion, Process 2 is automatically destroyed, and Process 1 continues to execute to ensure efficient use of resources.

[0081] In an alternative embodiment of the present invention, the method further includes:

[0082] If the VID information and PID information are empty, read the device node symbols and port power-on / off node information predefined in the configuration file under the preset system path, automatically configure the device node symbols and port power-on / off node information, and write the mapping relationship between the device node symbols and port power-on / off nodes into the database after the configuration is completed.

[0083] Since Process 1 depends on the fixed binding relationship of PID, VID, and the port, if the USB peripheral is replaced later, and it is detected that the PID and VID are not bound or the PID and VID are detected to change, it may cause the monitoring to fail or misjudge an exception, and then trigger an unnecessary port reset. For this reason, the present invention also designs Process 2 to further improve the flexibility and compatibility of the method of the present invention.

[0084] The second situation processed by Process 2: If it is detected that the VID and PID information are empty, Process 2 is also activated. In this scenario, the system directly reads the device node symbols and port power-on / off node information predefined in the Usb.conf file, bypasses the PID / VID binding mechanism, and directly completes the port configuration according to the preset rules. After the configuration is completed, the system writes the mapping relationship between the device node and the port into the database to avoid triggering Process 2 repeatedly later. After updating the database, Process 2 is destroyed, and Process 1 continues to execute.

[0085] It should be noted that for the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequence, because according to the embodiments of the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0086] Refer to Figure 3 , which shows the structural block diagram of a USB exception monitoring and automated soft repair device provided in an embodiment of the present invention, and specifically may include the following modules:

[0087] The fault type identification module 301 is used to identify the current USB fault type; the USB fault type includes soft faults and hard faults;

[0088] The hard fault repair notification module 302 is used to notify the R & D personnel to repair the hard fault if the current USB fault type is a hard fault;

[0089] The soft fault automatic repair module 303 is used to import the USB basic resource information of HarmonyOS if the current USB fault type is a soft fault, find the key-value pair relationship between the VID, PID and the USB port according to the USB basic resource information, and perform a reset or dynamic configuration according to the search result.

[0090] Optionally, the fault type identification module includes:

[0091] The current voltage acquisition sub-module is used to load a preset battery information access module and obtain the current voltage through the battery information access interface;

[0092] The fault type judgment sub-module is used to judge whether the current USB fault type is a soft fault or a hard fault according to the current voltage.

[0093] Optionally, the soft fault automatic repair module includes:

[0094] The VID and PID parsing sub-module is used to load a preset USB basic resource information access module, obtain the USB device list through the USB device list acquisition interface, and traverse the USB device list to parse the VID information and PID information.

[0095] Optionally, the soft fault automatic repair module includes:

[0096] The null value detection sub-module is used to detect whether the VID information and PID information of the USB device are null;

[0097] The binding relationship search sub-module is used to query the database to judge whether there is a key-value pair of VID information and PID information and the USB port if the VID information and PID information are not null;

[0098] The first non-null value repair sub-module is used to perform a reset operation on the bound USB port according to the key-value pair of VID information, PID information and the USB port if the database has the key-value pair of VID information, PID information and the USB port; the key-value pair relationship between the VID, PID and the corresponding USB port is obtained by listening to the USB plug and unplug broadcast of the system in advance and binding the PID, VID and the corresponding port position.

[0099] Optionally, the device further includes:

[0100] The second non-empty value repair sub-module is used to, if the database does not record the key-value pair of VID information and PID information with the USB port, read and parse the configuration file under the preset system path, obtain the new key-value pair relationship of VID, PID and the USB port according to the modification records in the configuration file, perform the configuration of the USB device node symbol and the port power-on / off node based on the new key-value pair relationship of VID, PID and the USB port, and update the new key-value pair relationship of VID, PID and the USB port in the database.

[0101] Optionally, the device further includes:

[0102] The null value repair sub-module is used to, if the VID information and PID information are null, read the predefined device node symbol and port power-on / off node information in the configuration file under the preset system path, automatically configure the device node symbol and port power-on / off node information, and write the mapping relationship of the device node symbol and port power-on / off node into the database after the configuration is completed.

[0103] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, please refer to the partial description of the method embodiment.

[0104] In addition, an embodiment of the present invention further provides an electronic device, as Figure 4 shown, including a processor 401, a communication interface 402, a memory 403 and a communication bus 404. Among them, the processor 401, the communication interface 402, and the memory 403 complete the communication with each other through the communication bus 404.

[0105] The memory 403 is used to store a computer program;

[0106] The processor 401 is used to implement the HarmonyOS-based USB exception monitoring and automated soft repair method as described in the above embodiments when executing the program stored on the memory 403.

[0107] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0108] The communication interface is used for the communication between the above terminal and other devices.

[0109] The memory may include a Random Access Memory (RAM), or may also include non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0110] The aforementioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0111] As Figure 5 shown, in another embodiment provided by the present invention, there is also provided a computer-readable storage medium 501. Instructions are stored in the computer-readable storage medium. When it runs on a computer, it causes the computer to execute the HarmonyOS-based USB exception monitoring and automated soft repair method described in the above embodiment.

[0112] In another embodiment provided by the present invention, there is also provided a computer program product containing instructions. When it runs on a computer, it causes the computer to execute the HarmonyOS-based USB exception monitoring and automated soft repair method described in the above embodiment.

[0113] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).

[0114] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article, or device that includes the element.

[0115] Each embodiment in this specification is described in a related manner. The same or similar parts among the embodiments can be referred to each other, and the differences between each embodiment and other embodiments are emphasized. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0116] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.

Claims

1. A USB abnormality monitoring and automated soft repair method based on HarmonyOS, characterized in that: The method comprises: Identify the current USB fault type; USB fault types include soft faults and hard faults; If the current USB fault type is a hard fault, notify the R&D personnel to repair the hard fault; If the current USB fault type is a soft fault, import the USB basic resource information of HarmonyOS, and search for the key-value pair relationship between VID, PID and USB port based on the USB basic resource information, and perform reset or dynamic configuration based on the search results.

2. The method according to claim 1, characterized in that: Identify the current USB fault type, including: Load the preset battery information access module and obtain the current voltage through the battery information access interface; The current USB fault type is determined to be a soft fault or a hard fault according to the current voltage.

3. The method according to claim 1, characterized in that Import the USB basic resource information of HarmonyOS, including: Load the preset USB basic resource information access module, obtain the USB device list through the USB device list acquisition interface, and traverse the USB device list to parse the VID information and PID information.

4. The method according to claim 3, characterized in that According to the USB basic resource information, the key-value pair relationship between VID, PID and USB port is searched, and reset or dynamic configuration is performed according to the search result, including: Check whether the VID information and PID information of the USB device are empty; If the VID information and the PID information are not empty, query the database to determine whether there is a key-value pair of the VID information, the PID information and the USB port; If the database contains a key-value pair of VID information, PID information and the USB port, a reset operation is performed on the bound USB port according to the key-value pair of VID information, PID information and the USB port; the key-value pair relationship between the VID, PID and the corresponding USB port is obtained in advance by monitoring the USB plug-in broadcast of the system, and the PID, VID and the corresponding port position are bound.

5. The method according to claim 4, characterized in that The method further comprises: If the database does not record the key-value pairs of VID information, PID information and USB port, read and parse the configuration file under the preset system path, obtain the new key-value pair relationship between VID, PID and USB port according to the modification record in the configuration file, perform the configuration of USB device node symbol and port power-on and power-off nodes based on the new key-value pair relationship between VID, PID and USB port, and update the new key-value pair relationship between VID, PID and USB port in the database.

6. The method according to claim 4, characterized in that The method further comprises: If the VID information and PID information are empty, the device node symbol and port power-on and power-off node information predefined in the configuration file under the preset system path are read, and the device node symbol and port power-on and power-off node information are automatically configured. After the configuration is completed, the mapping relationship between the device node symbol and the port power-on and power-off nodes is written into the database.

7. A USB abnormality monitoring and automatic soft repair device based on HarmonyOS, characterized in that: The device comprises: A fault type identification module is used to identify the current USB fault type; USB fault types include soft faults and hard faults; A hard fault repair notification module is used to notify R&D personnel to repair the hard fault if the current USB fault type is a hard fault; The soft fault automatic repair module is used to import the USB basic resource information of HarmonyOS if the current USB fault type is a soft fault, and search for the key-value pair relationship between VID, PID and USB port based on the USB basic resource information, and perform reset or dynamic configuration based on the search results.

8. The device according to claim 7, characterized in that The fault type identification module includes: The current voltage acquisition submodule is used to load the preset battery information access module and obtain the current voltage through the battery information access interface; The fault type judgment submodule is used to judge whether the current USB fault type is a soft fault or a hard fault according to the current voltage.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the HarmonyOS-based USB abnormality monitoring and automated soft repair method as described in any one of claims 1-6 when executing the program stored in the memory.

10. One or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to execute the USB abnormality monitoring and automated soft repair method based on HarmonyOS as described in any one of claims 1-6.