Disclosure of Invention
The present application provides a method, an apparatus, a system, a medium, and an electronic device for processing an interface jitter state, which are used to interrupt a currently executed program when a level state of an interface changes, wait for the level state to be stable, and then obtain the level state of the interface again as a latest level state, and during the waiting period, continue to run other programs without affecting the overall execution efficiency of the program.
In order to solve the above technical problem, the present application provides a method for processing an interface jitter state, which is applied to an electronic device, and includes:
scanning the level state of each interface;
when the level state changes, starting a hardware timer to interrupt a target program currently executed by a target interface and executing other programs except the target program; wherein the target program is a program that operates based on a level state of the target interface;
and when the hardware timer finishes timing, acquiring the latest level state of the target interface as the running parameter of the target program.
Preferably, after starting the hardware timer to interrupt the target program currently executed by the target interface when the level state changes, the method further includes:
acquiring an initial level state of the target interface;
judging whether the initial level state is different from the latest level state or not;
and if so, correspondingly writing the interface number of the target interface, the initial level state and the latest level state into an abnormal log.
Preferably, the scanning between the level states of the interfaces further comprises:
initializing the interface and the hardware timer.
Preferably, the timing duration of the hardware timer is 10 ms.
Preferably, the method further comprises the following steps:
judging whether the time for scanning the level state of each interface is greater than preset time;
if so, generating scanning exception information.
In order to solve the above technical problem, the present application further provides a method for processing an interface jitter state, which is applied to a hardware timer, and includes:
receiving a starting command of the electronic equipment;
interrupting a target program currently executed by a target interface to enable the electronic equipment to run other programs except the target program, and acquiring the latest level state of the target interface as an operating parameter of the target program when timing is finished; wherein the target program is a program that operates based on a level state of the target interface.
In order to solve the above technical problem, the present application further provides a device for processing an interface jitter state, which is applied to an electronic device, and includes:
the scanning module is used for scanning the level state of each interface;
the starting module is used for starting a hardware timer to interrupt a target program currently executed by a target interface and execute other programs except the target program when the level state changes, wherein the target program is a program operated based on the level state of the target interface;
and the acquisition module is used for acquiring the latest level state of the target interface as the running parameter of the target program when the hardware timer finishes timing.
Preferably, the method further comprises the following steps:
an initial level state obtaining module, configured to obtain an initial level state of the target interface;
the first judging module is used for judging whether the initial level state is different from the latest level state;
and the writing module is used for correspondingly writing the interface number of the target interface, the initial level state and the latest level state into an abnormal log when the judgment result of the first judgment module is yes.
As a preferred embodiment, the apparatus further comprises:
the second judgment module is used for judging whether the time for scanning the level state of each interface is greater than the preset time;
and the generating module is used for generating scanning abnormal information when the judgment result of the second judging module is yes.
In order to solve the above technical problem, the present application further provides an electronic device, where the electronic device stores a computer program; and for implementing the steps of the processing method of the interface jitter status as described when executing said computer program.
In order to solve the above technical problem, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the method for processing the interface jitter state.
In order to solve the above technical problem, the present application further provides a system for processing an interface jitter state, including:
the electronic equipment is used for scanning the level state of each interface, starting a hardware timer to interrupt a target program currently executed by a target interface and execute other programs except the target program when the level state changes, and acquiring the latest level state of the target interface as an operating parameter of the target program when the hardware timer finishes timing; wherein the target program is a program that operates based on a level state of the target interface;
and the hardware timer is used for interrupting the target program and timing.
The application provides a method for processing an interface jitter state, which comprises the following steps: the level state of each interface is scanned, when the level state of one interface changes, a hardware timer is started to interrupt the currently executed target program, and other programs can be executed during the timing period of the hardware timer. The target program is a program which runs based on the level state of the target interface. And when the hardware timer finishes timing, the level state of the target interface is stable, and the latest level state of the target interface is acquired as the running parameter of the target program. According to the method and the device, when the level state of the target interface changes, the jitter of the interface is eliminated through the delay of the hardware timer, and other programs can still be continuously executed after the current target program is interrupted through the hardware timer in the period, so that the overall execution efficiency of the program can be improved, and the defect of low execution efficiency caused by the method for eliminating the jitter by waiting for the delay in the prior art is overcome.
In addition, the processing device, the system, the medium and the electronic equipment for the interface jitter state provided by the application correspond to the method, and the effect is the same.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the present application.
The core of the application is to provide a method, a device, a system and a medium for processing an interface jitter state, which are used for interrupting a currently executed program when the level state of an interface changes, waiting for the level state to be stable, acquiring the level state of the interface again as a latest level state, and continuously running other programs during the waiting period without affecting the overall execution efficiency of the program.
In order that those skilled in the art will better understand the disclosure, the following detailed description will be given with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for processing an interface jitter state according to an embodiment of the present disclosure. The method is applied to an electronic device, as shown in fig. 1, and comprises the following steps:
s10: the level states of the interfaces are scanned.
In this embodiment, the application range of the electronic device is not limited, and the electronic device may be an electronic device on any hardware device, and the model and the executed program of the electronic device are not limited. The interface mentioned in this embodiment may be a GPIO (general purpose input output) interface, and the specific type and number are not limited. In general, there are multiple GPIO interfaces of a hardware device, and an electronic device scans the level state of each interface to obtain the current state of each interface. Typically, each interface is numbered and the electronic device cyclically scans the interfaces according to the numbers. It is to be understood that the scanning period is not limited, and is set according to actual conditions.
As a preferred embodiment, before S10, an initialization interface and a hardware timer are further included. The data of each interface and the hardware timer can be cleared through initialization, and the reliability of the scanned level state is guaranteed.
S11: when the level state changes, starting a hardware timer to interrupt a target program currently executed by a target interface and executing other programs except the target program; the target program is a program which runs based on the level state of the target interface.
In order to implement a specific function, the electronic device needs to run a corresponding program, and as the program runs, the level state of an interface may change, for example, in the last scanning cycle, the level state of a certain interface is 0, and then in the next scanning cycle, the level state of the interface may become 1, that is, the level state of the interface changes. As mentioned in the background, if the level state of the interface is jittered, the result may be wrong if the current level state is considered to be the true level state of the interface when the level state of the interface is determined to have changed. Therefore, in this embodiment, when the level state is detected to change, a hardware timer is started, and the function of the hardware timer is to interrupt the current target program of the target interface (the interface with the changed level), but for the electronic device, it is still necessary to execute other programs except the target program, that is, programs corresponding to other interfaces except the target interface. For example, there are 5 interfaces, interface 1, interface 2, interface 3, interface 4, and interface 5. In the scanning process, the level states of other interfaces except the interface 2 are not changed, and then the current level state of the interface 2 is 0, but in order to overcome the jitter, 0 is not directly used as the latest level state of the interface 2, but the target program corresponding to the interface 2 is interrupted by a hardware timer, but the other programs are continuously executed.
TABLE 1
S12: and when the hardware timer finishes timing, acquiring the latest level state of the target interface as an operating parameter of the target program.
After a preset time, that is, when the hardware timer ends, the level state of the target interface, that is, the interface 2, is obtained again, and the obtained level state is regarded as the latest level state. And if the latest level state is different from the initial level state, the change of the level state of the interface is considered to be effective, otherwise, the change of the level state of the interface is not effective. In order to facilitate subsequent viewing, the number, the latest level state and the like of the target interface can be recorded. It will be appreciated that the latest level state of the target interface is obtained at this time, so it is necessary to resume execution of the target program and take the latest level state as an operating parameter of the target program.
It should be noted that the timing time of the hardware timer may be determined according to the type of the interface, for example, if the interface jitter lasts for a longer time, the timing time may be increased appropriately, and conversely, the timing time may be decreased appropriately, and in a preferred embodiment, the timing duration of the hardware timer is 10 ms. If the timing duration is 10ms, the time for the target program to be interrupted is 10ms, and after 10ms, the target program resumes to run.
The method for processing the interface jitter state provided by the embodiment comprises the following steps: the level state of each interface is scanned, when the level state of one interface changes, a hardware timer is started to interrupt the currently executed target program, and other programs can be executed during the timing period of the hardware timer. The target program is a program which runs based on the level state of the target interface. And when the hardware timer finishes timing, the level state of the target interface is stable, and the latest level state of the target interface is acquired as the running parameter of the target program. According to the method and the device, when the level state of the target interface changes, the jitter of the interface is eliminated through the delay of the hardware timer, and other programs can still be continuously executed after the current target program is interrupted through the hardware timer in the period, so that the overall execution efficiency of the program can be improved, and the defect of low execution efficiency caused by the method for eliminating the jitter by waiting for the delay in the prior art is overcome.
Fig. 2 is a flowchart of another interface jitter status processing method according to an embodiment of the present application. Wherein, S10-S12 are the same as those in fig. 1, and are not described again in this embodiment. As shown in fig. 2, on the basis of the previous embodiment, the method further includes:
s20: and acquiring the initial level state of the target interface.
It will be appreciated that the initial level state is the level state at which a change in the level state of the target interface is determined as opposed to the most recent level state, which is the result of a scan on the current interface.
S21: it is determined whether the initial level state is different from the latest level state, and if so, the process proceeds to S22.
If the initial level state is the same as the latest level state, the level state change of the target interface is valid, and if the initial level state is not the same as the latest level state, the level state change of the target interface is invalid.
S22: and correspondingly writing the interface number, the initial level state and the latest level state of the target interface into an exception log.
In this step, the initial level state and the latest level state are different, and therefore, the initial level state and the latest level state are invalid changes, and in order to facilitate subsequent viewing, in this embodiment, the related information of the target interface is recorded. It is understood that, besides the interface number, the initial level state and the latest level state of the target interface, the time for determining the initial level state and the time for determining the latest level state may be recorded, so as to make a data reference for setting the timing duration of the hardware timer.
In another embodiment, further comprising:
judging whether the time for scanning the level state of each interface is greater than preset time;
if so, generating scanning exception information.
In a specific implementation, the time for scanning each interface is usually fixed, and since the scanning process is a cyclic scanning, if a fault occurs while scanning a certain interface, subsequent other interfaces cannot be scanned, which affects the processing speed or even goes down. In this embodiment, the time for scanning each interface is recorded, and if the time is greater than a predetermined time, it is determined that the scanning is abnormal. It is understood that the predetermined time herein can be determined according to actual conditions, and the embodiment is not limited.
In the foregoing embodiment, an embodiment of a method for processing an interface jitter state is described in detail from the perspective of an electronic device, and the present application also provides an embodiment corresponding to a hardware timer. Fig. 3 is a flowchart of another interface jitter status processing method according to an embodiment of the present application. The method is applied to a hardware timer, as shown in fig. 3, and includes:
s30: and receiving a starting command of the electronic equipment.
S31: interrupting a target program currently executed by a target interface to enable the electronic equipment to run other programs except the target program, and acquiring the latest level state of the target interface as a running parameter of the target program when timing is finished; the target program is a program which works based on the level state of the target interface.
In the above embodiments, the operation of the hardware timer is also described, so that the description of this embodiment is omitted. In a specific implementation, the start command may include interface information of the target interface, such as an interface number, so that the hardware timer can determine the interface to be interrupted, i.e., the target interface, according to the start command.
In the foregoing embodiments, a detailed description is given of a processing method of an interface jitter state, and the present application also provides an embodiment corresponding to a processing apparatus of an interface jitter state. It should be noted that the present application describes embodiments of the apparatus portion based on the angle of the functional module.
Fig. 4 is a structural diagram of a processing apparatus for processing an interface jitter state according to an embodiment of the present application. As shown in fig. 4, the apparatus is applied to an electronic device, and includes:
the scanning module 10 is used for scanning the level state of each interface;
the starting module 11 is configured to, when the level state changes, start a hardware timer to interrupt a target program currently executed by a target interface and execute other programs except the target program, where the target program is a program that runs based on the level state of the target interface;
and the obtaining module 12 is configured to obtain, when the hardware timer finishes counting, the latest level state of the target interface as an operation parameter of the target program.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here.
As a preferred embodiment, the apparatus further comprises:
an initial level state obtaining module, configured to obtain an initial level state of the target interface;
the first judging module is used for judging whether the initial level state is different from the latest level state;
and the writing module is used for correspondingly writing the interface number of the target interface, the initial level state and the latest level state into an abnormal log when the judgment result of the first judgment module is yes.
As a preferred embodiment, the apparatus further comprises:
the second judgment module is used for judging whether the time for scanning the level state of each interface is greater than the preset time;
and the generating module is used for generating scanning abnormal information when the judgment result of the second judging module is yes.
The processing device for interface jitter state provided by the embodiment comprises a scanning module, a starting module and an obtaining module, wherein when the level state of a target interface changes, the jitter of the interface is eliminated through the delay of a hardware timer, and during the period, other programs can still be continuously executed after the current target program is interrupted by the hardware timer, so that the overall execution efficiency of the program can be improved, and the defect of low execution efficiency caused by the method for eliminating the jitter by waiting for the delay in the prior art is overcome.
Fig. 5 is a structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 5, the processor stores a computer program, and is configured to implement the steps of the processing method such as the interface jitter state when executing the computer program.
Specifically, the electronic device includes a memory 50 for storing a computer program;
the processor 51 is configured to implement the steps of the processing method for the interface jitter status according to the above embodiment when executing the computer program.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here. In some embodiments of the present application, the processor 51 and the memory 50 may be connected by a bus or other means.
The processor 51 may include one or more processing cores, such as a 5-core processor, an 8-core processor, and the like. The processor 51 may be implemented in at least one hardware form of the family of 51 single-chip computers. The processor 51 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a CPU (Central Processing Unit); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 51 may be integrated with a GPU (Graphics processing unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 51 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 50 may include one or more computer-readable storage media, which may be non-transitory. Memory 50 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 50 is at least used for storing the following computer program 501, wherein after being loaded and executed by the processor 51, the computer program can implement relevant steps in the processing method for interface jitter status disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 50 may also include an operating system 502, data 503, and the like, and the storage manner may be a transient storage manner or a permanent storage manner. Operating system 502 may be Windows, among others. Data 503 may include, but is not limited to, data involved in the above-described methods.
In some embodiments, the interface jitter status processing device may further include a display 52, an input/output interface 53, a communication interface 54, a power supply 55, and a communication bus 56.
It will be appreciated by those skilled in the art that the arrangement shown in figure 5 does not constitute a limitation of the processing means of the interface jitter status and may comprise more or less components than those shown.
The electronic device provided by the embodiment of the application can realize the processing method for acquiring the interface jitter state when executing the program stored in the memory, and the effect is the same as that of the processing method.
Further, the present application also provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the method for processing the interface jitter state provided in any of the above embodiments.
It is to be understood that if the method in the above embodiments is implemented in the form of software functional units and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium and executes all or part of the steps of the methods described in the embodiments of the present application, or all or part of the technical solutions. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The computer program contained in the computer-readable storage medium provided in this embodiment can implement the steps of the method for processing the interface jitter state as described above when being executed by the processor, and the effects are the same as above.
Fig. 6 is a flowchart of another processing method applied to an interface jitter state of an electronic device according to an embodiment of the present disclosure. The electronic device mainly comprises a central processing unit and a hardware timer, and in the flow chart, the interaction between the central processing unit and the hardware timer is illustrated. As shown in fig. 6, the method includes:
s40: the central processing unit scans the level state of each interface.
S41: when the level state changes, a start command is sent to the hardware timer.
S42: the central processing unit executes other programs except the target program; the target program is a program which runs based on the level state of the target interface.
S43: the hardware timer interrupts the target program and times.
S44: when the timing is finished, the central processing unit acquires the latest level state of the target interface as the operating parameter of the target program.
Since the embodiments of the cpu and the hardware timer are described in detail above, the detailed description of the embodiments is omitted here.
In the method for processing the interface jitter state provided by this embodiment, when the level state of the target interface changes, the hardware timer delays to eliminate the jitter of the interface, and during this period, the hardware timer interrupts the current target program and then can continue to execute other programs, so that the overall execution efficiency of the program can be improved, and the defect of low execution efficiency caused by the method for eliminating the jitter by waiting for the delay in the prior art is overcome.
Finally, the present application further provides a system for processing an interface jitter state, including:
the electronic equipment is used for scanning the level state of each interface, starting the hardware timer to interrupt the target program currently executed by the target interface and execute other programs except the target program when the level state changes, and acquiring the latest level state of the target interface as the running parameter of the target program when the hardware timer finishes timing; the target program is a program which runs based on the level state of the target interface;
and the hardware timer is used for interrupting the target program and timing.
In the processing system for interface jitter status provided by this embodiment, when the level status of the target interface changes, the hardware timer delays to eliminate the jitter of the interface, and during this period, the hardware timer interrupts the current target program and then can continue to execute other programs, so that the overall execution efficiency of the program can be improved, and the disadvantage of low execution efficiency caused by the method for eliminating the jitter by waiting for the delay in the prior art is overcome.
The method, apparatus, system, medium, and electronic device for processing the interface jitter state provided in the present application are described in detail above. The embodiments are described in a progressive mode in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.