Disclosure of Invention
The invention provides a communication data checking processing method, a system, equipment and a medium, aiming at overcoming the defect that the equipment works abnormally due to the fact that error data cannot be avoided in the prior art.
The invention solves the technical problems through the following technical scheme:
the first aspect provides a communication data verification processing method, which is applied to communication interaction between a control board and a power board of intelligent equipment, and the verification processing method comprises the following steps:
presetting logic check rules corresponding to different types of communication data;
acquiring actual communication data sent by the control panel;
based on the data type of the actual communication data, adopting the logic verification rule to perform logic verification on the actual communication data;
if the logic verification is passed, supplying power to the load of the intelligent equipment based on the actual communication data according to the power panel;
and if the logic check fails, discarding the actual communication data.
Preferably, the logic verification of the actual communication data by using the logic verification rule includes:
determining the data type corresponding to the actual communication data;
judging whether the actual communication data is in a preset logic check threshold range corresponding to the data type;
if yes, the logical check is determined to be passed.
Preferably, the communication data is a data set, and the data set includes working state mode parameters corresponding to the intelligent device, and working temperature parameters and/or working time parameters;
the logic verification is carried out on the actual communication data by adopting the logic verification rule, and the steps comprise:
judging whether the intelligent equipment has a mode number matched with the working state mode parameter in the actual communication data;
if yes, acquiring a working temperature threshold and/or a working time threshold corresponding to the mode number;
judging whether the working temperature parameter is within the working temperature threshold value and/or whether the working time parameter is within the working time threshold value;
and if the working temperature parameter meets the corresponding working temperature threshold value and/or the working time parameter meets the working time threshold value, the logic check is passed.
Preferably, the logic verification of the actual communication data by using the logic verification rule further includes:
judging whether the intelligent equipment is in a working state or not;
if yes, carrying out logic check on the actual communication data;
if not, determining that the logic verification is not carried out on the actual communication data.
Preferably, the step of acquiring the actual communication data sent by the control board includes:
continuously receiving communication data sent by the control panel, and judging whether the received communication data meets a frame of complete data;
if yes, carrying out data verification on the communication data;
and if the data passes the verification, assigning the communication data to the power panel.
Preferably, the data Check adopts CRC (Cyclic Redundancy Check) data Check, and includes:
calculating the CRC value of the communication data according to a CRC protocol;
judging whether the CRC value is equal to a CRC value received in communication;
if yes, the data of the communication data is verified to be qualified.
Preferably, the data verification further comprises:
if the CRC value is not equal to a CRC value received in communication, judging whether the data checking times exceed a preset time threshold value;
if so, the data verification result of the communication data is wrong;
if not, returning to the step of calculating the CRC value of the current data according to the CRC protocol.
Preferably, the communication interaction process between the control board and the power board corresponds to the operation process of a data receiving interrupt program and the operation process of a main program, and the execution priority of the operation process of the data receiving interrupt program is higher than that of the main program;
and the running process of the data receiving interrupt program and the running process of the main program respectively adopt different logic verification rules to verify the communication data.
The second aspect provides a communication data's check-up processing system, is applied to in the communication interaction between the control panel of smart machine and the power strip, check-up processing system includes:
the logic check rule module is used for presetting logic check rules corresponding to different types of communication data;
the acquisition module is used for acquiring actual communication data sent by the control panel;
the logic verification module is used for performing logic verification on the actual communication data by adopting the logic verification rule based on the data type of the actual communication data;
and the processing module is used for controlling the power panel to supply power to the load of the intelligent equipment based on the actual communication data passing the logic verification or discarding the actual communication data not passing the logic verification.
Preferably, the logic check module comprises a data type unit and a threshold detection unit;
the data type unit is used for determining the data type corresponding to the communication data;
the threshold detection unit is used for determining whether the actual communication data corresponding to the data type is within a preset logic check threshold range.
Preferably, the communication data is a data set, and the data set includes working state mode parameters corresponding to the intelligent device, and working temperature parameters and/or working time parameters;
the logic checking module comprises a data type unit, a mode matching unit and a threshold value detection unit;
the pattern matching unit is used for judging whether a pattern number matched with the working state pattern parameters in the actual communication data exists in the intelligent equipment;
the data type unit is used for determining whether the data set comprises working temperature parameters and/or working time data;
the threshold detection unit is used for acquiring a working temperature threshold and/or a working time threshold corresponding to the mode number, and judging whether the working temperature parameter is within the working temperature threshold and/or whether the working time parameter is within the working time threshold;
the processing module is further configured to discard actual communication data that is not matched with the mode number, or the working temperature parameter does not satisfy the corresponding working temperature threshold, and/or the working time parameter does not satisfy the working time threshold.
A third aspect provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for verifying and processing the communication data when executing the computer program.
A fourth aspect provides a computer storage medium having a computer program stored thereon, the computer program, when executed by a processor, implementing the method of verifying communication data as described above.
The positive progress effects of the invention are as follows: through the logic verification of the communication data, the communication data with errors is found in time, particularly the communication data with correct data verification and logic errors which do not meet the design requirements of the intelligent equipment, the wrong communication data is directly discarded, and the data with correct data verification in the previous frame is used, so that the abnormal operation of the intelligent equipment caused by the wrong data can be effectively avoided.
Detailed Description
The invention is further illustrated by the following examples, which are not intended to limit the scope of the invention.
Example 1
The present embodiment provides a method for verifying and processing communication data, as shown in fig. 1, and is applied to communication interaction between a control board and a power board of an intelligent device, where the method for verifying and processing communication data includes:
s101, presetting logic check rules corresponding to different types of communication data;
s102, acquiring actual communication data sent by the control panel;
s103, based on the data type of the actual communication data, carrying out logic verification on the actual communication data by adopting the logic verification rule;
s104, if the logic verification is passed, supplying power to the load of the intelligent equipment based on the actual communication data according to the power panel;
and S105, if the logic verification is not passed, discarding the actual communication data.
As an implementation manner, in step S103, the logic verification is performed on the actual communication data by using the logic verification rule, and the steps include:
determining the data type corresponding to the actual communication data;
judging whether the actual communication data is in a preset logic check threshold range corresponding to the data type;
if yes, the logic check is determined to be passed.
As an achievable way, the communication data is a data set, and the data set includes a working state mode parameter corresponding to the intelligent device, and a working temperature parameter and/or a working time parameter;
in step S103, performing logic verification on the actual communication data by using the logic verification rule, including:
judging whether the intelligent equipment has a mode number matched with the working state mode parameter in the actual communication data;
if yes, acquiring a working temperature threshold and/or a working time threshold corresponding to the mode number;
judging whether the working temperature parameter is within the working temperature threshold value and/or whether the working time parameter is within the working time threshold value;
and if the working temperature parameter meets the corresponding working temperature threshold value and/or the working time parameter meets the working time threshold value, the logical verification is passed.
Specifically, as an embodiment, taking cooking equipment such as an oven as an example, multiple working modes are preset in the oven, and a corresponding working time threshold and a corresponding working temperature threshold are adopted in each working mode. After receiving the actual communication data sent by the control board, as an implementation mode, preferentially judging whether the actual communication data contains the working mode parameters related to the mode number, and matching the mode number corresponding to the preset working mode in the steaming oven according to the working mode parameters. After the corresponding working mode is matched, if the communication data only contain working mode parameters, the power panel supplies power to the load of the steaming oven based on the working parameters to switch the working mode.
In one embodiment, the transmission of data in the communication process is generally 8 bytes as a transmission unit. However, in actual use, the length of the mode number may be 8, 16, 32, etc., so if the length of the mode number exceeds 8 bytes, the mode number needs to be disassembled into a plurality of data with the length of 8 bytes during transmission, and the data with the length of 8 bytes needs to be re-synthesized into one mode number according to a protocol during reception. The data for this mode number is invalid, assuming that one or more of the plurality of data was transmitted in error at the time of transmission. Therefore, the meaning of checking the mode number is that after the data is received and the mode number is synthesized, the mode number is checked once. For legal and illegal setting of the mode number, the mode numbers of all modes are preset in a program, for example, in a steam box, the mode number of common steaming is set to be 0x0001, the mode number of over-temperature steaming is set to be 0x0101, if the received mode number is not 0x0001 and not 0x0101, the mode number is illegal, and if one of the defined mode numbers is legal.
Further, if the communication data further includes a working time parameter and/or a working temperature parameter, obtaining a working time threshold and/or a working temperature threshold of the steam oven in the working mode, determining whether the working time parameter in the communication data meets the corresponding working time threshold and/or whether the working temperature parameter meets the corresponding working temperature threshold, and when the communication data meets the logic rule requirements corresponding to the working mode parameter, the working temperature parameter and/or the working time parameter at the same time, the power panel supplies power to the load of the steam oven to execute corresponding work based on the working mode parameter, the working time parameter and/or the working temperature parameter. Through the logic verification of the working mode, the corresponding working time, the working temperature and other parameters, the situation that the power panel runs abnormally due to the fact that communication data caused by external interference can pass through data verification but do not accord with the design requirements of equipment is avoided.
As an implementation manner, the performing logic check on the actual communication data by using the logic check rule in step S103 further includes the steps of:
judging whether the intelligent equipment is in a working state or not;
if yes, carrying out logic check on the actual communication data;
if not, determining that the logic verification is not carried out on the actual communication data.
Specifically, under the condition of being applied to cooking equipment such as a steam oven, when the cooking equipment is in a non-working state, the power panel does not perform cooking operation on the load, the obtained actual communication data generally does not generate abnormity, and as an embodiment, the actual communication data can not be subjected to logic verification so as to improve the communication efficiency of the control panel and the power panel.
As a practical way, the step of acquiring the actual communication data sent by the control board in step S102 includes:
continuously receiving communication data sent by the control panel, and judging whether the received communication data meets one frame of complete data;
if yes, carrying out data verification on the communication data;
and if the data passes the verification, assigning the communication data to the power panel.
Specifically, the communication time between the control board and the power board generally needs 200ms, the communication data sent by the control board is received in a periodic time, the running time of the power board is wasted, and the communication efficiency between the control board and the power board and the integrity and reliability of subsequent data verification can be improved by ensuring that the received communication data meets the data volume of one frame.
In an implementable manner, the data check is a CRC data check, and the steps include:
calculating the CRC value of the communication data according to a CRC protocol;
judging whether the CRC value is equal to a CRC value received in communication;
if yes, the data of the communication data is verified to be qualified.
As one implementable manner, the data verification further comprises:
if the CRC value is not equal to a CRC value received in communication, judging whether the data checking times exceed a preset time threshold value;
if so, the data verification result of the communication data is wrong;
if not, returning to the step of calculating the CRC value of the current data according to the CRC protocol.
Specifically, in one embodiment, data verification can be performed on each assignment in the communication process between the control board and the power board and in the operation process of the power board, the data verification obtains a data verification result by calculating the consistency between the CRC value of the currently assigned array and the CRC of the received communication data according to the CRC protocol, as an achievable mode, the verification frequency of each data verification can be preset to be less than three times, and the communication data still obtaining the verification error result after the three times of verification is used as communication data which is unqualified in data verification and discarded.
As an implementation manner, the communication interaction process between the control board and the power board corresponds to the operation process of the data receiving interrupt program and the operation process of the main program, and the execution priority of the operation process of the data receiving interrupt program is higher than that of the operation process of the main program;
and the operation process of the data receiving interrupt program and the operation process of the main program respectively adopt different logic verification rules to verify the communication data.
The following specifically describes the implementation principle of the communication data verification processing method by way of example:
in the communication process of the control panel and the power panel, three groups of cache data arrays a, b, c and d are arranged, wherein the array a is an array for receiving data from a communication line, and the data in the array continuously changes all the time and can change at any time during program operation; the array b is that when the array a receives a complete frame of data from the communication line, and the data of the array a is assigned to the array b after the data is checked correctly (such as CRC), and if the data is not checked correctly, the assignment operation is cancelled; the array c is that in the operation of the main program, the array b is directly assigned to the array c; and the array d is used for assigning the data of the array c to the array d after the array c is subjected to data verification and logic verification, and if the array c is not verified, the assignment operation is cancelled.
Where the main program is relative to the interrupt. The priority of the interrupt program is higher than that of the main program, when the interrupt request is generated, the main program is suspended, the interrupt program is preferentially executed, and after the interrupt program is completely executed, the main program is returned to be executed again. The main program in the singlechip carries out time management, such as one part of program running once every 10ms, and the other part of program running once every 100 ms.
As an embodiment, the data receiving interrupt routine is executed by continuously receiving data from the data line, assigning the value to the array a, and determining whether the reception of one frame of data is completed according to the communication protocol. If not, continuing to receive; if the data is finished, carrying out data verification on the received data, judging whether the data is correct or not, if the data is correct, assigning the data of the array a to the array b, generating a finished receiving zone bit, setting the zone bit to be 1, and if the data is judged to be wrong, skipping the assignment to the array b.
The main program runs logic, wherein the most important is the assignment operation on the array d, and the program operated on the logic is run under a certain time base, for example, once every 10 ms. Firstly, setting the flag bit of the data which is completely received to be 1, otherwise, directly exiting the main program without receiving the data, wherein the purpose of setting the step is to ensure that the subsequent operation can be carried out only after receiving new frame data; if the step does not exist, the assignment operation of the array d is carried out once every 10ms, the time of one-time communication is about 200ms, and the running time of the program is wasted; then, clearing the flag bit of the data which is received and assigning the array b to the array c, so as to ensure that no new assignment operation can be carried out on the array d after the new data reception of one frame is not completed; then, carrying out data check and logic check on the array c; and finally, assigning the data of the array c passing the data check and the logic check to an array d, and simultaneously finishing all the operations on the array d.
In the communication process, data check CRC during sending and receiving is correct, which brings difficulty to finding data errors, the situation may be ignored by testers occasionally, but the logic error of key data is easy to cause abnormal operation of intelligent equipment under the condition that the data exceeds the length of one transmission (such as 8 bytes).
According to the communication data verification processing method provided by the embodiment, through logical verification of the communication data, wrong communication data, especially communication data with correct data verification and logic errors which do not meet the design requirements of the intelligent equipment, are timely found, the wrong communication data are directly discarded, and the correct data are verified by using the previous frame, so that abnormal operation of the intelligent equipment caused by the wrong data can be effectively avoided.
Example 2
The present embodiment provides asystem 200 for checking and processing communication data, as shown in fig. 2, which is applied to communication interaction between a control board and a power board of an intelligent device, and includes:
thepreset module 201 is used for presetting logic check rules corresponding to different types of communication data;
an obtainingmodule 202, configured to obtain actual communication data sent by the control board;
thelogic verification module 203 is configured to perform logic verification on the actual communication data by using the logic verification rule based on the data type of the actual communication data;
theprocessing module 204 is configured to control the power board to supply power to a load of the intelligent device based on the actual communication data passing the logic verification, or discard the actual communication data not passing the logic verification.
As an implementable manner, the logic check module includes a data type unit and a threshold detection unit;
the data type unit is used for determining the data type corresponding to the communication data;
the threshold detection unit is used for determining whether the actual communication data corresponding to the data type is within a preset logic check threshold range.
As an achievable mode, the communication data is a data set, and the data set includes working state mode parameters corresponding to the intelligent device, and working temperature parameters and/or working time parameters;
the logic checking module comprises a data type unit, a mode matching unit and a threshold value detection unit;
the pattern matching unit is used for judging whether a pattern number matched with the working state pattern parameters in the actual communication data exists in the intelligent equipment;
the data type unit is used for determining whether the data set comprises working temperature parameters and/or working time data;
the threshold detection unit is configured to obtain a working temperature threshold and/or a working time threshold corresponding to the mode number, and determine whether the working temperature parameter is within the working temperature threshold and/or whether the working time parameter is within the working time threshold;
the processing module is further configured to discard actual communication data that is not matched with the mode number, or the working temperature parameter does not satisfy the corresponding working temperature threshold, and/or the working time parameter does not satisfy the working time threshold.
As an implementation manner, the logic check module is further configured to determine whether the smart device is in a working state; if yes, carrying out logic check on the actual communication data; and if not, determining not to carry out logic verification on the actual communication data.
As an implementation manner, the obtaining module is further configured to continuously receive the communication data sent by the control board, and determine whether the received communication data satisfies a frame of complete data;
the system also comprises a data verification module used for performing data verification on the communication data required by the acquisition module.
As an implementation manner, the data check module is a CRC data check module, and is configured to calculate a CRC value of the communication data according to a CRC protocol, and determine whether the CRC value is equal to a CRC value received in communication.
As an implementation manner, the CRC data checking module is further configured to return to the step of calculating the CRC value of the current data according to the CRC protocol when the data checking result of the communication data is incorrect.
As an achievable way, the communication interaction process between the control board and the power board corresponds to the operation process of a data receiving interrupt program and the operation process of a main program, and the execution priority of the operation process of the data receiving interrupt program is higher than that of the main program;
and the operation process of the data receiving interrupt program and the operation process of the main program respectively adopt different logic verification rules to verify the communication data.
According to the communication data verification processing system provided by the embodiment, through the logical verification of the communication data, the communication data with errors, especially the communication data with correct data verification and logic errors which do not meet the design requirements of the intelligent equipment, are found in time, the wrong communication data are directly discarded, the correct data are verified by using the previous frame, and the abnormal operation of the intelligent equipment caused by the wrong data can be effectively avoided.
Example 3
Fig. 3 is a schematic structural diagram of an electronic device according to embodiment 3 of the present invention. The system comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, and when the processor executes the computer program, the verification processing method of the communication data of the embodiment 1 is realized. Theelectronic device 30 shown in fig. 3 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
Theelectronic device 30 may be embodied in the form of a general purpose computing device, which may be, for example, a server device. The components of theelectronic device 30 may include, but are not limited to: the at least oneprocessor 31, the at least onememory 32, and abus 33 that couples various system components including thememory 32 and theprocessor 31.
Thebus 33 includes a data bus, an address bus, and a control bus.
Thememory 32 may include volatile memory, such as Random Access Memory (RAM) 321 and/orcache memory 322, and may further include Read Only Memory (ROM) 323.
Memory 32 may also include a program/utility 325 having a set (at least one) ofprogram modules 324,such program modules 324 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may comprise an implementation of a network environment.
Theprocessor 31 executes various functional applications and data processing, such as a verification processing method of communication data according to embodiment 1 of the present invention, by running the computer program stored in thememory 32.
Theelectronic device 30 may also communicate with one or more external devices 34 (e.g., keyboard, pointing device, etc.). Such communication may be through input/output (I/O) interfaces 35. Also, model-generatingdevice 30 may also communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) vianetwork adapter 36. As shown,network adapter 36 communicates with the other modules of model-generatingdevice 30 overbus 33. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with the model-generatingdevice 30, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
It should be noted that although in the above detailed description several units/modules or sub-units/modules of the electronic device are mentioned, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more of the units/modules described above may be embodied in one unit/module according to embodiments of the invention. Conversely, the features and functions of one unit/module described above may be further divided into embodiments by a plurality of units/modules.
Example 4
The present invention also provides a computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the method for verifying and processing communication data according to embodiment 1.
More specific examples, among others, that the readable storage medium may employ may include, but are not limited to: a portable disk, a hard disk, random access memory, read only memory, erasable programmable read only memory, optical storage device, magnetic storage device, or any suitable combination of the foregoing.
In a possible implementation manner, the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product runs on a terminal device, the program code is configured to enable the terminal device to execute a method for verifying and processing communication data, which is described in implementation example 1.
Where program code for carrying out the invention is written in any combination of one or more programming languages, the program code may be executed entirely on the user device, partly on the user device, as a stand-alone software package, partly on the user device and partly on a remote device or entirely on the remote device.
While specific embodiments of the invention have been described above, it will be understood by those skilled in the art that this is by way of example only, and that the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the spirit and scope of the invention, and these changes and modifications are within the scope of the invention.