Serial port instruction transmission method and device, electronic equipment and storage medium

By using the dual guarantee mechanism of timeout timing function and polling delay timing function in serial port transmission, the problems of packet loss and code error in serial port transmission are solved, the stability and reliability of the serial port are improved, and efficient instruction transmission is achieved .

CN119271605APending Publication Date: 2025-01-07GUANGZHOU DCOLOUR OPTOELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411302448.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

During the serial port transmission process, packet loss, code error, and transmission and reception conflicts often occur, resulting in polling delay and response timeout, affecting the stability and reliability of the serial port and inefficient transmission efficiency.

Method used

The timeout timing function and the polling delay timing function provide double guarantees for instruction transmission, ensuring the safe and stable transmission of instructions, including obtaining the instructions to be transmitted, filling the sending queue, triggering the timeout timing function and polling delay timing function, ensuring the instruction's Normal sending and receiving.

Benefits of technology

It realizes efficient and fast transmission of serial port instructions, improves the stability and reliability of the serial port, avoids mistransmission and packet loss, and improves transmission efficiency and usage efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271605A_ABST
    Figure CN119271605A_ABST
Patent Text Reader

Abstract

The invention provides a serial port instruction transmission method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a to-be-transmitted serial port instruction; filling the serial port instruction to be transmitted into a sending queue through a first function to obtain a transmission queue; sending a first instruction of the transmission queue according to a first parameter, and triggering an overtime timing function at the same time; obtaining a response instruction according to the triggered timeout timing function; when the response instruction exists, triggering a polling delay timing function; and sending residual instructions of the transmission queue according to the triggered polling delay timing function. By implementing the application, the serial port instruction can be efficiently and quickly transmitted, the secure transmission of data is realized, the conditions of wrong transmission, packet loss and the like are not easy to occur, the stability and reliability of the serial port can be improved, the use efficiency of the serial port can be improved, and the serial port can be better controlled.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of serial port transmission technology, and in particular to a serial port instruction transmission method, device, electronic device and storage medium. Background Art

[0002] During the transmission of commands over the serial port, packet loss, bit errors, and conflicts between sending and receiving often occur. The existence of these situations will lead to problems such as polling delays and response timeouts. As a result, the serial port transmission cannot achieve stable transmission, resulting in poor stability and reliability of the serial port, low transmission efficiency, and prone to mistransmission and data loss during the transmission process, which seriously affects the use of the serial port and brings many inconveniences to users.

[0003] However, in the process of solving the above problems, the prior art cannot achieve timing control of serial port transmission. Although the stability of the serial port can be improved and data can be transmitted normally, the timing problem of serial port transmission cannot be effectively controlled, and serial port transmission disorder is prone to occur. Summary of the invention

[0004] The purpose of the present application is to provide a serial port command transmission method, device, electronic device and storage medium, which can efficiently and quickly transmit serial port commands, realize secure data transmission, and is less likely to cause mistransmission, packet loss and the like. It can improve the stability and reliability of the serial port, improve the efficiency of the serial port, and better control the serial port.

[0005] In a first aspect, an embodiment of the present application provides a serial port instruction transmission method, the method comprising:

[0006] Get the serial port command to be transmitted;

[0007] Filling the serial port instruction to be transmitted into the sending queue through the first function to obtain a transmission queue;

[0008] Sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function at the same time;

[0009] Obtain a response instruction according to the timeout timing function after triggering;

[0010] When the response instruction exists, trigger the polling delay timing function;

[0011] The remaining instructions of the transmission queue are sent according to the triggered polling delay timing function.

[0012] In the above implementation process, the timeout timing function and the polling delay timing function are used to provide doubly guarantee for the instruction transmission, ensuring the safe and stable transmission of the instructions. The serial port instructions can be transmitted efficiently and quickly, and the safe transmission of data can be achieved. It is not easy to have mistransmission, packet loss, etc., which can improve the stability and reliability of the serial port, improve the efficiency of the serial port, and better control the serial port.

[0013] Furthermore, the step of sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function at the same time includes:

[0014] When the value of the first parameter is empty, the serial port instruction sending signal is triggered, the first instruction is sent to the serial port according to the callback function, and the timeout timing function is triggered at the same time.

[0015] In the above implementation process, when the value of the first parameter is empty, it indicates that the serial port command can be sent normally. Sending the first command to the serial port according to the callback function can ensure the normal sending of the command and avoid data loss.

[0016] Furthermore, the step of sending the first instruction to the serial port according to the callback function includes:

[0017] Get the initial callback function;

[0018] Initializing the sending parameters in the initial callback function and configuring the transmission information of the initial callback function to obtain the callback function;

[0019] The first instruction is filled into the first parameter, and the filled first parameter is sent to the serial port through the callback function.

[0020] In the above implementation process, sending instructions according to the configured callback function can improve the transmission speed and efficiency of the instructions, avoid the situation where the instructions are sent incorrectly during the transmission process, and improve the stability of the serial port transmission.

[0021] Furthermore, when the response instruction exists, the step of triggering the polling delay timing function includes:

[0022] Get the data packet;

[0023] Verifying the data packet to determine whether the message data in the data packet is correct;

[0024] If so, extract valid data from the message data to trigger a polling delay timing function.

[0025] In the above implementation process, the reliability of serial port transmission can be improved, the accuracy of data can be ensured, and only valid data is extracted for transmission, which can effectively reduce the occupation of serial port resources during the transmission process.

[0026] Furthermore, before the step of sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function, the step further includes:

[0027] Reset the timeout timing function and obtain the reset count.

[0028] In the above implementation process, resetting the timeout timing function can strictly record the number of timeouts in the serial port transmission process, ensure the effective transmission of data, and reasonably and effectively control the transmission time and waiting time.

[0029] Furthermore, after the step of obtaining a response instruction according to the triggered timeout timing function, the method further includes:

[0030] If the response instruction does not exist, determine whether the response time has timed out;

[0031] If so, determine whether the reset times exceed a first threshold value, if the reset times do not exceed the first threshold value, re-obtain a response instruction, if the reset times exceed the first threshold value, suspend instruction transmission.

[0032] In the above implementation process, when the response instruction does not exist, it is further determined whether the response time has timed out, and the instruction transmission can be performed while ensuring that the response instruction can be received normally, thereby improving the instruction transmission efficiency and avoiding the inability to receive instructions for a long time.

[0033] Furthermore, the step of sending the remaining instructions of the transmission queue according to the triggered polling delay timing function includes:

[0034] Reset the polling delay timing function after triggering to obtain the polling delay timing;

[0035] When the polling delay time exceeds a second threshold, the second instruction in the transmission queue is sent, and so on, the remaining instructions in the transmission queue are sent.

[0036] In the above implementation process, resetting the polling delay timing function after triggering and then resending the remaining instructions can ensure that each instruction sent is effective, and can improve the transmission efficiency of each instruction transmission, avoiding each instruction transmission time being too long and affecting the use of the serial port.

[0037] In a second aspect, an embodiment of the present application further provides a serial port instruction transmission device, the device comprising:

[0038] An acquisition module, used for acquiring serial port instructions to be transmitted;

[0039] A filling module, used for filling the serial port instruction to be transmitted into the sending queue through the first function to obtain a transmission queue;

[0040] A trigger module, used to send the first instruction of the transmission queue according to the first parameter and trigger the timeout timing function at the same time; and also used to trigger the polling delay timing function when the response instruction exists;

[0041] A data acquisition module is used to obtain a response instruction according to a timeout timing function after being triggered;

[0042] The sending module is used to send the remaining instructions of the transmission queue according to the polling delay timing function after being triggered.

[0043] In the above implementation process, the timeout timing function and the polling delay timing function are used to provide doubly guarantee for the instruction transmission, ensuring the safe and stable transmission of the instructions. The serial port instructions can be transmitted efficiently and quickly, and the safe transmission of data can be achieved. It is not easy to have mistransmission, packet loss, etc., which can improve the stability and reliability of the serial port, improve the efficiency of the serial port, and better control the serial port.

[0044] 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.

[0045] 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.

[0046] 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.

[0047] 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.

[0048] 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

[0049] 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.

[0050] Figure 1 A flowchart of a serial port command transmission method provided in an embodiment of the present application;

[0051] Figure 2 A schematic diagram of the structure of a serial port command transmission device provided in an embodiment of the present application;

[0052] Figure 3 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] 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.

[0054] 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.

[0055] 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.

[0056] Embodiment 1

[0057] Figure 1 is a flow chart of the serial port command transmission method provided in the embodiment of the present application, such as Figure 1 As shown, the method includes:

[0058] S1, obtain the serial port command to be transmitted;

[0059] S2, filling the serial port command to be transmitted into the sending queue through the first function to obtain a transmission queue;

[0060] S3, sending the first instruction of the transmission queue according to the first parameter, and triggering the timeout timing function at the same time;

[0061] S4, obtaining a response instruction according to the timeout timing function after triggering;

[0062] S5, when the response instruction exists, the polling delay timing function is triggered;

[0063] S6, sending the remaining instructions of the transmission queue according to the triggered polling delay timing function.

[0064] In the above implementation process, the timeout timing function and the polling delay timing function are used to provide doubly guarantee for the instruction transmission, ensuring the safe and stable transmission of the instructions. The serial port instructions can be transmitted efficiently and quickly, and the safe transmission of data can be achieved. It is not easy to have mistransmission, packet loss, etc., which can improve the stability and reliability of the serial port, improve the efficiency of the serial port, and better control the serial port.

[0065] The embodiment of the present application caches the instructions to be sent through a first-in-first-out queue structure. By first sending an instruction and waiting for the lower computer to reply, and then waiting for a preset polling delay time to send the next package of instructions, the time for sending instructions can be accurately controlled, giving the lower computer sufficient processing time to ensure that the lower computer receives and responds normally.

[0066] In S2, the embodiment of the present application pushes the instruction into the transmission queue through the first function (List.pushBack).

[0067] Furthermore, S3 includes:

[0068] When the value of the first parameter is empty, the serial port command sending signal is triggered, the first command is sent to the serial port according to the callback function, and the timeout timing function is triggered at the same time.

[0069] In the above implementation process, when the value of the first parameter is empty, it indicates that the serial port command can be sent normally. Sending the first command to the serial port according to the callback function can ensure the normal sending of the command and avoid data loss.

[0070] By judging whether the first parameter (cmd_currunt) is empty, it can be judged that no instruction is currently being issued. If no instruction is being issued, the first instruction in the queue is immediately sent. In the embodiment of the present application, List.popFront is used to extract the first instruction and give it to the first parameter.

[0071] Furthermore, the step of sending the first instruction to the serial port according to the callback function includes:

[0072] Get the initial callback function;

[0073] Initialize the sending parameters in the initial callback function, and configure the transmission information of the initial callback function to obtain the callback function;

[0074] Fill the first instruction into the first parameter, and send the filled first parameter to the serial port through the callback function.

[0075] In the above implementation process, sending instructions according to the configured callback function can improve the transmission speed and efficiency of the instructions, avoid the situation where the instructions are sent incorrectly during the transmission process, and improve the stability of the serial port transmission.

[0076] The embodiment of the present application sends the function code that needs to be sent to the instruction and received to the serial port through the callback function, which is achieved by configuring the callback function and the number of retransmissions.

[0077] Initialize the configuration transmission information (including generation information, reception information, and debugging information) through the initial callback function. Fill the currently extracted instruction with the first parameter and give it to the callback function to be sent, and send the instruction to the serial port through the send_cb function in the callback function mb_set_callback (send_cb, resp_cb, log_cb) that is initialized and set.

[0078] In S4, the timeout timing function (start_timer) is used to immediately restart the timing.

[0079] Furthermore, S5 includes:

[0080] Get the data packet;

[0081] Verify the data packet to determine whether the message data in the data packet is correct;

[0082] If so, extract the valid data in the message data to trigger the polling delay timing function.

[0083] In the above implementation process, the reliability of serial port transmission can be improved to ensure the accuracy of data. At the same time, only valid data is extracted for transmission, which can effectively reduce the occupation of serial port resources during transmission. After sending, the timer function of the response timeout is reset through stop_timer (mbCustomTimer._00_mb_timeout).

[0084] When there is a response instruction, it enters the data packet (on_mb_recv_data) to check whether the message data (including frame header and length) is correct. If it is a legal instruction, it takes out the valid data to process the business logic.

[0085] Furthermore, before the step of sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function, the method further includes:

[0086] Reset the timeout timing function and get the reset count.

[0087] In the above implementation process, resetting the timeout timing function can strictly record the number of timeouts in the serial port transmission process, ensure the effective transmission of data, and reasonably and effectively control the transmission time and waiting time.

[0088] If the response command is not received within the timeout period, the reset timeout timing function is entered, and whether to resend the command is determined based on the number of resends. After processing, the polling delay timing function needs to be reset once.

[0089] If packet loss or bit error occurs during the transmission process, resulting in the lower computer being unable to receive the correct command from the upper computer, the lower computer will not reply with the response command. The upper computer will wait for a timeout period if it does not receive the correct response command. When the timeout period arrives, it will resend the previous command until it receives the correct response from the lower computer before continuing to send the next one. This can improve the stability and reliability of the serial port and achieve stable and reliable serial port command transmission.

[0090] Further, after the step of obtaining a response instruction according to the triggered timeout timing function, the method further includes:

[0091] If the response instruction does not exist, determine whether the response time has timed out;

[0092] If so, determine whether the number of reset times exceeds a first threshold value, if the number of reset times does not exceed the first threshold value, re-obtain a response instruction, if the number of reset times exceeds the first threshold value, suspend instruction transmission.

[0093] In the above implementation process, when the response instruction does not exist, it is further determined whether the response time has timed out, and the instruction transmission can be performed while ensuring that the response instruction can be received normally, thereby improving the instruction transmission efficiency and avoiding the inability to receive instructions for a long time.

[0094] The first threshold in the embodiment of the present application is 10ms.

[0095] Furthermore, S6 includes:

[0096] Reset the polling delay timing function after triggering to obtain the polling delay timing;

[0097] When the polling delay timer exceeds the second threshold, the second instruction in the transmission queue is sent, and so on, the remaining instructions in the transmission queue are sent.

[0098] In the above implementation process, resetting the polling delay timing function after triggering and then resending the remaining instructions can ensure that each instruction sent is effective, and can improve the transmission efficiency of each instruction transmission, avoiding each instruction transmission time being too long and affecting the use of the serial port.

[0099] After the timing of the polling delay timing function is restarted, the next instruction is taken out from the queue and sent after the polling delay timing exceeds the second threshold.

[0100] The above is a complete instruction cycle. By executing it in a loop, the remaining instructions in the queue can be transmitted in sequence to achieve stable and reliable transmission.

[0101] Embodiment 2

[0102] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a serial port instruction transmission device is provided below, such as Figure 2 As shown, the device comprises:

[0103] Acquisition module 1, used for acquiring serial port instructions to be transmitted;

[0104] Filling module 2, used for filling the serial port instruction to be transmitted into the sending queue through the first function to obtain a transmission queue;

[0105] A trigger module 3, used for sending the first instruction of the transmission queue according to the first parameter, and triggering the timeout timing function at the same time; and also used for triggering the polling delay timing function when the response instruction exists;

[0106] The data acquisition module 4 is used to obtain a response instruction according to the timeout timing function after triggering;

[0107] The sending module 5 is used to send the remaining instructions of the transmission queue according to the triggered polling delay timing function.

[0108] In the above implementation process, the timeout timing function and the polling delay timing function are used to provide doubly guarantee for the instruction transmission, ensuring the safe and stable transmission of the instructions. The serial port instructions can be transmitted efficiently and quickly, and the safe transmission of data can be achieved. It is not easy to have mistransmission, packet loss, etc., which can improve the stability and reliability of the serial port, improve the efficiency of the serial port, and better control the serial port.

[0109] Furthermore, the trigger module 3 is also used for:

[0110] When the value of the first parameter is empty, the serial port command sending signal is triggered, the first command is sent to the serial port according to the callback function, and the timeout timing function is triggered at the same time.

[0111] In the above implementation process, when the value of the first parameter is empty, it indicates that the serial port command can be sent normally. Sending the first command to the serial port according to the callback function can ensure the normal sending of the command and avoid data loss.

[0112] Furthermore, the trigger module 3 is also used for:

[0113] Get the initial callback function;

[0114] Initialize the sending parameters in the initial callback function, configure the transmission information of the initial callback function, and obtain the callback function;

[0115] Fill the first instruction into the first parameter, and send the filled first parameter to the serial port through the callback function.

[0116] In the above implementation process, sending instructions according to the configured callback function can improve the transmission speed and efficiency of the instructions, avoid the situation where the instructions are sent incorrectly during the transmission process, and improve the stability of the serial port transmission.

[0117] Furthermore, the trigger module 3 is also used for:

[0118] Get the data packet;

[0119] Verify the data packet to determine whether the message data in the data packet is correct;

[0120] If so, extract the valid data in the message data to trigger the polling delay timing function.

[0121] In the above implementation process, the reliability of serial port transmission can be improved, the accuracy of data can be ensured, and only valid data is extracted for transmission, which can effectively reduce the occupation of serial port resources during the transmission process.

[0122] Furthermore, the device also includes a reset module, which is used to:

[0123] Reset the timeout timing function and get the reset count.

[0124] In the above implementation process, resetting the timeout timing function can strictly record the number of timeouts in the serial port transmission process, ensure the effective transmission of data, and reasonably and effectively control the transmission time and waiting time.

[0125] Furthermore, the data acquisition module 4 is also used for:

[0126] If the response instruction does not exist, determine whether the response time has timed out;

[0127] If so, determine whether the number of reset times exceeds a first threshold value, if the number of reset times does not exceed the first threshold value, re-obtain a response instruction, if the number of reset times exceeds the first threshold value, suspend instruction transmission.

[0128] In the above implementation process, when the response instruction does not exist, it is further determined whether the response time has timed out, and the instruction transmission can be performed while ensuring that the response instruction can be received normally, thereby improving the instruction transmission efficiency and avoiding the inability to receive instructions for a long time.

[0129] Furthermore, the sending module 5 is also used for:

[0130] Reset the polling delay timing function after triggering to obtain the polling delay timing;

[0131] When the polling delay timer exceeds the second threshold, the second instruction in the transmission queue is sent, and so on, the remaining instructions in the transmission queue are sent.

[0132] In the above implementation process, resetting the polling delay timing function after triggering and then resending the remaining instructions can ensure that each instruction sent is effective, and can improve the transmission efficiency of each instruction transmission, avoiding each instruction transmission time being too long and affecting the use of the serial port.

[0133] The above serial port command transmission 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.

[0134] 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.

[0135] Embodiment 3

[0136] 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 serial port instruction transmission method of the first embodiment.

[0137] Optionally, the above-mentioned electronic device may be a server.

[0138] 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.

[0139] 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.

[0140] 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.

[0141] 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.

[0142] 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.

[0143] 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.

[0144] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which implements the serial port instruction transmission method of embodiment 1 when executed by a processor.

[0145] 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.

[0146] 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.

[0147] 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.

[0148] 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.

[0149] 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.

[0150] 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.

[0151] 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 serial port command transmission method, characterized in that: The method comprises: Get the serial port command to be transmitted; Filling the serial port instruction to be transmitted into the sending queue through the first function to obtain a transmission queue; Sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function at the same time; Obtain a response instruction according to the timeout timing function after triggering; When the response instruction exists, trigger the polling delay timing function; The remaining instructions of the transmission queue are sent according to the triggered polling delay timing function.

2. The serial port command transmission method according to claim 1, characterized in that: The step of sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function at the same time includes: When the value of the first parameter is empty, the serial port instruction sending signal is triggered, the first instruction is sent to the serial port according to the callback function, and the timeout timing function is triggered at the same time.

3. The serial port command transmission method according to claim 2, characterized in that: The step of sending the first instruction to the serial port according to the callback function includes: Get the initial callback function; Initializing the sending parameters in the initial callback function and configuring the transmission information of the initial callback function to obtain the callback function; The first instruction is filled into the first parameter, and the filled first parameter is sent to the serial port through the callback function.

4. The serial port command transmission method according to claim 1, characterized in that: The step of triggering the polling delay timing function when the response instruction exists includes: Get the data packet; Verifying the data packet to determine whether the message data in the data packet is correct; If so, extract valid data from the message data to trigger a polling delay timing function.

5. The serial port command transmission method according to claim 1, characterized in that: Before the step of sending the first instruction of the transmission queue according to the first parameter and triggering the timeout timing function, the method further includes: Reset the timeout timing function and obtain the reset count.

6. The serial port command transmission method according to claim 5, characterized in that: After the step of obtaining a response instruction according to the triggered timeout timing function, the method further includes: If the response instruction does not exist, determine whether the response time has timed out; If so, determine whether the reset times exceed a first threshold value, if the reset times do not exceed the first threshold value, re-obtain a response instruction, if the reset times exceed the first threshold value, suspend instruction transmission.

7. The serial port command transmission method according to claim 1, characterized in that: The step of sending the remaining instructions of the transmission queue according to the triggered polling delay timing function includes: Reset the polling delay timing function after triggering to obtain the polling delay timing; When the polling delay time exceeds a second threshold, the second instruction in the transmission queue is sent, and so on, the remaining instructions in the transmission queue are sent.

8. A serial port command transmission device, characterized in that: The device comprises: An acquisition module, used for acquiring serial port instructions to be transmitted; A filling module, used for filling the serial port instruction to be transmitted into the sending queue through the first function to obtain a transmission queue; A trigger module, used to send the first instruction of the transmission queue according to the first parameter and trigger the timeout timing function at the same time; and also used to trigger the polling delay timing function when the response instruction exists; A data acquisition module is used to obtain a response instruction according to a timeout timing function after being triggered; The sending module is used to send the remaining instructions of the transmission queue according to the polling delay timing function after being triggered.

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 execute the serial port instruction transmission method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: It stores a computer program, and when the computer program is executed by a processor, the serial port instruction transmission method as described in any one of claims 1 to 7 is implemented.