Data verification method and device, electronic equipment and storage medium
Through a data verification method based on polling instructions, it solves the problems of existing industrial monitoring equipment such as large size, complex wiring, and inability to implement wireless communication and real-time data analysis, and achieves quick, easy and flexible verification of monitoring equipment data. Acquisition improves the flexibility and real-time performance of data verification.
Patent Information
- Application Number
- CN202411478139.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-22
- Publication Date
- 2025-01-21
AI Technical Summary
Existing industrial monitoring equipment is large in size and is not portable, requires complex wiring operations, cannot realize wireless communication, small data storage space, and cannot flexibly obtain real-time data for analysis, cannot judge the status and accuracy of the data, and it is difficult to realize data verification. .
Provide a data verification method by obtaining initialized queue data, obtaining return data according to polling instructions, sending target data in the queue data, obtaining response data, parsing the response data to obtain data to be verified, and processing the data to be verified Perform verification and obtain verification results. This method does not require complex wiring operations and enables quick and easy verification of monitoring equipment data.
It realizes quick and easy verification of monitoring equipment data without complicated wiring operations, flexibly obtains data status, realizes dynamic verification, and improves the flexibility and real-time performance of data verification.
Smart Images

Figure CN119342005A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data verification method, device, electronic device and storage medium. Background Art
[0002] In industrial applications, real-time monitoring of data can help us understand the current operating status of the machine. At the same time, we can adjust the machine in a timely manner according to the current operating status, so that the operation of the machine can tend to be executed in the direction of human control.
[0003] Existing industrial monitoring equipment usually monitors data based on the modbus RTU protocol. However, the monitoring equipment in the prior art is large and inconvenient to carry. In addition, the corresponding monitoring equipment usually requires external equipment wiring and debugging, cannot realize wireless communication to obtain data, the wiring operation is complicated, the data storage space is small and it is not convenient to export data for problem analysis, cannot flexibly obtain real-time data for data analysis operations, cannot judge the status and accuracy of the data, and realize data verification. Summary of the invention
[0004] The purpose of this application is to provide a data verification method, device, electronic device and storage medium, which can quickly and easily view and verify the data of the monitoring equipment without complicated wiring operations, making the data verification of the monitoring equipment more flexible, and can obtain the data status in time to realize dynamic verification of the data.
[0005] In a first aspect, an embodiment of the present application provides a data verification method, the method comprising:
[0006] Get the initialized queue data;
[0007] Obtain return data according to the polling instruction;
[0008] Send the target data in the queue data according to the returned data to obtain response data;
[0009] Parsing the response data to obtain data to be verified;
[0010] The data to be verified is verified to obtain a verification result.
[0011] In the above implementation process, the target data in the return data sending queue data obtained according to the polling instruction is obtained to obtain the data to be verified for verification. The data of the monitoring device can be checked quickly and easily without complicated wiring operations, making the data verification of the monitoring device more flexible, and the data status can be obtained in time to realize dynamic verification of the data.
[0012] Furthermore, the step of obtaining the returned data according to the polling instruction includes:
[0013] Sending a first polling instruction in the polling instructions, determining whether first return data corresponding to the first polling instruction is received within a first time threshold, and determining that the first return data is the return data;
[0014] If yes, send the second polling instruction in the polling instruction, obtain the second return data corresponding to the second polling instruction, and determine that the second return data is the return data, until all polling instructions in the polling instruction are sent;
[0015] If not, a timeout timer is enabled according to the first function, first return data after timeout corresponding to the first polling instruction is obtained, and the first return data after timeout corresponding to the first polling instruction is determined to be the return data.
[0016] In the above implementation process, polling instructions are issued in sequence, and return data is received within a preset time threshold. Limiting the receiving time of the return data can ensure the real-time nature of data verification and avoid affecting the data status due to too long a time.
[0017] Furthermore, the step of obtaining the first returned data after the timeout corresponding to the first polling instruction further includes:
[0018] Determine whether first returned data after timeout corresponding to the first polling instruction is received within a second time threshold corresponding to the timeout timer;
[0019] If yes, performing data analysis on the first returned data after the timeout according to the second function;
[0020] If not, determine whether the queue data contains data that needs to be sent. If the queue data contains no data that needs to be sent, enable the polling delay timer according to the third function.
[0021] In the above implementation process, when the first return data after timeout corresponding to the first polling instruction is received within the second time threshold of the timeout timer, the first return data after timeout corresponding to the first polling instruction is parsed in time to ensure the accuracy of the data and reduce data errors.
[0022] Furthermore, the step of parsing the response data to obtain the data to be verified includes:
[0023] Match the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain a first array;
[0024] The target data in the instruction buffer of the queue data is added to the first array to obtain the data to be verified.
[0025] In the above implementation process, the target instruction in the instruction buffer is matched with the frame header data of the response data, so that the response data can be processed in time and the data redundancy caused by the response data can be reduced.
[0026] Furthermore, the step of matching the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain the first array includes:
[0027] Matching the frame header data with the slave number and function code in the target instruction to determine whether the target byte data of the frame header data is matched;
[0028] If so, determine that the frame header data is correct data, mark the frame header position, and obtain the first array.
[0029] In the above implementation process, the frame header data is matched according to the slave number and the function code, so that the accuracy of the frame header data can be accurately verified, support can be provided for subsequent data verification, and the flexibility of data verification can be improved.
[0030] Furthermore, the step of verifying the data to be verified and obtaining a verification result includes:
[0031] Determine whether the target byte of the data to be verified is a preset length;
[0032] If so, determine that the data to be verified is correct data, obtain the verification code of the data to be verified, and determine whether the verification code is correct. If the verification code is correct, clear the data according to the fourth function.
[0033] In the above implementation process, the accuracy of the data to be verified is determined according to the length of the target byte, and the check code of the data to be verified is further verified, which can improve the accuracy of the verification, avoid verification errors, and improve the verification efficiency.
[0034] In a second aspect, an embodiment of the present application further provides a data verification device, the device comprising:
[0035] The acquisition module is used to obtain the queue data after initialization;
[0036] A data acquisition module, used to obtain return data according to the polling instruction; and also used to send the target data in the queue data according to the return data to obtain response data;
[0037] A parsing module, used for parsing the response data to obtain data to be verified;
[0038] The verification module is used to verify the data to be verified and obtain a verification result.
[0039] In the above implementation process, the target data in the return data sending queue data obtained according to the polling instruction is obtained to obtain the data to be verified for verification. The data of the monitoring device can be checked quickly and easily without complicated wiring operations, making the data verification of the monitoring device more flexible, and the data status can be obtained in time to realize dynamic verification of the data.
[0040] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.
[0042] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables the computer to execute the method as described in any one of the first aspects.
[0043] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present disclosure.
[0044] And it can be implemented according to the contents of the specification. The following is a detailed description of the preferred embodiments of the present application with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the range values. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 A schematic diagram of a data verification method according to an embodiment of the present invention;
[0047] Figure 2 A schematic diagram of the structure of a data verification device provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0050] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0051] The specific implementation methods of the present application are further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.
[0052] Embodiment 1
[0053] Figure 1 is a flow chart of a data verification method provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0054] S1, obtain the initialized queue data;
[0055] S2, obtain the returned data according to the polling instruction;
[0056] S3, sending the target data in the queue data according to the returned data to obtain the response data;
[0057] S4, parsing the response data to obtain the data to be verified;
[0058] S5, verifying the data to be verified and obtaining a verification result.
[0059] In the above implementation process, the target data in the return data sending queue data obtained according to the polling instruction is obtained to obtain the data to be verified for verification. The data of the monitoring device can be checked quickly and easily without complicated wiring operations, making the data verification of the monitoring device more flexible, and the data status can be obtained in time to realize dynamic verification of the data.
[0060] In S1, the queue data sent by the server is initialized. The embodiment of the present application performs polling based on the polling rule of the modbusTCP protocol, obtains the register data / parameter return data sent by the slave by sending a polling instruction, and the slave makes a passive response.
[0061] Furthermore, S2 includes:
[0062] Sending a first polling instruction in the polling instructions, determining whether first return data corresponding to the first polling instruction is received within a first time threshold, and determining that the first return data is return data;
[0063] If yes, send the second polling instruction in the polling instruction, obtain the second return data corresponding to the second polling instruction, and determine that the second return data is the return data, until all polling instructions in the polling instruction are sent;
[0064] If not, the timeout timer is enabled according to the first function, the first return data after the timeout corresponding to the first polling instruction is obtained, and the first return data after the timeout corresponding to the first polling instruction is determined to be the return data.
[0065] In the above implementation process, polling instructions are issued in sequence, and return data is received within a preset time threshold. Limiting the receiving time of the return data can ensure the real-time nature of data verification and avoid affecting the data status due to too long a time.
[0066] When the host sends a polling instruction, it will confirm whether the response timeout has occurred based on the response time of the return data from the slave. There may be multiple polling data in each polling cycle. In the embodiment of the present application, two different polling instructions are used as one polling cycle. When the response time exceeds the first time threshold, the polling timeout occurs, and then the timeout timer is enabled again. The next polling data is sent according to the polling delay time, and so on.
[0067] Optionally, the first function of the embodiment of the present application may be a List.pushBack(list, value) function.
[0068] During the polling process of the present application, when the response time meets the requirement of the first time threshold, the slave number subscript curSlaveIndex and the address number subscript curCmdIndex corresponding to the polling instruction are respectively increased by 1. By judging whether the current queue value exists in the queue through the curSlaveIndex subscript value, the order of the polling instructions sent is ensured to follow the first-in-first-out principle.
[0069] Furthermore, the step of obtaining the first returned data after the timeout corresponding to the first polling instruction also includes:
[0070] Determine whether first returned data after timeout corresponding to the first polling instruction is received within a second time threshold corresponding to the timeout timer;
[0071] If yes, perform data analysis on the first returned data after the timeout according to the second function;
[0072] If not, determine whether there is data in the queue that needs to be sent. If there is no data in the queue that needs to be sent, enable the polling delay timer according to the third function.
[0073] In the above implementation process, when the first return data after timeout corresponding to the first polling instruction is received within the second time threshold of the timeout timer, the first return data after timeout corresponding to the first polling instruction is parsed in time to ensure the accuracy of the data and reduce data errors.
[0074] The timeout timer is enabled. If the corresponding data is received (the first returned data after the timeout corresponding to the first polling instruction), the data parsing callback is implemented according to the on_mb_recv_data(packet) function (the second function).
[0075] If no response is received, it is determined whether there is data to be sent in the current queue data. If there is no corresponding data to be sent in the queue data, the polling delay timer is started and the next polling data is sent, and so on. When all polling instructions in a polling cycle are executed, the polling ends. Optionally, the third function can be the same function as the first function, which is used to start the timer.
[0076] Furthermore, S4 includes:
[0077] Matching the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain a first array;
[0078] The target data in the instruction buffer of the queue data is added to the first array to obtain the data to be verified.
[0079] In the above implementation process, the target instruction in the instruction buffer is matched with the frame header data of the response data, so that the response data can be processed in time and the data redundancy caused by the response data can be reduced.
[0080] The response data will trigger on_mb_recv_data(packet). The embodiment of the present application performs data parsing according to the modbusTCP protocol. The data parsing triggers the callback in byte mode, which is obtained in the instruction buffer.
[0081] Further, the step of matching the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain the first array includes:
[0082] Match the slave number and function code in the target instruction with the frame header data to determine whether the target byte data of the frame header data is matched;
[0083] If so, determine that the frame header data is correct data, mark the frame header position, and obtain the first array.
[0084] In the above implementation process, the frame header data is matched according to the slave number and the function code, so that the accuracy of the frame header data can be accurately verified, support can be provided for subsequent data verification, and the flexibility of data verification can be improved.
[0085] The embodiment of the present application matches the frame header data using a for loop, starting from i and ending at #packet (the last received byte index). The frame header data is found by corresponding judgment, and the first two bytes of a frame of complete data correspond to the slave number and function code. If the corresponding correct data is received, the flag position of the frame header data is 1, and the data is added to the buff array (the first array) to obtain the data to be checked.
[0086] Furthermore, S5 includes:
[0087] Determine whether the target byte of the data to be verified is a preset length;
[0088] If so, determine that the data to be verified is correct data, obtain the verification code of the data to be verified, and determine whether the verification code is correct. If the verification code is correct, clear the data according to the fourth function.
[0089] In the above implementation process, the accuracy of the data to be verified is determined according to the length of the target byte, and the check code of the data to be verified is further verified, which can improve the accuracy of the verification, avoid verification errors, and improve the verification efficiency.
[0090] Determine the data length of the third byte (target byte) of a complete frame of data received. The data structure is: slave number (1 byte) - function code (1 byte) - data length (1 byte) - register data (several bytes, based on the data length) - CRC16 check (2 bytes). The data in the first array is a complete frame of data. At the same time, determine whether the received CRC16 check code is correct. If it is correct, execute the cmd_list_check_ack (user_cmd_buff) function (the fourth function), which mainly displays the currently read register data. At the same time, clear the current first array and clear the corresponding count variable.
[0091] The embodiments of the present application can quickly and flexibly realize real-time parameter acquisition and verification data through wireless processing, and can realize the function of exporting verification data to an SD card or USB flash drive, and support opening files on a computer to view real-time data.
[0092] Embodiment 2
[0093] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a data verification device is provided below, such as Figure 2 As shown, the device comprises:
[0094] Acquisition module 1, used to obtain the queue data after initialization;
[0095] The data acquisition module 2 is used to obtain the returned data according to the polling instruction; and is also used to send the target data in the queue data according to the returned data to obtain the response data;
[0096] The parsing module 3 is used to parse the response data to obtain the data to be verified;
[0097] The verification module 4 is used to verify the data to be verified and obtain the verification result.
[0098] In the above implementation process, the target data in the return data sending queue data obtained according to the polling instruction is obtained to obtain the data to be verified for verification. The data of the monitoring device can be checked quickly and easily without complicated wiring operations, making the data verification of the monitoring device more flexible, and the data status can be obtained in time to realize dynamic verification of the data.
[0099] Furthermore, the data acquisition module 2 is also used for:
[0100] Sending a first polling instruction in the polling instructions, determining whether first return data corresponding to the first polling instruction is received within a first time threshold, and determining that the first return data is return data;
[0101] If yes, send the second polling instruction in the polling instruction, obtain the second return data corresponding to the second polling instruction, and determine that the second return data is the return data, until all polling instructions in the polling instruction are sent;
[0102] If not, the timeout timer is enabled according to the first function, the first return data after the timeout corresponding to the first polling instruction is obtained, and the first return data after the timeout corresponding to the first polling instruction is determined to be the return data.
[0103] In the above implementation process, polling instructions are issued in sequence, and return data is received within a preset time threshold. Limiting the receiving time of the return data can ensure the real-time nature of data verification and avoid affecting the data status due to too long a time.
[0104] Furthermore, the data acquisition module 2 is also used for:
[0105] Determine whether first returned data after timeout corresponding to the first polling instruction is received within a second time threshold corresponding to the timeout timer;
[0106] If yes, perform data analysis on the first returned data after the timeout according to the second function;
[0107] If not, determine whether there is data in the queue that needs to be sent. If there is no data in the queue that needs to be sent, enable the polling delay timer according to the third function.
[0108] In the above implementation process, when the first return data after timeout corresponding to the first polling instruction is received within the second time threshold of the timeout timer, the first return data after timeout corresponding to the first polling instruction is parsed in time to ensure the accuracy of the data and reduce data errors.
[0109] Furthermore, the parsing module 3 is also used for:
[0110] Matching the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain a first array;
[0111] The target data in the instruction buffer of the queue data is added to the first array to obtain the data to be verified.
[0112] In the above implementation process, the target instruction in the instruction buffer is matched with the frame header data of the response data, so that the response data can be processed in time and the data redundancy caused by the response data can be reduced.
[0113] Furthermore, the parsing module 3 is also used for:
[0114] Match the slave number and function code in the target instruction with the frame header data to determine whether the target byte data of the frame header data is matched;
[0115] If so, determine that the frame header data is correct data, mark the frame header position, and obtain the first array.
[0116] In the above implementation process, the frame header data is matched according to the slave number and the function code, so that the accuracy of the frame header data can be accurately verified, support can be provided for subsequent data verification, and the flexibility of data verification can be improved.
[0117] Furthermore, the verification module 4 is also used for:
[0118] Determine whether the target byte of the data to be verified is a preset length;
[0119] If so, determine that the data to be verified is correct data, obtain the verification code of the data to be verified, and determine whether the verification code is correct. If the verification code is correct, clear the data according to the fourth function.
[0120] In the above implementation process, the accuracy of the data to be verified is determined according to the length of the target byte, and the check code of the data to be verified is further verified, which can improve the accuracy of the verification, avoid verification errors, and improve the verification efficiency.
[0121] The above data verification device can implement the method of the above embodiment 1. The options in the above embodiment 1 are also applicable to this embodiment and will not be described in detail here.
[0122] The rest of the contents of the embodiments of the present application can refer to the contents of the above-mentioned embodiment 1, and will not be repeated in this embodiment.
[0123] Embodiment 3
[0124] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the data verification method of the first embodiment.
[0125] Optionally, the above-mentioned electronic device may be a server.
[0126] See also Figure 3 , Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 31, a communication interface 32, a memory 33 and at least one communication bus 34. The communication bus 34 is used to realize direct connection and communication between these components. The communication interface 32 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 31 may be an integrated circuit chip with signal processing capabilities.
[0127] The processor 31 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 31 can also be any conventional processor, etc.
[0128] The memory 33 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 33 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 31, the device can execute the above-mentioned Figure 1 The method embodiment involves various steps.
[0129] Optionally, the electronic device may further include a storage controller and an input / output unit. The memory 33, the storage controller, the processor 31, the peripheral interface, and the input / output unit are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via a communication bus 34. The processor 31 is used to execute executable modules stored in the memory 33, such as software function modules or computer programs included in the device.
[0130] The input and output unit is used to provide users with the task creation and to create an optional time period or preset execution time for the task to enable interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0131] Understandably, Figure 3 The structure shown is for illustration only. The electronic device may also include Figure 3 More or fewer components as shown, or with Figure 3 Different configurations are shown. Figure 3 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0132] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which implements the data verification method of the first embodiment when the computer program is executed by a processor.
[0133] The embodiment of the present application also provides a computer program product, which, when running on a computer, enables the computer to execute the method described in the method embodiment.
[0134] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based device that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0136] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0137] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0138] The above is only a specific implementation of the present application, but the protection range of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical range disclosed in the present application, which should be included in the protection range of the present application. Therefore, the protection range of the present application should be based on the protection range of the claims.
[0139] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A data verification method, characterized in that: The method comprises: Get the initialized queue data; Obtain return data according to the polling instruction; Send the target data in the queue data according to the returned data to obtain response data; Parsing the response data to obtain data to be verified; The data to be verified is verified to obtain a verification result.
2. The data verification method according to claim 1, characterized in that: The step of obtaining the returned data according to the polling instruction comprises: Sending a first polling instruction in the polling instructions, determining whether first return data corresponding to the first polling instruction is received within a first time threshold, and determining that the first return data is the return data; If yes, send the second polling instruction in the polling instruction, obtain the second return data corresponding to the second polling instruction, and determine that the second return data is the return data, until all polling instructions in the polling instruction are sent; If not, a timeout timer is enabled according to the first function, first return data after timeout corresponding to the first polling instruction is obtained, and the first return data after timeout corresponding to the first polling instruction is determined to be the return data.
3. The data verification method according to claim 2, characterized in that: The step of obtaining first returned data after timeout corresponding to the first polling instruction also includes: Determine whether first returned data after timeout corresponding to the first polling instruction is received within a second time threshold corresponding to the timeout timer; If yes, performing data analysis on the first returned data after the timeout according to the second function; If not, determine whether the queue data contains data that needs to be sent. If the queue data contains no data that needs to be sent, enable the polling delay timer according to the third function.
4. The data verification method according to claim 1, characterized in that: The step of parsing the response data to obtain the data to be verified includes: Match the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain a first array; The target data in the instruction buffer of the queue data is added to the first array to obtain the data to be verified.
5. The data verification method according to claim 4, characterized in that: The step of matching the frame header data of the response data according to the target instruction in the instruction buffer of the queue data to obtain the first array includes: Matching the frame header data with the slave number and function code in the target instruction to determine whether the target byte data of the frame header data is matched; If so, determine that the frame header data is correct data, mark the frame header position, and obtain the first array.
6. The data verification method according to claim 1, characterized in that: The step of verifying the data to be verified and obtaining a verification result comprises: Determine whether the target byte of the data to be verified is a preset length; If so, determine that the data to be verified is correct data, obtain the verification code of the data to be verified, and determine whether the verification code is correct. If the verification code is correct, clear the data according to the fourth function.
7. A data verification device, characterized in that: The device comprises: The acquisition module is used to obtain the queue data after initialization; A data acquisition module, used to obtain return data according to the polling instruction; and also used to send the target data in the queue data according to the return data to obtain response data; A parsing module, used for parsing the response data to obtain data to be verified; The verification module is used to verify the data to be verified and obtain a verification result.
8. The data verification device according to claim 7, characterized in that: The data acquisition module is also used for: Sending a first polling instruction in the polling instructions, determining whether first return data corresponding to the first polling instruction is received within a first time threshold, and determining that the first return data is the return data; If yes, send the second polling instruction in the polling instruction, obtain the second return data corresponding to the second polling instruction, and determine that the second return data is the return data, until all polling instructions in the polling instruction are sent; If not, a timeout timer is enabled according to the first function, first return data after timeout corresponding to the first polling instruction is obtained, and the first return data after timeout corresponding to the first polling instruction is determined to be the return data.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the data verification method according to any one of claims 1 to 6.
10. A storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the data verification method as claimed in any one of claims 1 to 6.