A method and device for processing serial communication instructions

By using instruction queue management and feedback data verification and analysis in serial communication, combined with instruction resend and timeout processing, the problems of unstable and unreliable serial communication are solved, and more efficient and reliable communication is achieved.

CN119766905APending Publication Date: 2025-04-04SHENZHEN LACHESIS MOBILE MEDICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411787308.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing serial port communication fails to respond in time after the command is sent, data transmission error detection defects, lacks instruction timeout processing mechanism and failure retry mechanism, resulting in unstable and unreliable communication.

Method used

The instructions to be sent are obtained through the current instruction queue to ensure the order of the instructions processed by the lower computer, and the integrity verification and analysis of the feedback data is carried out to ensure the correctness and consistency of the feedback data. At the same time, the instruction resend mechanism and timeout processing are implemented to ensure the stability and reliability of communication.

Benefits of technology

It improves the stability and reliability of serial communication between the upper and lower computers, reduces response delays and errors, and enhances instruction processing efficiency and system response capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766905A_ABST
    Figure CN119766905A_ABST
Patent Text Reader

Abstract

The present application discloses a method and device for processing serial communication instructions, which relates to the field of industrial communication control, including: obtaining a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue; when the first instruction is not empty, sending the first instruction to a lower computer, and receiving the first feedback data returned by the lower computer when executing the first instruction; performing integrity check on the first feedback data to obtain a first check result; when the first check result meets the preset integrity standard, parsing the first feedback data to obtain a first feedback instruction; when the first feedback instruction is consistent with the first instruction, obtaining the execution result of the first instruction according to the first feedback data. The implementation of the present application can solve the problem of unstable and unreliable serial communication between the upper computer and the lower computer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial communication control, and in particular to a method and device for processing serial communication instructions. Background Art

[0002] In the modern serial communication processing, the data interaction between the host computer and the slave computer occupies a very high share and is widely used in the field of industrial control, such as IoT devices and smart homes. The existing technology mainly relies on the standard serial communication protocol to implement the sending and response of instructions.

[0003] However, in actual application, the existing serial communication has many defects. First, when the lower computer fails to respond to the command in time or responds in a chaotic manner after the command is sent, it is difficult for the upper computer to determine the successful execution of the command; second, the existing serial communication protocol has defects in the error detection of data transmission, which may cause the lower computer to execute the wrong command; third, there is a lack of an effective command timeout processing mechanism, which may cause the command to be lost when the lower computer is busy; fourth, there is a lack of a failure retry mechanism. When the command has no response or an error response, the upper computer can only wait passively and cannot actively adjust and restore communication. The above defects will lead to instability and unreliability of serial communication between the upper computer and the lower computer. Therefore, how to improve the stability and reliability of serial communication between the upper computer and the lower computer is still a technical problem that needs to be solved urgently in the prior art. Summary of the invention

[0004] The present application provides a serial communication instruction processing method and device to solve the technical problem of unstable and unreliable serial communication between a host computer and a slave computer.

[0005] According to a first aspect of an embodiment of the present application, a method for processing a serial communication instruction is provided, comprising:

[0006] Obtaining a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue;

[0007] When the first instruction is not empty, sending the first instruction to the lower computer, and receiving first feedback data returned by the lower computer when executing the first instruction;

[0008] Performing integrity check on the first feedback data to obtain a first check result;

[0009] When the first verification result meets the preset integrity standard, parsing the first feedback data to obtain a first feedback instruction;

[0010] When the first feedback instruction is consistent with the first instruction, the execution result of the first instruction is obtained according to the first feedback data.

[0011] The present application first obtains the first instruction to be sent through the current instruction queue, then sends the first instruction to the lower computer when the first instruction is not empty, and receives the first feedback data returned by the lower computer after executing the first instruction. The orderliness of the lower computer processing instructions is ensured through the instruction queue, which can reduce the response delay or response error caused by insufficient processing capacity of the lower computer, thereby improving the overall processing efficiency and communication stability; and then the integrity of the first feedback data is checked to obtain a first check result, which can timely detect data damage and loss in transmission through the data integrity check, avoid useless parsing of incomplete data, further improve the instruction processing efficiency and communication stability, and only parse the first feedback data to obtain the first feedback instruction when the first check result meets the integrity standard, and only obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction, which can ensure that the first feedback data returned by the lower computer corresponds to the first instruction currently sent to the lower computer through the strict correspondence between the first feedback instruction and the first instruction, eliminate response confusion, and improve response stability and reliability.

[0012] In some implementations of the present application, the receiving of the first feedback data returned by the lower computer when the lower computer executes the first instruction specifically includes:

[0013] Opening a first receiving window according to preset window parameters, and collecting, through the first receiving window, a feedback byte stream returned by the lower computer when executing the first instruction;

[0014] When a preset end identifier appears in the feedback byte stream, all bytes in the feedback byte stream are combined to obtain first feedback data, the feedback byte stream is cleared and collection is stopped.

[0015] The present application first opens a first receiving window according to preset window parameters, and collects the feedback byte stream returned by the lower computer when executing the first instruction through the first receiving window, and obtains the first feedback data when an end identifier appears in the feedback byte stream, clears the feedback byte stream and stops collecting, which can ensure the correct collection of the first feedback data, thereby avoiding execution result errors caused by feedback data collection errors and improving communication reliability.

[0016] In certain embodiments of the present application, it further includes:

[0017] When the first verification result does not meet the integrity standard, the first feedback data is discarded, and a first re-collection instruction is issued to enable the first receiving window to re-collect the feedback byte stream.

[0018] When the first verification result does not meet the integrity standard, the present application discards the first feedback data and issues a first re-collection instruction to enable the first receiving window to re-collect the feedback byte stream. This can promptly detect the incompleteness of the first feedback data due to damage and loss of transmitted data, avoid subsequent useless parsing of incomplete data, and thus improve instruction processing efficiency and communication stability.

[0019] In some implementations of the present application, obtaining the execution result of the first instruction according to the first feedback data specifically includes:

[0020] When the number of times the first instruction is sent is not greater than a preset maximum number of times, obtaining a waiting time according to a sending timestamp of the first instruction and a feedback timestamp of the first feedback data;

[0021] If the waiting time is not greater than a preset timeout threshold, the first feedback data is used as the execution result of the first instruction.

[0022] The present application first obtains the waiting time according to the timestamps of the first instruction and the first feedback data when the number of times the first instruction is sent does not exceed the maximum number of times, and then obtains the execution result of the first instruction when the waiting time is not greater than the timeout threshold. This can avoid the instruction error response caused by the instruction transmission timeout caused by network delay, thereby avoiding response confusion.

[0023] In some embodiments of the present application, after obtaining the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data, the method further includes:

[0024] If the waiting time is greater than the timeout threshold, the first instruction is placed at the beginning of the current instruction queue to resend the first instruction, and the number of times the first instruction is sent is updated.

[0025] When the waiting time is greater than the timeout threshold, the present application resends the first instruction and updates the number of transmissions, and can provide a retry capability for the host computer when it is determined that the instruction has timed out, thereby improving the system's responsiveness and communication reliability.

[0026] In some embodiments of the present application, before obtaining the first instruction to be sent, the method further includes:

[0027] When the number of times the first instruction is sent is greater than the maximum number of times, a combination of a preset default result and the first instruction is used as the execution result of the first instruction.

[0028] When the number of times the first instruction is sent is greater than the maximum number of times, the present application combines the default result and the first instruction as the execution result of the first instruction, which can avoid reduced efficiency due to excessive retries, ensure the responsiveness of the system, and improve communication reliability.

[0029] According to a second aspect of the implementation of the present application, there is provided a serial communication instruction processing device, including an instruction acquisition module, an instruction sending module, a feedback verification module, a feedback parsing module and a result acquisition module;

[0030] The instruction acquisition module is used to acquire a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue;

[0031] The instruction sending module is used for sending the first instruction to the lower computer when the first instruction is not empty, and receiving the first feedback data returned by the lower computer when the first instruction is executed;

[0032] The feedback verification module is used to perform integrity verification on the first feedback data to obtain a first verification result;

[0033] The feedback parsing module is configured to parse the first feedback data to obtain a first feedback instruction when the first verification result meets a preset integrity standard;

[0034] The result acquisition module is used to obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction.

[0035] In certain embodiments of the present application, the instruction sending module includes a feedback receiving submodule; the feedback receiving submodule includes a window acquisition unit and a byte combination unit;

[0036] The window collection unit is used to open a first receiving window according to preset window parameters, and collect a feedback byte stream returned by the lower computer when executing the first instruction through the first receiving window;

[0037] The byte combination unit is used to combine all bytes in the feedback byte stream to obtain first feedback data, clear the feedback byte stream and stop collecting when a preset end identifier appears in the feedback byte stream.

[0038] In certain embodiments of the present application, the feedback verification module includes a data re-collection submodule;

[0039] The data re-collection submodule is used to discard the first feedback data and issue a first re-collection instruction to enable the first receiving window to re-collect the feedback byte stream when the first verification result does not meet the integrity standard.

[0040] In certain embodiments of the present application, the result acquisition module includes a waiting time acquisition submodule and an execution result acquisition submodule;

[0041] The waiting time acquisition submodule is used to obtain the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data when the sending timestamp of the first instruction is not greater than the preset maximum sending timestamp;

[0042] The execution result acquisition submodule is used to use the first feedback data as the execution result of the first instruction if the waiting time is not greater than a preset timeout threshold.

[0043] In certain embodiments of the present application, the result acquisition module includes an instruction resending submodule;

[0044] The instruction resending submodule is used for placing the first instruction at the beginning of the current instruction queue to resend the first instruction if the waiting time is greater than the timeout threshold, and updating the number of times the first instruction is sent.

[0045] In some embodiments of the present application, a default result acquisition module is also included;

[0046] The default result acquisition module is used to use a combination of a preset default result and the first instruction as the execution result of the first instruction when the number of times the first instruction is sent is greater than the maximum number of times.

[0047] The present application first obtains the first instruction to be sent through the current instruction queue, then sends the first instruction to the lower computer when the first instruction is not empty, and receives the first feedback data returned by the lower computer after executing the first instruction. The orderliness of the lower computer processing instructions is ensured through the instruction queue, which can reduce the response delay or response error caused by insufficient processing capacity of the lower computer, thereby improving the overall processing efficiency and communication stability; and then the integrity of the first feedback data is checked to obtain a first check result, which can timely detect data damage and loss in transmission through the data integrity check, avoid useless parsing of incomplete data, further improve the instruction processing efficiency and communication stability, and only parse the first feedback data to obtain the first feedback instruction when the first check result meets the integrity standard, and only obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction, which can ensure that the first feedback data returned by the lower computer corresponds to the first instruction currently sent to the lower computer through the strict correspondence between the first feedback instruction and the first instruction, eliminate response confusion, and improve response stability and reliability. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1: is a flow chart of a serial communication instruction processing method shown in certain embodiments of the present application;

[0049] Figure 2 : A module structure diagram of a serial communication instruction processing device shown in certain embodiments of the present application. DETAILED DESCRIPTION

[0050] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below in conjunction with the accompanying drawings are exemplary and are only used to explain some embodiments of the present application, and should not be construed as limitations on the embodiments of the present application. Based on the embodiments shown in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0051] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, unless otherwise clearly and specifically defined, "multiple" and "several" mean two or more.

[0052] There are many defects in the existing serial communication process, including but not limited to: when the lower computer fails to respond to the command in time or responds in a chaotic manner after the command is sent, it is difficult for the upper computer to determine the successful execution of the command; there are defects in the error detection of data transmission, which may cause the lower computer to execute the wrong command; there is a lack of an effective command timeout processing mechanism, which may cause the command to be lost when the lower computer is busy; there is a lack of a failure retry mechanism, when the command has no response or an error response, the upper computer can only wait passively and cannot actively adjust and restore communication. The above defects will lead to instability and unreliability of serial communication between the upper computer and the lower computer. Therefore, how to improve the stability and reliability of serial communication between the upper computer and the lower computer is still a technical problem that needs to be solved urgently in the prior art.

[0053] Based on the above technical background, please refer to Figure 1 The embodiment of the present application provides a serial communication instruction processing method, including steps S101 to S105, each step is as follows:

[0054] Step S101: Acquire a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue.

[0055] In certain embodiments of the present application, the preferred data structure form of the current instruction queue is a queue. Generally, the elements in the queue have a first-in, first-out property.

[0056] Step S102: when the first instruction is not empty, sending the first instruction to the lower computer, and receiving first feedback data returned by the lower computer when executing the first instruction.

[0057] In certain embodiments of the present application, it further includes:

[0058] When the first instruction is empty, the first instruction is discarded, and the first instruction at the beginning after the first instruction is popped out of the current instruction queue is selected as a new first instruction for processing.

[0059] In some implementations of the present application, the receiving of the first feedback data returned by the lower computer when the lower computer executes the first instruction specifically includes:

[0060] Opening a first receiving window according to preset window parameters, and collecting, through the first receiving window, a feedback byte stream returned by the lower computer when executing the first instruction;

[0061] When a preset end identifier appears in the feedback byte stream, all bytes in the feedback byte stream are combined to obtain first feedback data, the feedback byte stream is cleared and collection is stopped.

[0062] Specifically, due to the difference in transmission mechanism between the upper computer and the lower computer, when the upper computer receives the transmission data of the lower computer, it is usually the upper computer that receives the data returned by the lower computer by opening the receiving stream and accumulating single bytes. Exemplarily, after the lower computer executes the first instruction sent by the upper computer, the returned data is "AA11223344XXBB", then in the feedback byte stream collected by the first receiving window opened by the upper computer, the first collection obtains "AA", and the byte accumulation is "AA"; the second collection is "11", and the byte accumulation is "AA11"; and so on, until the end identifier appears in the collection, which is "BB" in this example, and the byte accumulation is "AA11223344XXBB", then the first feedback data obtained by combining all bytes in the feedback byte stream is "AA11223344XXBB".

[0063] In certain embodiments of the present application, the end identifier may be specified by the specific serial communication protocol of the upper computer and the lower computer at both ends of the communication, and the serial communication protocol may be a public protocol or a private protocol; or may be set by a person skilled in the art for the upper computer and the corresponding lower computer according to relevant communication specifications before the upper computer and the lower computer communicate. This is common knowledge in the art, and the present application does not make corresponding limitations here.

[0064] The present application first opens a first receiving window according to preset window parameters, and collects the feedback byte stream returned by the lower computer when executing the first instruction through the first receiving window, and obtains the first feedback data when an end identifier appears in the feedback byte stream, clears the feedback byte stream and stops collecting, which can ensure the correct collection of the first feedback data, thereby avoiding execution result errors caused by feedback data collection errors and improving communication reliability.

[0065] Step S103: Perform integrity check on the first feedback data to obtain a first check result.

[0066] In certain implementations of the present application, the integrity check rule corresponding to the integrity check is provided by the party where the lower computer is located and is set in the serial port communication program of the upper computer.

[0067] In certain embodiments of the present application, the integrity check rules corresponding to the integrity check include but are not limited to odd check, even check, cumulative check, XOR check or cyclic redundancy check on all bytes or check bytes of the first feedback data. The preferred implementation is the XOR check on the check bytes of the first feedback data.

[0068] Exemplarily, the first feedback data is "AA11223344XXBB", the check byte is "XX" in the first feedback data, the check rule is XOR check, and the integrity standard is that the check byte satisfies the check rule. When the check byte satisfies the check rule, the first check result obtained meets the integrity standard; otherwise, the first check result obtained does not meet the integrity standard.

[0069] Step S104: when the first verification result meets the preset integrity standard, the first feedback data is parsed to obtain a first feedback instruction.

[0070] In some implementations of the present application, the parsing of the first feedback data to obtain the first feedback instruction is specifically:

[0071] Obtaining a data return time according to a current round sending timestamp of the first instruction and a feedback timestamp of the first feedback data;

[0072] If the data return time is not greater than a preset return timeout threshold, the first feedback data is parsed to obtain a first feedback instruction.

[0073] In certain implementations of the present application, the preferred value of the return timeout threshold is 1000 ms.

[0074] In certain embodiments of the present application, it further includes:

[0075] When the first verification result does not meet the integrity standard, the first feedback data is discarded, and a first re-collection instruction is issued to enable the first receiving window to re-collect the feedback byte stream.

[0076] When the first verification result does not meet the integrity standard, the present application discards the first feedback data and issues a first re-collection instruction to enable the first receiving window to re-collect the feedback byte stream. This can promptly detect the incompleteness of the first feedback data due to damage and loss of transmitted data, avoid subsequent useless parsing of incomplete data, and thus improve instruction processing efficiency and communication stability.

[0077] Step S105: when the first feedback instruction is consistent with the first instruction, obtaining the execution result of the first instruction according to the first feedback data.

[0078] In certain embodiments of the present application, it further includes:

[0079] When the first feedback instruction is inconsistent with the first instruction, a combination of a preset default result and the first instruction is used as the execution result of the first instruction.

[0080] In some implementations of the present application, obtaining the execution result of the first instruction according to the first feedback data specifically includes:

[0081] When the number of times the first instruction is sent is not greater than a preset maximum number of times, obtaining a waiting time according to a sending timestamp of the first instruction and a feedback timestamp of the first feedback data;

[0082] If the waiting time is not greater than a preset timeout threshold, the first feedback data is used as the execution result of the first instruction.

[0083] In certain embodiments of the present application, the maximum number of transmissions and the timeout threshold may be set by a technician in this field on the upper computer according to relevant communication specifications before the upper computer and the lower computer communicate, or may be set by a technician in this field on the upper computer according to actual communication scenarios or relevant communication implementation experience. The preferred value of the maximum number of transmissions is 3 times, and the preferred value of the timeout threshold is 3000ms.

[0084] It should be understood that the current round sending timestamp and the sending timestamp are two different timestamp attributes of the first instruction. The current round sending timestamp is the timestamp of resending the first instruction within the current round corresponding to the number of times the first instruction is sent when the first instruction is resent after the waiting time exceeds the timeout threshold; the sending timestamp is the timestamp corresponding to the first time the first instruction is sent.

[0085] The present application first obtains the waiting time according to the timestamps of the first instruction and the first feedback data when the number of times the first instruction is sent does not exceed the maximum number of times, and then obtains the execution result of the first instruction when the waiting time is not greater than the timeout threshold. This can avoid the instruction error response caused by the instruction transmission timeout caused by network delay, thereby avoiding response confusion.

[0086] In some embodiments of the present application, after obtaining the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data, the method further includes:

[0087] If the waiting time is greater than the timeout threshold, the first instruction is placed at the beginning of the current instruction queue to resend the first instruction, and the number of times the first instruction is sent is updated.

[0088] When the waiting time is greater than the timeout threshold, the present application resends the first instruction and updates the number of transmissions, and can provide a retry capability for the host computer when it is determined that the instruction has timed out, thereby improving the system's responsiveness and communication reliability.

[0089] In some embodiments of the present application, before obtaining the first instruction to be sent, the method further includes:

[0090] When the number of times the first instruction is sent is greater than the maximum number of times, a combination of a preset default result and the first instruction is used as the execution result of the first instruction.

[0091] In certain implementations of the present application, the default result may be set by a person skilled in the art according to the current communication task, or may be set by a person skilled in the art according to relevant communication specifications. This is common knowledge in the art, and the present application does not make corresponding limitations here.

[0092] When the number of times the first instruction is sent is greater than the maximum number of times, the present application combines the default result and the first instruction as the execution result of the first instruction, which can avoid reduced efficiency due to excessive retries, ensure the responsiveness of the system, and improve communication reliability.

[0093] The present application first obtains the first instruction to be sent through the current instruction queue, then sends the first instruction to the lower computer when the first instruction is not empty, and receives the first feedback data returned by the lower computer after executing the first instruction. The orderliness of the lower computer processing instructions is ensured through the instruction queue, which can reduce the response delay or response error caused by insufficient processing capacity of the lower computer, thereby improving the overall processing efficiency and communication stability; and then the integrity of the first feedback data is checked to obtain a first check result, which can timely detect data damage and loss in transmission through the data integrity check, avoid useless parsing of incomplete data, further improve the instruction processing efficiency and communication stability, and only parse the first feedback data to obtain the first feedback instruction when the first check result meets the integrity standard, and only obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction, which can ensure that the first feedback data returned by the lower computer corresponds to the first instruction currently sent to the lower computer through the strict correspondence between the first feedback instruction and the first instruction, eliminate response confusion, and improve response stability and reliability.

[0094] Corresponding to the previous method, see Figure 2 , the embodiment of the present application provides a serial communication instruction processing device, including an instruction acquisition module 210, an instruction sending module 220, a feedback verification module 230, a feedback parsing module 240 and a result acquisition module 250;

[0095] The instruction acquisition module 210 is used to acquire a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue;

[0096] The instruction sending module 220 is used to send the first instruction to the lower computer when the first instruction is not empty, and receive the first feedback data returned by the lower computer when the first instruction is executed;

[0097] The feedback verification module 230 is used to perform integrity verification on the first feedback data to obtain a first verification result;

[0098] The feedback parsing module 240 is configured to parse the first feedback data to obtain a first feedback instruction when the first verification result meets a preset integrity standard;

[0099] The result acquisition module 250 is used to obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction.

[0100] In certain embodiments of the present application, the instruction sending module 220 includes a feedback receiving submodule; the feedback receiving submodule includes a window acquisition unit and a byte combination unit;

[0101] The window collection unit is used to open a first receiving window according to preset window parameters, and collect a feedback byte stream returned by the lower computer when executing the first instruction through the first receiving window;

[0102] The byte combination unit is used to combine all bytes in the feedback byte stream to obtain first feedback data, clear the feedback byte stream and stop collecting when a preset end identifier appears in the feedback byte stream.

[0103] In certain embodiments of the present application, the feedback verification module 230 includes a data re-collection submodule;

[0104] The data re-collection submodule is used to discard the first feedback data and issue a first re-collection instruction to enable the first receiving window to re-collect the feedback byte stream when the first verification result does not meet the integrity standard.

[0105] In certain embodiments of the present application, the result acquisition module 250 includes a waiting time acquisition submodule and an execution result acquisition submodule;

[0106] The waiting time acquisition submodule is used to obtain the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data when the sending timestamp of the first instruction is not greater than the preset maximum sending timestamp;

[0107] The execution result acquisition submodule is used to use the first feedback data as the execution result of the first instruction if the waiting time is not greater than a preset timeout threshold.

[0108] In certain embodiments of the present application, the result acquisition module 250 includes an instruction resending submodule;

[0109] The instruction resending submodule is used for placing the first instruction at the beginning of the current instruction queue to resend the first instruction if the waiting time is greater than the timeout threshold, and updating the number of times the first instruction is sent.

[0110] In some embodiments of the present application, a default result acquisition module is also included;

[0111] The default result acquisition module is used to use a combination of a preset default result and the first instruction as the execution result of the first instruction when the number of times the first instruction is sent is greater than the maximum number of times.

[0112] The present application first obtains the first instruction to be sent through the current instruction queue, then sends the first instruction to the lower computer when the first instruction is not empty, and receives the first feedback data returned by the lower computer after executing the first instruction. The orderliness of the lower computer processing instructions is ensured through the instruction queue, which can reduce the response delay or response error caused by insufficient processing capacity of the lower computer, thereby improving the overall processing efficiency and communication stability; and then the integrity of the first feedback data is checked to obtain a first check result, which can timely detect data damage and loss in transmission through the data integrity check, avoid useless parsing of incomplete data, further improve the instruction processing efficiency and communication stability, and only parse the first feedback data to obtain the first feedback instruction when the first check result meets the integrity standard, and only obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction, which can ensure that the first feedback data returned by the lower computer corresponds to the first instruction currently sent to the lower computer through the strict correspondence between the first feedback instruction and the first instruction, eliminate response confusion, and improve response stability and reliability.

[0113] It should be understood that the device provided in the embodiments of the present application corresponds to the aforementioned method, and a serial communication instruction processing device provided in the embodiments of the present application can implement a serial communication instruction processing method provided in any embodiment of the present application.

[0114] Adaptively, the embodiments of the present application also provide a computer device and a computer-readable storage medium.

[0115] The computer device comprises: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor;

[0116] Wherein, when the processor executes the computer program, a serial communication instruction processing method of the present application is implemented.

[0117] The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute a serial communication instruction processing method of the present application.

[0118] The above are some implementation methods of the present application, and the purpose, technical scheme and beneficial effects of the present application are further described in detail. It should be clear that the above-mentioned partial implementation methods of the present application cannot be understood as limiting the present application. It is particularly pointed out that for those skilled in the art, any changes, modifications, equivalent substitutions and variations made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A serial communication instruction processing method, characterized in that: include: Obtaining a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue; When the first instruction is not empty, sending the first instruction to the lower computer, and receiving first feedback data returned by the lower computer when executing the first instruction; Performing integrity check on the first feedback data to obtain a first check result; When the first verification result meets the preset integrity standard, parsing the first feedback data to obtain a first feedback instruction; When the first feedback instruction is consistent with the first instruction, the execution result of the first instruction is obtained according to the first feedback data.

2. A serial communication instruction processing method according to claim 1, characterized in that: The receiving of the first feedback data returned by the lower computer when the lower computer executes the first instruction specifically includes: Opening a first receiving window according to preset window parameters, and collecting, through the first receiving window, a feedback byte stream returned by the lower computer when executing the first instruction; When a preset end identifier appears in the feedback byte stream, all bytes in the feedback byte stream are combined to obtain first feedback data, the feedback byte stream is cleared and collection is stopped.

3. A serial communication instruction processing method according to claim 2, characterized in that: Also includes: When the first verification result does not meet the integrity standard, the first feedback data is discarded, and a first re-collection instruction is issued to enable the first receiving window to re-collect the feedback byte stream.

4. A serial communication instruction processing method according to claim 1, characterized in that: The obtaining the execution result of the first instruction according to the first feedback data specifically includes: When the number of times the first instruction is sent is not greater than a preset maximum number of times, obtaining a waiting time according to a sending timestamp of the first instruction and a feedback timestamp of the first feedback data; If the waiting time is not greater than a preset timeout threshold, the first feedback data is used as the execution result of the first instruction.

5. A serial communication instruction processing method according to claim 4, characterized in that: After obtaining the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data, the method further includes: If the waiting time is greater than the timeout threshold, the first instruction is placed at the beginning of the current instruction queue to resend the first instruction, and the number of times the first instruction is sent is updated.

6. A serial communication instruction processing method according to claim 4, characterized in that: Before obtaining the first instruction to be sent, the method further includes: When the number of times the first instruction is sent is greater than the maximum number of times, a combination of a preset default result and the first instruction is used as the execution result of the first instruction.

7. A serial communication instruction processing device, characterized in that: It includes an instruction acquisition module, an instruction sending module, a feedback verification module, a feedback parsing module and a result acquisition module; The instruction acquisition module is used to acquire a first instruction to be sent; wherein the first instruction is the first instruction at the beginning of the current instruction queue; The instruction sending module is used for sending the first instruction to the lower computer when the first instruction is not empty, and receiving the first feedback data returned by the lower computer when the first instruction is executed; The feedback verification module is used to perform integrity verification on the first feedback data to obtain a first verification result; The feedback parsing module is configured to parse the first feedback data to obtain a first feedback instruction when the first verification result meets a preset integrity standard; The result acquisition module is used to obtain the execution result of the first instruction according to the first feedback data when the first feedback instruction is consistent with the first instruction.

8. A serial communication instruction processing device according to claim 7, characterized in that: The instruction sending module includes a feedback receiving submodule; the feedback receiving submodule includes a window acquisition unit and a byte combination unit; The window collection unit is used to open a first receiving window according to preset window parameters, and collect a feedback byte stream returned by the lower computer when executing the first instruction through the first receiving window; The byte combination unit is used to combine all bytes in the feedback byte stream to obtain first feedback data, clear the feedback byte stream and stop collecting when a preset end identifier appears in the feedback byte stream.

9. A serial communication instruction processing device according to claim 8, characterized in that: The feedback verification module includes a data re-collection submodule; The data re-collection submodule is used to discard the first feedback data and issue a first re-collection instruction to enable the first receiving window to re-collect the feedback byte stream when the first verification result does not meet the integrity standard.

10. A serial communication instruction processing device according to claim 7, characterized in that: The result acquisition module includes a waiting time acquisition submodule and an execution result acquisition submodule; The waiting time acquisition submodule is used to obtain the waiting time according to the sending timestamp of the first instruction and the feedback timestamp of the first feedback data when the sending timestamp of the first instruction is not greater than the preset maximum sending timestamp; The execution result acquisition submodule is used to use the first feedback data as the execution result of the first instruction if the waiting time is not greater than a preset timeout threshold.

11. A serial communication instruction processing device according to claim 10, characterized in that: The result acquisition module includes an instruction resending submodule; The instruction resending submodule is used for placing the first instruction at the beginning of the current instruction queue to resend the first instruction if the waiting time is greater than the timeout threshold, and updating the number of times the first instruction is sent.

12. A serial communication instruction processing device according to claim 10, characterized in that: Also includes a default result acquisition module; The default result acquisition module is used to use a combination of a preset default result and the first instruction as the execution result of the first instruction when the number of times the first instruction is sent is greater than the maximum number of times.