Serial port optimization method and device, electronic equipment and storage medium
By obtaining the serial port wake-up characters and responses, serial port optimization without the need for the serial port protocol is gradually realized, which solves the upgrade restrictions caused by protocol mismatch in the existing technology, and improves the upgrade convenience and efficiency of the serial port screen.
Patent Information
- Application Number
- CN202411051267.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-22
AI Technical Summary
In the existing serial port upgrade optimization technology, fixed format protocols limit the universality of the serial port protocol, resulting in the inability to respond in the case of protocol mismatch, limiting the upgrade optimization method, especially inconvenient in many application scenarios.
By obtaining the serial port wake-up characters, starting the download mode, gradually obtaining the target characters according to the serial port configuration characters and packet response, realizing serial port optimization without the need for the serial port protocol, it is suitable for a variety of application scenarios and provides convenient upgrade and optimization methods.
It realizes serial port optimization without the need for serial port protocol, is suitable for a variety of application scenarios, improves the convenience and efficiency of upgrade and optimization of serial port screens, and ensures the accuracy and security of data transmission.
Smart Images

Figure CN119003426A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of serial port screen technology, and more specifically, to a serial port optimization method, device, electronic device and storage medium. Background Art
[0002] The serial port screen is a display screen with serial port communication function. It consists of a module that integrates a display control chip and a serial port communication chip. It can communicate with other devices (such as microcontrollers, single-chip microcomputers, computers, etc.) through the serial port to display data on the screen. The upgrade and optimization of the serial port screen is usually achieved by updating software or hardware, which can provide more functional options, fix vulnerabilities, and improve performance.
[0003] However, in the existing serial port upgrade optimization technology, a fixed protocol format is usually preset in the software. The lower computer wakes up the serial port screen and enters the download mode by sending fixed-format message data. This is the premise for successful downloading. It is not necessary to understand the built-in protocol format of the screen before downloading. This method is extremely demanding in some application scenarios. When the serial port protocol is different from the fixed-format command sent, it cannot respond. The non-universality of the serial port protocol greatly limits the upgrade and optimization methods of the serial port. Summary of the invention
[0004] The purpose of this application is to provide a serial port optimization method, device, electronic device and storage medium, which can implement a serial port optimization method without a serial port protocol, provide more convenience for serial port upgrade optimization, be suitable for a variety of application scenarios, and also provide more convenience for the use of serial port screens.
[0005] In a first aspect, an embodiment of the present application provides a serial port optimization method, the method comprising:
[0006] Get the serial port wake-up character;
[0007] Start the download mode according to the serial port wake-up character;
[0008] In download mode, get the first serial port screen response according to the serial port configuration characters;
[0009] Start the data receiving mode according to the first serial port screen response;
[0010] In data receiving mode, the second serial port screen response is obtained according to the data packet;
[0011] The target character is obtained according to the response of the second serial port screen, and the serial port optimization is successful.
[0012] In the above implementation process, the serial port screen response is obtained in the download mode and the receiving mode in turn according to the serial port wake-up character, and then the target character is obtained to realize the serial port optimization. The serial port optimization method without the serial port protocol can be realized, which provides more convenience for the upgrade and optimization of the serial port, is suitable for a variety of application scenarios, and also provides more convenience for the use of the serial port screen.
[0013] Furthermore, the step of starting the download mode according to the serial port wake-up character includes:
[0014] Determining whether the serial port wake-up character meets a first preset requirement;
[0015] If not, detect the host sending character, communication level and baud rate to obtain a new serial port wake-up character;
[0016] If yes, start download mode.
[0017] In the above implementation process, when the serial port wake-up character meets the first preset requirement, the download mode is started. When it does not meet the first preset requirement, the host sends the character, communication level and baud rate to ensure the accuracy and security of the data, providing basic support for subsequent serial port optimization.
[0018] Furthermore, the step of obtaining a first serial port screen response according to the serial port configuration character includes:
[0019] Extracting the temporary baud rate in the serial port configuration character;
[0020] Determine whether the current serial port screen response meets the second preset requirement according to the temporary baud rate;
[0021] If so, determine that the current serial port screen response is the first serial port screen response;
[0022] If not, the temporary baud rate is modified, and the first serial port screen response is obtained again according to the modified temporary baud rate.
[0023] In the above implementation process, it is determined whether the temporary baud rate in the serial port configuration character meets the second preset requirement. If it does not meet the second preset requirement, the temporary baud rate is modified in time to ensure that the modified temporary baud rate can meet the transmission requirements of the serial port and achieve serial port screen response.
[0024] Furthermore, before the step of modifying the temporary baud rate and re-obtaining the first serial port screen response according to the modified temporary baud rate, it also includes:
[0025] The serial port configuration character is sent after a first preset time delay.
[0026] In the above implementation process, delaying the sending of the serial port configuration characters for a certain period of time can ensure that the data buffered by the serial port has been completely transmitted, avoid data omission or untimely transmission, and improve the transmission efficiency of the serial port.
[0027] Furthermore, the step of obtaining a second serial port screen response according to the data packet includes:
[0028] Verifying the data packet to determine whether the data packet meets a third preset requirement;
[0029] If not, the data packet is inverted and filled to obtain a new data packet, and the second serial port screen response is obtained according to the new data packet;
[0030] If so, determine whether the current serial port screen response meets the fourth preset requirement. If the current serial port screen response meets the fourth preset requirement, determine that the current serial port screen response is the second serial port screen response. If the current serial port screen response does not meet the fourth preset requirement, detect the sequence number of the data packet to obtain a new data packet, and obtain the second serial port screen response according to the new data packet.
[0031] In the above implementation process, the data packet is checked, and when the data packet does not meet the third preset requirement, the data packet is promptly inverted and filled, so that the data packet can meet the response requirements of the serial port and avoid packet loss.
[0032] Furthermore, the step of detecting the sequence number of the data packet to obtain a new data packet includes:
[0033] Determine whether the response time of the current serial port screen response exceeds a first time threshold;
[0034] If so, determine whether the response time of the current serial port screen response exceeds the second time threshold, if the response time of the current serial port screen response exceeds the second time threshold, re-obtain the first serial port screen response, if the response time of the current serial port screen response does not exceed the second time threshold, detect the sequence number of the data packet to obtain a new data packet;
[0035] If not, the sequence number of the data packet is detected to obtain a new data packet.
[0036] In the above implementation process, when the response time of the current serial port screen response exceeds the first time threshold, the response time of the current serial port screen response is further detected to avoid the impact of the long response time of the current serial port screen response on the optimization of the serial port.
[0037] Furthermore, the step of obtaining the target character according to the second serial port screen response and the serial port optimization is successful includes:
[0038] If the target character is the first target character, the serial port optimization is successful;
[0039] If the target character is the second target character, the serial port is not optimized.
[0040] In the above implementation process, the serial port is optimized or not optimized according to different target characters, thereby improving the optimization efficiency and use efficiency of the serial port.
[0041] In a second aspect, an embodiment of the present application further provides a serial port optimization device, the device comprising:
[0042] The acquisition module is used to obtain the serial port wake-up character;
[0043] A startup module, used to start the download mode according to the serial port wake-up character; and also used to start the data receiving mode according to the first serial port screen response;
[0044] The data acquisition module is used to obtain the first serial port screen response according to the serial port configuration characters in the download mode; and is also used to obtain the second serial port screen response according to the data packet in the data receiving mode;
[0045] The optimization module is used to obtain the target character according to the second serial port screen response, and the serial port optimization is successful.
[0046] In the above implementation process, the serial port screen response is obtained in the download mode and the receiving mode in turn according to the serial port wake-up character, and then the target character is obtained to realize the serial port optimization. The serial port optimization method without the serial port protocol can be realized, which provides more convenience for the upgrade and optimization of the serial port, is suitable for a variety of application scenarios, and also provides more convenience for the use of the serial port screen.
[0047] 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.
[0048] 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.
[0049] 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.
[0050] 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.
[0051] 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
[0052] 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.
[0053] Figure 1 A flowchart of a serial port optimization method provided in an embodiment of the present application;
[0054] Figure 2 A schematic diagram of the structure of the serial port optimization device provided in the embodiment of the present application;
[0055] Figure 3 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] 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.
[0057] 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.
[0058] 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.
[0059] Embodiment 1
[0060] Figure 1 is a flow chart of the serial port optimization method provided in the embodiment of the present application, such as Figure 1 As shown, the method includes:
[0061] S1, get the serial port wake-up character;
[0062] S2, start the download mode according to the serial port wake-up character;
[0063] S3, in download mode, obtain the first serial port screen response according to the serial port configuration characters;
[0064] S4, start the data receiving mode according to the response of the first serial port screen;
[0065] S5, in data receiving mode, obtain the second serial port screen response according to the data packet;
[0066] S6, the target character is obtained according to the response of the second serial port screen, and the serial port optimization is successful.
[0067] In the above implementation process, the serial port screen response is obtained in the download mode and the receiving mode in turn according to the serial port wake-up character, and then the target character is obtained to realize the serial port optimization. The serial port optimization method without the serial port protocol can be realized, which provides more convenience for the upgrade and optimization of the serial port, is suitable for a variety of application scenarios, and also provides more convenience for the use of the serial port screen.
[0068] In S1, in the embodiment of the present application, the serial port wake-up character sent by the user is obtained by entering the download mode command: $cfgenter#.
[0069] Furthermore, S2 includes:
[0070] Determine whether the serial port wake-up character meets the first preset requirement;
[0071] If not, detect the host sending character, communication level and baud rate to obtain a new serial port wake-up character;
[0072] If yes, start download mode.
[0073] In the above implementation process, when the serial port wake-up character meets the first preset requirement, the download mode is started. When it does not meet the first preset requirement, the host sends the character, communication level and baud rate to ensure the accuracy and security of the data, providing basic support for subsequent serial port optimization.
[0074] Determine whether the screen responds to the character: $ok# ($ok# is the character of the first preset requirement). If it responds, start the download mode. If it does not respond, check whether the communication level and baud rate are consistent, and check whether the character sent by the host is $cfgenter#.
[0075] This application does not limit the protocol type, as long as the protocol content contains the characters $cfgenter#.
[0076] Furthermore, S3 includes:
[0077] Extract the temporary baud rate from the serial port configuration characters;
[0078] Determine whether the current serial port screen response meets the second preset requirement according to the temporary baud rate;
[0079] If so, determine that the current serial port screen response is the first serial port screen response;
[0080] If not, modify the temporary baud rate and regain the first serial port screen response based on the modified temporary baud rate.
[0081] In the above implementation process, it is determined whether the temporary baud rate in the serial port configuration character meets the second preset requirement. If it does not meet the second preset requirement, the temporary baud rate is modified in time to ensure that the modified temporary baud rate can meet the transmission requirements of the serial port and achieve serial port screen response.
[0082] Send serial port configuration characters: $file, [pathname], [size], [block], [baudrate]#, where [pathname] is the internal storage path of the screen, [size] is the file size in bytes, [block] is the data size of each packet of file transmission, in this application, select (512+4) or (1024+4) or (2048+4), [baudrate] is the temporary baud rate of the data transmission download package, and 0 means continuing to use the current baud rate without changing the temporary baud rate. The second preset requirement requires that the size, path, etc. of the serial port configuration characters meet the above requirements.
[0083] The first serial port screen responds: $ok#.
[0084] Furthermore, before the step of modifying the temporary baud rate and re-obtaining the first serial port screen response according to the modified temporary baud rate, it also includes:
[0085] Sending the serial port configuration character is delayed for a first preset time.
[0086] In the above implementation process, delaying the sending of the serial port configuration characters for a certain period of time can ensure that the data buffered by the serial port has been completely transmitted, avoid data omission or untimely transmission, and improve the transmission efficiency of the serial port.
[0087] Before modifying the baud rate, you need to confirm whether the serial port buffer data in the hardware has been sent. You can send it by delaying 10ms (the first preset time) to ensure that the serial port buffer data has been sent before sending the serial port configuration characters.
[0088] Furthermore, S5 includes:
[0089] Verifying the data packet to determine whether the data packet meets the third preset requirement;
[0090] If not, the data packet is inverted and filled to obtain a new data packet, and the second serial port screen response is obtained according to the new data packet;
[0091] If so, determine whether the current serial port screen response meets the fourth preset requirement. If the current serial port screen response meets the fourth preset requirement, determine that the current serial port screen response is the second serial port screen response. If the current serial port screen response does not meet the fourth preset requirement, detect the sequence number of the data packet to obtain a new data packet, and obtain the second serial port screen response based on the new data packet.
[0092] In the above implementation process, the data packet is checked, and when the data packet does not meet the third preset requirement, the data packet is promptly inverted and filled, so that the data packet can meet the response requirements of the serial port and avoid packet loss.
[0093] This application sends file data to the screen through a data packet, and the format of the data packet is: SN SNR DATACHECKSUM, where [SN] is the sequence number, 1 byte, [SNR] is the bitwise inversion of SN, 1 byte, [DATA] is valid data, 512, 1024, 2048 bytes are recommended, [CHECKSUM] is the checksum of the data packet, inverted, 2 bytes, that is, CHECKSUM = SN + SNR + DATA, then take the lower 16 bits and invert them.
[0094] If the data portion is not enough for a data packet, it needs to be filled with 0. The third preset requirement is that the format, content, size, etc. of the data packet must meet the above requirements.
[0095] The second serial port screen responds with: SN SNR. When the second serial port screen responds with SN SNR, it continues to send the next data packet until all data packets are sent.
[0096] Furthermore, the step of detecting the sequence number of the data packet to obtain a new data packet includes:
[0097] Determine whether the response time of the current serial port screen response exceeds the first time threshold;
[0098] If so, determine whether the response time of the current serial port screen response exceeds the second time threshold. If the response time of the current serial port screen response exceeds the second time threshold, re-obtain the first serial port screen response. If the response time of the current serial port screen response does not exceed the second time threshold, detect the sequence number of the data packet to obtain a new data packet.
[0099] If not, the sequence number of the data packet is checked to obtain a new data packet.
[0100] In the above implementation process, when the response time of the current serial port screen response exceeds the first time threshold, the response time of the current serial port screen response is further detected to avoid the impact of the long response time of the current serial port screen response on the optimization of the serial port.
[0101] In this application, the first time threshold is 200ms, and the second time threshold is 3s. If there is no response for more than 3s, the serial port wake-up character is obtained again to optimize the serial port. If a response is made after more than 200ms but not more than 3s, check whether SN and CHECKSUM are abnormal.
[0102] Furthermore, S6 includes:
[0103] If the target character is the first target character, the serial port optimization is successful;
[0104] If the target character is the second target character, the serial port is not optimized.
[0105] In the above implementation process, the serial port is optimized or not optimized according to different target characters, thereby improving the optimization efficiency and use efficiency of the serial port.
[0106] The first target character is: $reboot#, indicating that the serial port optimization is successful, and the second target character is $cfgexit#.
[0107] Embodiment 2
[0108] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a serial port optimization device is provided below, such as Figure 2 As shown, the device comprises:
[0109] Acquisition module 1, used to obtain the serial port wake-up character;
[0110] Startup module 2, used to start the download mode according to the serial port wake-up character; and also used to start the data receiving mode according to the first serial port screen response;
[0111] The data acquisition module 3 is used to obtain the first serial port screen response according to the serial port configuration characters in the download mode; and is also used to obtain the second serial port screen response according to the data packet in the data receiving mode;
[0112] The optimization module 4 is used to obtain the target character according to the second serial port screen response, and the serial port optimization is successful.
[0113] In the above implementation process, the serial port screen response is obtained in the download mode and the receiving mode in turn according to the serial port wake-up character, and then the target character is obtained to realize the serial port optimization. The serial port optimization method without the serial port protocol can be realized, which provides more convenience for the upgrade and optimization of the serial port, is suitable for a variety of application scenarios, and also provides more convenience for the use of the serial port screen.
[0114] Furthermore, the startup module 2 is also used for:
[0115] Determine whether the serial port wake-up character meets the first preset requirement;
[0116] If not, detect the host sending character, communication level and baud rate to obtain a new serial port wake-up character;
[0117] If yes, start download mode.
[0118] In the above implementation process, when the serial port wake-up character meets the first preset requirement, the download mode is started. When it does not meet the first preset requirement, the host sends the character, communication level and baud rate to ensure the accuracy and security of the data, providing basic support for subsequent serial port optimization.
[0119] Furthermore, the data acquisition module 3 is also used for:
[0120] Extract the temporary baud rate from the serial port configuration characters;
[0121] Determine whether the current serial port screen response meets the second preset requirement according to the temporary baud rate;
[0122] If so, determine that the current serial port screen response is the first serial port screen response;
[0123] If not, modify the temporary baud rate and regain the first serial port screen response based on the modified temporary baud rate.
[0124] In the above implementation process, it is determined whether the temporary baud rate in the serial port configuration character meets the second preset requirement. If it does not meet the second preset requirement, the temporary baud rate is modified in time to ensure that the modified temporary baud rate can meet the transmission requirements of the serial port and achieve serial port screen response.
[0125] Furthermore, the data acquisition module 3 is also used for:
[0126] The serial port configuration character is sent after a first preset time delay.
[0127] In the above implementation process, delaying the sending of the serial port configuration characters for a certain period of time can ensure that the data buffered by the serial port has been completely transmitted, avoid data omission or untimely transmission, and improve the transmission efficiency of the serial port.
[0128] Furthermore, the data acquisition module 3 is also used for:
[0129] Verifying the data packet to determine whether the data packet meets the third preset requirement;
[0130] If not, the data packet is inverted and filled to obtain a new data packet, and the second serial port screen response is obtained according to the new data packet;
[0131] If so, determine whether the current serial port screen response meets the fourth preset requirement. If the current serial port screen response meets the fourth preset requirement, determine that the current serial port screen response is the second serial port screen response. If the current serial port screen response does not meet the fourth preset requirement, detect the sequence number of the data packet to obtain a new data packet, and obtain the second serial port screen response based on the new data packet.
[0132] In the above implementation process, the data packet is checked, and when the data packet does not meet the third preset requirement, the data packet is promptly inverted and filled, so that the data packet can meet the response requirements of the serial port and avoid packet loss.
[0133] Furthermore, the data acquisition module 3 is also used for:
[0134] Determine whether the response time of the current serial port screen response exceeds the first time threshold;
[0135] If so, determine whether the response time of the current serial port screen response exceeds the second time threshold. If the response time of the current serial port screen response exceeds the second time threshold, re-obtain the first serial port screen response. If the response time of the current serial port screen response does not exceed the second time threshold, detect the sequence number of the data packet to obtain a new data packet.
[0136] If not, the sequence number of the data packet is checked to obtain a new data packet.
[0137] In the above implementation process, when the response time of the current serial port screen response exceeds the first time threshold, the response time of the current serial port screen response is further detected to avoid the impact of the long response time of the current serial port screen response on the optimization of the serial port.
[0138] Furthermore, the optimization module 4 is also used for:
[0139] If the target character is the first target character, the serial port optimization is successful;
[0140] If the target character is the second target character, the serial port is not optimized.
[0141] In the above implementation process, the serial port is optimized or not optimized according to different target characters, thereby improving the optimization efficiency and use efficiency of the serial port.
[0142] The above serial port optimization 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.
[0143] 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.
[0144] Embodiment 3
[0145] 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 optimization method of the first embodiment.
[0146] Optionally, the above-mentioned electronic device may be a server.
[0147] 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.
[0148] 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.
[0149] 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.
[0150] 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.
[0151] 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.
[0152] 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.
[0153] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which implements the serial port optimization method of embodiment 1 when executed by a processor.
[0154] 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.
[0155] 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.
[0156] 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.
[0157] 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.
[0158] 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.
[0159] 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.
[0160] 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 optimization method, It is characterized in that The method comprises: Get the serial port wake-up character; Start the download mode according to the serial port wake-up character; In download mode, get the first serial port screen response according to the serial port configuration characters; Start the data receiving mode according to the first serial port screen response; In data receiving mode, the second serial port screen response is obtained according to the data packet; The target character is obtained according to the response of the second serial port screen, and the serial port optimization is successful.
2. The serial port optimization method according to claim 1, It is characterized in that The step of starting the download mode according to the serial port wake-up character comprises: Determining whether the serial port wake-up character meets a first preset requirement; If not, detect the host sending character, communication level and baud rate to obtain a new serial port wake-up character; If yes, start download mode.
3. The serial port optimization method according to claim 1, It is characterized in that The step of obtaining a first serial port screen response according to the serial port configuration character comprises: Extracting the temporary baud rate in the serial port configuration character; Determine whether the current serial port screen response meets the second preset requirement according to the temporary baud rate; If so, determine that the current serial port screen response is the first serial port screen response; If not, the temporary baud rate is modified, and the first serial port screen response is obtained again according to the modified temporary baud rate.
4. The serial port optimization method according to claim 3, It is characterized in that Before the step of modifying the temporary baud rate and re-obtaining the first serial port screen response according to the modified temporary baud rate, the method further includes: The serial port configuration character is sent after a first preset time delay.
5. The serial port optimization method according to claim 4, It is characterized in that The step of obtaining a second serial port screen response according to the data packet includes: Verifying the data packet to determine whether the data packet meets a third preset requirement; If not, the data packet is inverted and filled to obtain a new data packet, and the second serial port screen response is obtained according to the new data packet; If so, determine whether the current serial port screen response meets the fourth preset requirement. If the current serial port screen response meets the fourth preset requirement, determine that the current serial port screen response is the second serial port screen response. If the current serial port screen response does not meet the fourth preset requirement, detect the sequence number of the data packet to obtain a new data packet, and obtain the second serial port screen response according to the new data packet.
6. The serial port optimization method according to claim 5, It is characterized in that The step of detecting the sequence number of the data packet to obtain a new data packet comprises: Determine whether the response time of the current serial port screen response exceeds a first time threshold; If so, determine whether the response time of the current serial port screen response exceeds the second time threshold, if the response time of the current serial port screen response exceeds the second time threshold, re-obtain the first serial port screen response, if the response time of the current serial port screen response does not exceed the second time threshold, detect the sequence number of the data packet to obtain a new data packet; If not, the sequence number of the data packet is detected to obtain a new data packet.
7. The serial port optimization method according to claim 1, It is characterized in that The step of obtaining the target character according to the second serial port screen response and the serial port optimization is successful includes: If the target character is the first target character, the serial port optimization is successful; If the target character is the second target character, the serial port is not optimized.
8. A serial port optimization device, It is characterized in that The device comprises: The acquisition module is used to obtain the serial port wake-up character; A startup module, used to start the download mode according to the serial port wake-up character; and also used to start the data receiving mode according to the first serial port screen response; The data acquisition module is used to obtain the first serial port screen response according to the serial port configuration characters in the download mode; and is also used to obtain the second serial port screen response according to the data packet in the data receiving mode; The optimization module is used to obtain the target character according to the second serial port screen response, and the serial port optimization is successful.
9. An electronic device, It is characterized in that The 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 optimization method according to any one of claims 1 to 7.
10. A storage medium, It is characterized in that It stores a computer program, and when the computer program is executed by a processor, the serial port optimization method according to any one of claims 1 to 7 is implemented.
