External equipment anomaly detection method and device, electronic equipment and storage medium

By creating multiple peripheral driver modules and sending heartbeat packets regularly, the embedded device can detect abnormalities of external devices that are inconsistent with the communication protocol, solving problems that cannot be detected in the prior art and improving user experience.

CN119561875APending Publication Date: 2025-03-04SHENZHEN SKYWORTH DISPLAY TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411677936.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

Existing embedded devices cannot detect abnormalities on external devices that are inconsistent with their communication protocols, resulting in inconvenient user experience.

Method used

By obtaining the configuration file, multiple peripheral driver modules are created, each containing a communication protocol and an external device type. When an external device connection is detected, the device type is obtained and the matching peripheral driver module is determined, and the heartbeat packet is sent regularly and the response heartbeat packet is parsed to detect device abnormality.

Benefits of technology

The abnormal detection of external devices with different communication protocols is realized, and the problem that existing embedded devices cannot detect external devices with inconsistent communication protocols is solved, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119561875A_ABST
    Figure CN119561875A_ABST
Patent Text Reader

Abstract

According to the external equipment anomaly detection method and device, the electronic equipment and the storage medium provided by the embodiment of the invention, each established peripheral driving module in the technical scheme can support conversion of the heartbeat packet for detecting the anomaly of the external equipment into the protocol heartbeat packet corresponding to the included communication protocol, and the protocol heartbeat packet is sent to the external equipment; according to the embodiment of the invention, the method achieves the anomaly detection of the external equipment with different communication protocols, effectively solves a problem that the conventional embedded equipment cannot carry out the anomaly detection of the external equipment which is not consistent with the communication protocol of the conventional embedded equipment, and brings inconvenience to a user, and greatly improves the use experience of the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the technical field of device detection, and in particular, to a method, device, electronic device and storage medium for detecting anomalies of an external device. Background Art

[0002] In the current field of embedded devices, with the continuous development of technology and the increasing richness of application scenarios, in order to make embedded devices have more functions, embedded devices usually need to be connected to external devices and use external devices to implement certain specific functions to meet the actual needs of users.

[0003] Currently, there are external devices on the market, including but not limited to sensors, actuators, communication modules, etc. Various external devices are manufactured by different manufacturers, resulting in different communication protocols supported by the external devices and embedded devices.

[0004] Existing embedded devices can only perform anomaly detection on external devices with consistent communication protocols. They cannot perform anomaly detection on external devices with inconsistent communication protocols supported by the embedded devices. This can easily cause the embedded devices to be unable to detect anomalies of external devices in a timely manner, causing inconvenience to users in using the embedded devices, greatly reducing the user experience. Summary of the invention

[0005] In view of this, in order to solve the problem that existing embedded devices cannot detect anomalies of external devices that are inconsistent with their communication protocols, causing inconvenience to users in using embedded devices, an embodiment of the present invention provides a method, device, electronic device and storage medium for detecting anomalies of external devices.

[0006] In a first aspect, an embodiment of the present invention provides a method for detecting an abnormality of an external device, the method comprising:

[0007] Obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0008] Creating multiple peripheral driver modules based on multiple peripheral device types and multiple communication protocols; wherein each peripheral driver module includes a communication protocol and an external device type;

[0009] When the connection of the external device is detected, the device type of the external device is acquired, and a plurality of first target peripheral driver modules matching the device type are determined from a plurality of peripheral driver modules;

[0010] Sending heartbeat packets to multiple first target peripheral driver modules at regular intervals, so that each first target peripheral driver module converts the heartbeat packets into protocol heartbeat packets based on the communication protocol, and calls a thread from a thread pool to send the protocol heartbeat packets to an external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packets, and sends the protocol response heartbeat packets corresponding to the target protocol heartbeat packets to the second target peripheral driver module corresponding to the target protocol heartbeat packets;

[0011] Receive a response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

[0012] In a possible implementation, determining a plurality of first target peripheral driver modules matching the device type from a plurality of peripheral driver modules includes:

[0013] A peripheral driver module corresponding to an external device type matching the device type is determined from among a plurality of peripheral driver modules as a first target peripheral driver module.

[0014] In a possible implementation, the response heartbeat packet includes a peripheral abnormality bit of the external device;

[0015] Detect whether the external device is abnormal based on the response heartbeat packet, including:

[0016] Parse the response heartbeat packet to obtain the peripheral abnormal bit;

[0017] Determine whether the peripheral abnormal bit is a preset abnormal bit;

[0018] When it is determined that the abnormal bit of the peripheral device is the preset abnormal bit, detecting the abnormality of the external device;

[0019] When it is determined that the abnormal bit of the peripheral device is not the preset abnormal bit, it is detected that there is no abnormality in the external device.

[0020] In a possible implementation, each peripheral driver module further includes a peripheral exception handling mechanism, and the peripheral exception handling mechanism is a peripheral built-in exception handling mechanism, a communication mode exception handling mechanism, or a forced restart exception handling mechanism; the method further includes:

[0021] When an abnormality is detected in the external device, the external device is subjected to abnormality processing based on the external device abnormality processing mechanism included in the second target external device driver module.

[0022] In one possible implementation, the method further includes:

[0023] The timer is started regularly so that the timer polls to obtain the execution time of the threads in the execution state in the thread pool. When the execution time exceeds the preset time, the thread is restored from the execution state to the idle state.

[0024] In one possible implementation, the method further includes:

[0025] Broadcasting a network data packet, wherein the network data packet includes first information of the external device; wherein the first information at least includes: device type, peripheral name, communication mode, and number of abnormal events that occurred in history;

[0026] Establishing a communication connection with the operation interface device through a network data packet to display the first information on the operation interface of the operation interface device;

[0027] Receiving viewing information of an external device sent by an operation interface device;

[0028] Sending viewing information to the external device through the second target peripheral driver module, and receiving second information for viewing information sent by the external device through the second target peripheral driver module; wherein the second information at least includes: peripheral status, communication protocol and historical abnormal events;

[0029] The second information is sent to the operation interface device so that the second information is displayed on the operation interface.

[0030] In a possible implementation manner, the historical abnormal event is abnormal code data converted by the second target peripheral device driver module according to a preset format; the method further includes:

[0031] Save historical abnormal events to the target address.

[0032] In a second aspect, an embodiment of the present invention provides a device for detecting anomalies of an external device, the device comprising:

[0033] An acquisition module, used to acquire a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0034] A creation module, used to create multiple peripheral driver modules based on multiple peripheral device types and multiple communication protocols; wherein each peripheral driver module includes a communication protocol and an external device type;

[0035] an acquisition and determination module, configured to acquire the device type of the external device when the connection of the external device is detected, and determine a plurality of first target peripheral driver modules matching the device type from a plurality of peripheral driver modules;

[0036] A timing sending module is used to regularly send heartbeat packets to multiple first target peripheral driver modules, so that each first target peripheral driver module converts the heartbeat packet into a protocol heartbeat packet based on the communication protocol, and calls a thread from the thread pool to send the protocol heartbeat packet to an external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packet, and sends the protocol response heartbeat packet corresponding to the target protocol heartbeat packet to the second target peripheral driver module corresponding to the target protocol heartbeat packet;

[0037] The detection module is used to receive the response heartbeat packet converted by the second target peripheral device driver module to the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

[0038] In a third aspect, an embodiment of the present invention provides an electronic device, which includes: a processor and a memory, the processor is used to execute a program for external device abnormality detection stored in the memory to implement the above-mentioned external device abnormality detection method.

[0039] In a fourth aspect, an embodiment of the present invention provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned method for detecting anomalies of external devices.

[0040] The method, device, electronic device and storage medium for detecting anomalies of external devices provided by the embodiments of the present invention include: obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols; creating multiple external device driver modules based on the multiple external device types and multiple communication protocols; wherein each external device driver module includes a communication protocol and an external device type; when an external device connection is detected, obtaining the device type of the external device, and determining multiple first target external device driver modules matching the device type from the multiple external device driver modules; and timing the external device driver modules to connect to the external device. The heartbeat packet is sent to multiple first target peripheral driver modules, so that each first target peripheral driver module converts the heartbeat packet into a protocol heartbeat packet based on the communication protocol, and calls a thread from the thread pool to send the protocol heartbeat packet to the external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packet, and sends the protocol response heartbeat packet corresponding to the target protocol heartbeat packet to the second target peripheral driver module corresponding to the target protocol heartbeat packet; the response heartbeat packet converted from the protocol response heartbeat packet by the second target peripheral driver module is received, and whether the external device is abnormal is detected based on the response heartbeat packet. Each peripheral driver module created in the above technical solution can support the conversion of the heartbeat packet for detecting the abnormality of the external device into the protocol heartbeat packet corresponding to the included communication protocol and send it to the external device, so as to realize the abnormality detection of external devices with different communication protocols, and effectively alleviate the problem that the existing embedded devices cannot detect the abnormality of external devices with inconsistent communication protocols, which brings inconvenience to users in using embedded devices, thereby greatly improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A flowchart of an embodiment of a method for detecting anomalies of an external device provided by an embodiment of the present invention;

[0042] Figure 2 A flowchart of another method for detecting abnormality of an external device provided by an embodiment of the present invention;

[0043] Figure 3 A schematic diagram of a device communication connection framework provided by an embodiment of the present invention;

[0044] Figure 4 An example display diagram of a historical abnormal event provided by an embodiment of the present invention;

[0045] Figure 5 A block diagram of an embodiment of an apparatus for detecting abnormality of an external device provided by an embodiment of the present invention;

[0046] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0048] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.

[0049] The embodiment of the present invention provides a method for detecting anomalies of an external device, which is applied to a central processing unit (CPU) in an embedded device that can connect to an external device. The embedded device includes but is not limited to electronic devices such as televisions, refrigerators, pipeline machines, washing machines, etc. Figure 1 , Figure 1 A flow chart of an embodiment of a method for detecting anomalies of an external device provided in an embodiment of the present invention. Figure 1 The process shown may include the following steps:

[0050] Step 101, obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0051] The configuration file is a system file that has been configured before the embedded device leaves the factory, including which external devices the embedded device can support to connect to, and which communication protocols it can support. Generally, the external device types and communication protocols included in different configuration files of the embedded device are different. For example, if the embedded device is a TV, the external device types in the configuration file may include radar external device types, light sensor external device types, and camera external device types, and the communication protocols in the configuration file may include I2C (Inter-Integrated Circuit, serial peripheral interface), SPI (Serial Peripheral interface, serial peripheral interface), UART (Universal Asynchronous Receiver / Transmitter); and when the embedded device is a washing machine, the external device types in the configuration file may include temperature external device types and water level external device types, and the communication protocols in the configuration file may include USB (Universal Serial Bus, Universal Serial Bus), CAN (Controller Area Network). They are not listed one by one here.

[0052] Step 102, creating multiple peripheral driver modules based on multiple external device types and multiple communication protocols;

[0053] Each peripheral device driver module includes a communication protocol and an external device type, and is used to communicate with an external device of the external device type and the communication protocol. For ease of understanding, in this embodiment, the embedded device is taken as a television for example for explanation. Since the external device types included in the configuration file include radar external device type, light sensing external device type and camera external device type, and the communication protocols included are I2C, SPI, and UART, then 9 peripheral driver modules can be constructed according to the principle of one communication protocol and one external device type, namely, radar external device type-I2C peripheral driver module, radar external device type-SPI peripheral driver module, radar external device type-UART peripheral driver module, light sensing external device type-I2C peripheral driver module, light sensing external device type-SPI peripheral driver module, light sensing external device type-UART peripheral driver module, camera external device type-I2C peripheral driver module, camera external device type-SPI peripheral driver module, camera external device type-UART peripheral driver module, each peripheral driver module can support the embedded device to communicate with external devices of different external device types and different communication protocols.

[0054] Step 103, when it is detected that the external device is connected, the device type of the external device is obtained, and a plurality of first target peripheral driver modules matching the device type are determined from a plurality of peripheral driver modules;

[0055] Typically, the communication interfaces set for embedded devices of different external device types are different. Therefore, the device type of the external device can be determined through the communication interface to which the external device is connected, so as to determine the external device driver module that matches the external device, i.e., the first target peripheral driver module, from multiple peripheral driver modules.

[0056] The implementation process of determining multiple first target peripheral driver modules matching the device type from multiple peripheral driver modules in the above step 103 is: determining the peripheral driver module corresponding to the external device type matching the device type from the multiple peripheral driver modules as the first target peripheral driver module.

[0057] Continuing with the previous example, if the device type of the external device is a light-sensing device type, this matches the light-sensing external device types in the above-mentioned light-sensing external device type-I2C peripheral driver module, light-sensing external device type-SPI peripheral driver module, and light-sensing external device type-UART peripheral driver module. Therefore, the light-sensing external device type-I2C peripheral driver module, the light-sensing external device type-SPI peripheral driver module, and the light-sensing external device type-UART peripheral driver module are determined as the first target peripheral driver module.

[0058] Step 104, regularly sending the heartbeat packet to multiple first target peripheral driver modules, so that each first target peripheral driver module converts the heartbeat packet into a protocol heartbeat packet based on the communication protocol, and calls a thread from the thread pool to send the protocol heartbeat packet to an external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packet, and sends the protocol response heartbeat packet corresponding to the target protocol heartbeat packet to the second target peripheral driver module corresponding to the target protocol heartbeat packet;

[0059] A heartbeat packet can be a custom command character sent at a certain time interval and transmitted between two or more devices to notify each other of their status. The timing can be the time interval between two adjacent heartbeat packets set before the heartbeat packet generator is installed on the embedded device to ensure the normal operation of the heartbeat generator, or other time intervals, which are not limited here.

[0060] Since the embedded device cannot obtain the communication protocol supported by the external device, the heartbeat packet sent by the embedded device using its own communication protocol is sent to each first target peripheral driver module, so that each first target peripheral driver module uses the communication protocol it includes to convert the heartbeat packet into a protocol heartbeat packet consistent with the communication protocol in the first target peripheral driver module and send it to the external device.

[0061] In order to improve the data transmission speed, in this embodiment, the parallel sending of the protocol heartbeat packet is realized by threading, that is, each first target peripheral driver module respectively calls a thread from the thread pool to use the thread to realize the parallel sending of the protocol heartbeat packet to the external device.

[0062] After the external device receives multiple protocol heartbeat packets sent by each first target peripheral driver module, since the external device only supports one communication protocol, the external device can parse each protocol heartbeat packet to determine the target protocol heartbeat packet consistent with the communication protocol it supports, so as to send the protocol response heartbeat packet sent by the external device using its own communication protocol to the second target peripheral driver module consistent with its communication protocol.

[0063] Step 105 , receiving a response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detecting whether the external device is abnormal based on the response heartbeat packet.

[0064] In addition to being able to convert data sent by the embedded device using its own communication protocol into data of the communication protocol included in the peripheral driver module, the peripheral driver module also has the ability to convert data sent by the external device into data of its own communication protocol supported by the embedded device. In this embodiment, in order to enable the central processor of the embedded device to detect whether the external device is abnormal through the protocol response heartbeat packet fed back by the external device, after the external device sends the protocol response heartbeat packet to the second target peripheral driver module, the second target peripheral driver module converts the protocol response heartbeat packet into a response heartbeat packet of its own communication protocol supported by the embedded device, and the central processor of the embedded device can parse the response heartbeat packet to detect whether the external device is abnormal.

[0065] The method for detecting abnormalities of external devices provided by the embodiment of the present invention, each peripheral driver module created in the technical scheme can support the conversion of the heartbeat packet for detecting abnormalities of the external device into a protocol heartbeat packet corresponding to the included communication protocol and send it to the external device, thereby realizing abnormality detection of external devices with different communication protocols, and effectively alleviating the problem that the existing embedded devices cannot detect abnormalities of external devices with inconsistent communication protocols, which brings inconvenience to users in using embedded devices, thereby greatly improving the user experience.

[0066] As an optional implementation, as in the above method, step 105 of detecting whether the external device is abnormal based on the response heartbeat packet can be specifically implemented through steps A1 to A4:

[0067] Step A1, parsing the response heartbeat packet to obtain the peripheral abnormality bit;

[0068] In specific implementation, the response heartbeat packet includes a peripheral exception bit of the external device, and the peripheral exception bit (Peripheral Exception Vector) is an interrupt vector bit used to indicate whether the external device is abnormal. Therefore, in this embodiment, whether the external device is abnormal can be determined by obtaining the peripheral exception bit from the response heartbeat packet.

[0069] Step A2, determining whether the peripheral abnormality bit is a preset abnormality bit;

[0070] The preset abnormal bit is a preset abnormal bit corresponding to the abnormality of the external device. If the abnormal bit of the external device is determined to be the preset abnormal bit, it means that the external device is abnormal, and step A3 is executed; if the abnormal bit of the external device is determined not to be the preset abnormal bit, it means that the external device is not abnormal, and step A4 is executed.

[0071] Step A3, detecting an abnormality of an external device;

[0072] Step A4: Check if the external device is normal.

[0073] Through the method in this embodiment, whether the external device is abnormal is accurately determined by comparing the external device abnormal bit included in the response heartbeat packet with the preset abnormal bit, so as to realize abnormal detection of the external device.

[0074] When an abnormality occurs in various external devices, the embedded device may adopt a simple and crude processing method such as restarting the device or stopping the service to handle the abnormality of the external device, and it is impossible to adopt a corresponding processing method to handle the abnormality of the external device according to the actual situation of the external device. In this embodiment, each peripheral driver module also includes a peripheral exception handling mechanism, and the peripheral exception handling mechanism included in each peripheral driver module is to adopt a corresponding processing method according to the actual situation of the external device. For example, for an external device with an exception handling function (resetting the read-write buffer and re-communication handshake mechanism), the corresponding exception handling command can be directly sent to the external device to realize the abnormal handling of the external device, then the peripheral exception handling mechanism included in the peripheral driver module for the external device is the peripheral built-in exception handling mechanism; for an external device without an exception handling function, conventional communication methods such as I2C and SPI can send a string of low-level data (such as: 00000) to clear the data of the data communication nodes of both parties to realize the abnormal handling of the external device, then the peripheral exception handling mechanism included in the peripheral driver module for the external device is the communication mode exception handling mechanism. For external devices that are not in the above two situations, you can only power on the external device again (for example, pull down or raise the power-on GPIO bit again) and re-go through the initialization process to implement exception handling for the external device. Then the peripheral exception handling mechanism included in the peripheral driver module for the external device is a forced restart exception handling mechanism. Therefore, for different external devices, the peripheral exception handling mechanism included in the peripheral driver module is the peripheral's own exception handling mechanism, the communication method exception handling mechanism or the forced restart exception handling mechanism.

[0075] In summary, when an external device is detected to be abnormal, an external device abnormality is handled based on the external device abnormality handling mechanism included in the second target external device driver module. That is, the external device is handled accordingly using the external device built-in abnormality handling mechanism, the communication mode abnormality handling mechanism or the forced restart abnormality handling mechanism included in the second target external device driver module, so as to achieve abnormal recovery of the external device.

[0076] It can be seen from the above description that in order to improve the data transmission speed, in this embodiment, the thread method is used to implement the parallel transmission of the protocol heartbeat packet. However, in order to effectively avoid abnormal communication with external devices causing abnormal crash of the embedded device, in this embodiment, it is necessary to start the timer regularly so that the timer polls to obtain the execution time of the thread in the execution state in the thread pool, and when the execution time exceeds the preset time, the thread is restored from the execution state to the idle state. The embedded device uses a combination of thread pool and timer, which can effectively prevent the problem of device crash caused by long-term abnormal communication between the embedded device and the external device while improving the data transmission speed.

[0077] Usually, embedded devices can also be connected to an operation interface device with an operation interface, such as a computer, mobile phone, or tablet, so that the external device can be viewed through the operation interface device, which is convenient for technicians to understand the status of the external device in real time. For the specific process of network connection and external device viewing, please refer to Figure 2 , Figure 2 The process shown may include the following steps:

[0078] Step 201, broadcasting a network data packet, wherein the network data packet includes first information of an external device;

[0079] The network data packet includes the first information of the external device. It can be understood that the network data packet includes the first information of the external device currently connected to the embedded device. If the external devices currently connected to the embedded device are radar and camera, then this network data packet includes the first information of the radar and the first information of the camera. If the only external device currently connected to the embedded device is radar, then this network data packet only includes the first information of the radar, wherein the first information includes at least: device type, peripheral name, communication method and number of historical abnormal events.

[0080] Step 202, establishing a communication connection with an operation interface device through a network data packet, so as to display first information on an operation interface of the operation interface device;

[0081] Click to search for embedded devices from the operation interface of the operation interface device. At this time, the network data packets broadcast by the embedded device will be received and processed. After the network data packets are parsed successfully, all detected embedded devices will be displayed on the operation interface. When the user clicks to connect to an embedded device, a network connection will be established with the corresponding embedded device based on websocket (network socket). After the network connection is successful, the first information of all external devices of the corresponding embedded device will be displayed.

[0082] The above operation interface is based on the Semantic UI (Semantic User Interface) framework, which provides a set of user interface components that are easy to understand and use by using natural language principles. Responsibilities include searching for embedded devices, displaying a list of embedded devices, displaying information about external devices of embedded devices, and allowing users to view external devices of embedded devices through the operation interface.

[0083] In order to facilitate the understanding of the connection relationship between embedded devices, external devices, and operation interface devices, Figure 3 A schematic diagram of a device framework is shown, such as Figure 3As shown, the operation interface device 1 includes an operation interface 2, the operation interface device 1 is connected to the central processor 3 of the embedded device 2 based on websocket, the central processor 3 is connected to each peripheral driver, and each peripheral driver is connected to an external device of a device type matching the external device type. Figure 3 The figure shows peripheral driver A of light sensing external device type, I2C communication protocol, and peripheral driver B of radar external device type, SPI communication protocol, and communication mode exception handling mechanism. In the figure, peripheral driver A is connected to external device A which is a light sensing device, and peripheral driver B is connected to external device B which is a radar device.

[0084] Step 203, receiving the viewing information of the external device sent by the operation interface device;

[0085] After the network connection with the operation interface device is successful, the user enters the interface for viewing the peripheral information by clicking the peripheral name of the external device that the user wants to view, and the operation interface device will send the viewing information to the embedded device.

[0086] Step 204, sending the viewing information to the external device through the second target peripheral driver module, and receiving the second information for the viewing information sent by the external device through the second target peripheral driver module; wherein the second information at least includes: the state of the peripheral device, the communication protocol and the historical abnormal events;

[0087] A second target peripheral driver module consistent with the communication protocol of the external device is used to convert the viewing information into viewing information that can be recognized by the external device and send it to the external device. The external device sends second information corresponding to the viewing information to the second target peripheral driver module. The second target peripheral driver module converts the second information into second information that can be recognized by the embedded device and sends it to the central processing unit.

[0088] Step 205: Send the second information to the operation interface device to display the second information on the operation interface.

[0089] The above-mentioned historical abnormal events are specific abnormal data of the external device abnormality determined by abnormal detection of the external device through steps 101 to 105 in this embodiment. Usually, due to differences in error definitions among external devices of different manufacturers and types, it is difficult for embedded devices to form a unified standard when handling external device abnormalities. For example, some external devices may use specific error codes to indicate faults, while other external devices may use status registers to indicate faults. This inconsistent error definition method increases the complexity of fault diagnosis and processing of embedded devices.

[0090] In order to uniformly define errors and facilitate the clarification of abnormal problems of external devices, in the present embodiment, the above-mentioned historical abnormal events are abnormal code data converted by the second target peripheral driver module according to a preset format. Usually, in the case of an external device abnormality, the protocol response heartbeat packet sent by the external device includes abnormal data of the external device abnormality. After sending the protocol response heartbeat packet to the second target peripheral driver module, the second target peripheral driver module, in addition to converting the protocol response heartbeat packet into a response heartbeat packet that can be recognized by the embedded device, also needs to uniformly convert the abnormal data into abnormal code data according to the preset format.

[0091] The preset format may be a json (JavaScript Object Notation) data format, a java (Java programming language) data format, or an XML (Extensible Markup Language) data format, which is not limited here for ease of understanding. Figure 4 An example of a historical abnormal event is shown, and the historical abnormal event is represented in json data format.

[0092] In order to facilitate the subsequent analysis of abnormal conditions of external devices, in actual applications, it is necessary to save historical abnormal events to a target address, which is not limited to the local memory, hard disk, external storage, cloud, etc. of the embedded device. When it is necessary to perform abnormal analysis based on the historical abnormal events corresponding to the external device, it can be obtained from the target address.

[0093] See also Figure 5 , is a block diagram of an embodiment of an apparatus for detecting abnormalities of an external device provided by an embodiment of the present invention. Figure 5 As shown, the device comprises:

[0094] An acquisition module 501 is used to acquire a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0095] A creation module 502, used to create multiple peripheral device driver modules based on multiple peripheral device types and multiple communication protocols; wherein each peripheral device driver module includes a communication protocol and an external device type;

[0096] The acquisition and determination module 503 is used to acquire the device type of the external device when the connection of the external device is detected, and determine a plurality of first target peripheral driver modules matching the device type from a plurality of peripheral driver modules;

[0097] The timing sending module 504 is used to send the heartbeat packet to multiple first target peripheral driver modules at a regular time, so that each first target peripheral driver module converts the heartbeat packet into a protocol heartbeat packet based on the communication protocol, and calls a thread from the thread pool to send the protocol heartbeat packet to the external device, and the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packet, and sends the protocol response heartbeat packet corresponding to the target protocol heartbeat packet to the second target peripheral driver module corresponding to the target protocol heartbeat packet;

[0098] The detection module 505 is used to receive the response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

[0099] Specifically, the specific process of each module in the device of the embodiment of the present invention realizing its function can be referred to the relevant description in the method embodiment, which will not be repeated here.

[0100] The device for detecting abnormalities of external devices provided by the embodiment of the present invention, each peripheral driver module created in the technical solution can support the conversion of the heartbeat packet for detecting abnormalities of the external device into a protocol heartbeat packet corresponding to the included communication protocol and send it to the external device, thereby realizing abnormality detection of external devices with different communication protocols, effectively alleviating the problem that the existing embedded devices cannot detect abnormalities of external devices with inconsistent communication protocols, which brings inconvenience to users in using embedded devices, thereby greatly improving the user experience.

[0101] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, Figure 6 The electronic device 1200 shown includes: at least one processor 1201, a memory 1202, at least one network interface 1204 and other user interfaces 1203. The various components in the electronic device 1200 are coupled together via a bus system 1205. It is understood that the bus system 1205 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 1205 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 1205 is not described in detail. Figure 6 Various buses are labeled as bus system 1205.

[0102] The user interface 1203 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).

[0103] It can be understood that the memory 1202 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (DRRAM). The memory 1202 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0104] In some embodiments, the memory 1202 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 12021 and an application program 12022 .

[0105] The operating system 12021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 12022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 12022.

[0106] In the embodiment of the present invention, by calling the program or instruction stored in the memory 1202, specifically, the program or instruction stored in the application 12022, the processor 1201 is used to execute the method steps provided by each method embodiment, for example, including:

[0107] Obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0108] Creating multiple peripheral driver modules based on multiple peripheral device types and multiple communication protocols; wherein each peripheral driver module includes a communication protocol and an external device type;

[0109] When the connection of the external device is detected, the device type of the external device is acquired, and a plurality of first target peripheral driver modules matching the device type are determined from a plurality of peripheral driver modules;

[0110] Sending heartbeat packets to multiple first target peripheral driver modules at regular intervals, so that each first target peripheral driver module converts the heartbeat packets into protocol heartbeat packets based on the communication protocol, and calls a thread from a thread pool to send the protocol heartbeat packets to an external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packets, and sends the protocol response heartbeat packets corresponding to the target protocol heartbeat packets to the second target peripheral driver module corresponding to the target protocol heartbeat packets;

[0111] Receive a response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

[0112] In a possible implementation, determining a plurality of first target peripheral driver modules matching the device type from a plurality of peripheral driver modules includes:

[0113] A peripheral driver module corresponding to an external device type matching the device type is determined from among a plurality of peripheral driver modules as a first target peripheral driver module.

[0114] In a possible implementation, the response heartbeat packet includes a peripheral abnormality bit of the external device;

[0115] Detect whether the external device is abnormal based on the response heartbeat packet, including:

[0116] Parse the response heartbeat packet to obtain the peripheral abnormal bit;

[0117] Determine whether the peripheral abnormal bit is a preset abnormal bit;

[0118] When it is determined that the abnormal bit of the peripheral device is the preset abnormal bit, detecting the abnormality of the external device;

[0119] When it is determined that the abnormal bit of the peripheral device is not the preset abnormal bit, it is detected that there is no abnormality in the external device.

[0120] In a possible implementation, each peripheral driver module further includes a peripheral exception handling mechanism, and the peripheral exception handling mechanism is a peripheral built-in exception handling mechanism, a communication mode exception handling mechanism, or a forced restart exception handling mechanism; the method further includes:

[0121] When an abnormality is detected in the external device, the external device is subjected to abnormality processing based on the external device abnormality processing mechanism included in the second target external device driver module.

[0122] In one possible implementation, the method further includes:

[0123] The timer is started regularly so that the timer polls to obtain the execution time of the threads in the execution state in the thread pool. When the execution time exceeds the preset time, the thread is restored from the execution state to the idle state.

[0124] In one possible implementation, the method further includes:

[0125] Broadcasting a network data packet, wherein the network data packet includes first information of the external device; wherein the first information at least includes: device type, peripheral name, communication mode, and number of abnormal events that occurred in history;

[0126] Establishing a communication connection with the operation interface device through a network data packet to display the first information on the operation interface of the operation interface device;

[0127] Receiving viewing information of an external device sent by an operation interface device;

[0128] Sending viewing information to the external device through the second target peripheral driver module, and receiving second information for viewing information sent by the external device through the second target peripheral driver module; wherein the second information at least includes: peripheral status, communication protocol and historical abnormal events;

[0129] The second information is sent to the operation interface device so that the second information is displayed on the operation interface.

[0130] In a possible implementation manner, the historical abnormal event is abnormal code data converted by the second target peripheral device driver module according to a preset format; the method further includes:

[0131] Save historical abnormal events to the target address.

[0132] The method disclosed in the above embodiment of the present invention can be applied to the processor 1201, or implemented by the processor 1201. The processor 1201 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 1201. The above processor 1201 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 1202, and the processor 1201 reads the information in the memory 1202 and completes the steps of the above method in combination with its hardware.

[0133] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.

[0134] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0135] The electronic device provided in this embodiment may be Figure 6 The electronic device shown in FIG. 1 may perform the following steps: Figure 1-2 All steps of the method for detecting abnormalities of external devices in the Figure 1-2 For details, please refer to the technical effect of the method for detecting abnormalities in external devices shown in Figure 1-2 For the sake of brevity, the relevant description is not repeated here.

[0136] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.

[0137] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned method for detecting abnormalities of external devices can be implemented.

[0138] The processor is used to execute the program for detecting an abnormality of an external device stored in the memory to implement the following steps of the method for detecting an abnormality of an external device:

[0139] Obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols;

[0140] Creating multiple peripheral driver modules based on multiple peripheral device types and multiple communication protocols; wherein each peripheral driver module includes a communication protocol and an external device type;

[0141] When the connection of the external device is detected, the device type of the external device is acquired, and a plurality of first target peripheral driver modules matching the device type are determined from a plurality of peripheral driver modules;

[0142] Sending heartbeat packets to multiple first target peripheral driver modules at regular intervals, so that each first target peripheral driver module converts the heartbeat packets into protocol heartbeat packets based on the communication protocol, and calls a thread from a thread pool to send the protocol heartbeat packets to an external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packets, and sends the protocol response heartbeat packets corresponding to the target protocol heartbeat packets to the second target peripheral driver module corresponding to the target protocol heartbeat packets;

[0143] Receive a response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

[0144] In a possible implementation, determining a plurality of first target peripheral driver modules matching the device type from a plurality of peripheral driver modules includes:

[0145] A peripheral driver module corresponding to an external device type matching the device type is determined from among a plurality of peripheral driver modules as a first target peripheral driver module.

[0146] In a possible implementation, the response heartbeat packet includes a peripheral abnormality bit of the external device;

[0147] Detect whether the external device is abnormal based on the response heartbeat packet, including:

[0148] Parse the response heartbeat packet to obtain the peripheral abnormal bit;

[0149] Determine whether the peripheral abnormal bit is a preset abnormal bit;

[0150] When it is determined that the abnormal bit of the peripheral device is the preset abnormal bit, detecting the abnormality of the external device;

[0151] When it is determined that the abnormal bit of the peripheral device is not the preset abnormal bit, it is detected that there is no abnormality in the external device.

[0152] In a possible implementation, each peripheral driver module further includes a peripheral exception handling mechanism, and the peripheral exception handling mechanism is a peripheral built-in exception handling mechanism, a communication mode exception handling mechanism, or a forced restart exception handling mechanism; the method further includes:

[0153] When an abnormality is detected in the external device, the external device is subjected to abnormality processing based on the external device abnormality processing mechanism included in the second target external device driver module.

[0154] In one possible implementation, the method further includes:

[0155] The timer is started regularly so that the timer polls to obtain the execution time of the threads in the execution state in the thread pool. When the execution time exceeds the preset time, the thread is restored from the execution state to the idle state.

[0156] In one possible implementation, the method further includes:

[0157] Broadcasting a network data packet, wherein the network data packet includes first information of the external device; wherein the first information at least includes: device type, peripheral name, communication mode, and number of abnormal events that occurred in history;

[0158] Establishing a communication connection with the operation interface device through a network data packet to display the first information on the operation interface of the operation interface device;

[0159] Receiving viewing information of an external device sent by an operation interface device;

[0160] Sending viewing information to the external device through the second target peripheral driver module, and receiving second information for viewing information sent by the external device through the second target peripheral driver module; wherein the second information at least includes: peripheral status, communication protocol and historical abnormal events;

[0161] The second information is sent to the operation interface device so that the second information is displayed on the operation interface.

[0162] In a possible implementation manner, the historical abnormal event is abnormal code data converted by the second target peripheral device driver module according to a preset format; the method further includes:

[0163] Save historical abnormal events to the target address.

[0164] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0165] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0166] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for detecting anomalies of an external device, characterized in that: The method comprises: Obtaining a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols; Creating a plurality of peripheral device driver modules based on a plurality of the external device types and a plurality of the communication protocols; wherein each of the peripheral device driver modules includes one of the communication protocols and one of the external device types; When the connection of the external device is detected, the device type of the external device is acquired, and a plurality of first target peripheral driver modules matching the device type are determined from the plurality of peripheral driver modules; Sending heartbeat packets to multiple first target peripheral driver modules at regular intervals, so that each of the first target peripheral driver modules converts the heartbeat packets into protocol heartbeat packets based on the communication protocol, and calls a thread from a thread pool to send the protocol heartbeat packets to the external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packets, and sends the protocol response heartbeat packets corresponding to the target protocol heartbeat packets to the second target peripheral driver module corresponding to the target protocol heartbeat packets; Receive a response heartbeat packet converted by the second target peripheral device driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

2. The method according to claim 1, characterized in that The step of determining a plurality of first target peripheral device driver modules matching the device type from the plurality of peripheral device driver modules comprises: A peripheral device driver module corresponding to the external device type matching the device type is determined from the plurality of peripheral device driver modules as a first target peripheral device driver module.

3. The method according to claim 1, characterized in that The response heartbeat packet includes the peripheral abnormality bit of the external device; The detecting whether the external device is abnormal based on the response heartbeat packet includes: Parsing the response heartbeat packet to obtain the peripheral abnormality bit; Determining whether the peripheral abnormality bit is a preset abnormality bit; In the case where it is determined that the external device abnormality bit is a preset abnormality bit, detecting an abnormality of the external device; When it is determined that the external device abnormality bit is not a preset abnormality bit, it is detected that there is no abnormality in the external device.

4. The method according to claim 3, characterized in that Each of the peripheral driver modules also includes a peripheral exception handling mechanism, and the peripheral exception handling mechanism is a peripheral built-in exception handling mechanism, a communication mode exception handling mechanism, or a forced restart exception handling mechanism; the method also includes: When an abnormality is detected in the external device, an abnormality process is performed on the external device based on the external device abnormality process mechanism included in the second target external device driver module.

5. The method according to claim 1, characterized in that The method further comprises: The timer is started regularly so that the timer polls to obtain the execution time of the threads in the execution state in the thread pool, and when the execution time exceeds a preset time, the thread is restored from the execution state to the idle state.

6. The method according to claim 1, characterized in that The method further comprises: Broadcasting a network data packet, wherein the network data packet includes first information of the external device; wherein the first information at least includes: the device type, the name of the external device, the communication method, and the number of abnormal events that occurred in the past; Establishing a communication connection with an operation interface device through the network data packet to display the first information on an operation interface of the operation interface device; Receiving viewing information of the external device sent by the operation interface device; Sending the viewing information to the external device through the second target peripheral driver module, and receiving second information sent by the external device for the viewing information through the second target peripheral driver module; wherein the second information at least includes: peripheral status, communication protocol and historical abnormal events; The second information is sent to the operation interface device so as to display the second information on the operation interface.

7. The method according to claim 6, characterized in that The historical abnormal event is abnormal code data converted by the second target peripheral device driver module according to a preset format; The method further comprises: The historical abnormal events are saved to a target address.

8. A device for detecting abnormality of an external device, characterized in that: The device comprises: An acquisition module, used to acquire a configuration file, wherein the configuration file includes multiple external device types and multiple communication protocols; A creation module, used to create multiple peripheral driver modules based on multiple external device types and multiple communication protocols; wherein each of the external driver modules includes one communication protocol and one external device type; an acquisition and determination module, configured to acquire the device type of the external device when the connection of the external device is detected, and determine a plurality of first target peripheral driver modules matching the device type from the plurality of peripheral driver modules; A timing sending module, used for regularly sending heartbeat packets to multiple first target peripheral driver modules, so that each of the first target peripheral driver modules converts the heartbeat packets into protocol heartbeat packets based on the communication protocol, and calls a thread from a thread pool to send the protocol heartbeat packets to the external device, the external device parses the multiple protocol heartbeat packets to identify the target protocol heartbeat packets, and sends the protocol response heartbeat packet corresponding to the target protocol heartbeat packet to the second target peripheral driver module corresponding to the target protocol heartbeat packet; The detection module is used to receive the response heartbeat packet converted by the second target peripheral driver module from the protocol response heartbeat packet, and detect whether the external device is abnormal based on the response heartbeat packet.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a program for detecting an abnormality of an external device stored in the memory, so as to implement the method for detecting an abnormality of an external device according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method for detecting anomalies of an external device according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and system supporting access of sensors of different types

    CN104010005A

  • Abnormity monitoring method and device for vehicle CAN bus and computer equipment

    CN110191018A

  • Monitoring system and method for abnormal data of industrial equipment

    CN112578756A

  • Abnormality detection method, device and equipment for RS485 bus and storage medium

    CN115622767A

  • Detection of shared memory faults in a computing job

    US20210216387A1