Automatic test method and system based on serial port communication

By introducing an automatic testing method in serial communication, using data transmission and processing between the upper and lower computers, the problem of difficult to implement automatic testing of serial communication in the prior art is solved, and the user experience is improved.

CN119473745AInactive Publication Date: 2025-02-18FOSHAN LONGSHEN ROBOT
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510062121.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing serial debugging tools require manual confirmation and comparison, which is difficult to meet the batch automatic testing needs of serial communication, and the user experience is poor.

Method used

It provides an automatic testing method based on serial port communication, which automatically generates test result information through the transmission, code modification and encoding processing of serial port test data between the upper and lower computers to reduce human-computer interaction steps.

Benefits of technology

Automatic testing of serial communication is realized, the user experience is improved, and the problem of poor user experience in the existing technology is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473745A_ABST
    Figure CN119473745A_ABST
Patent Text Reader

Abstract

The invention is applicable to the technical field of communication data transmission, and provides an automatic test method and system based on serial port communication, and the method comprises the steps: firstly controlling an upper computer to automatically generate serial port test data information and send the serial port test data information to a lower computer, and then controlling the lower computer to carry out code modification processing on the serial port test data information; the method comprises the steps of generating code changing data information and sending the code changing data information to an upper computer, then controlling the upper computer to encode serial port test data information according to a code changing rule of a lower computer to generate encoded data information, and finally accurately generating test result information by comparing the encoded data information with the code changing data information. According to the invention, automatic testing of serial port communication can be realized, a lower computer can automatically perform data receiving and code changing output, an upper computer can also automatically perform data coding output and perform automatic comparison and statistics on received and transmitted data, independent peripherals are not needed, the steps of man-machine interaction are remarkably reduced, and the testing efficiency is improved. And the user experience is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of communication data transmission, and in particular, to an automatic testing method and system based on serial port communication. Background Art

[0002] With the rapid development of the electronics industry, various forms of serial interfaces (serial ports for short) are involved in the configuration, debugging, interaction and feedback functions of electronic products. Therefore, serial port debugging tools have been developed in various hardware platforms or operating systems in recent decades, such as PuTTY, CoolTerm or HyperTerminal, to enable technicians to verify serial port communications.

[0003] At present, commonly used serial port debugging tools usually require manual confirmation and comparison, which makes it difficult to meet the needs of batch automatic testing of serial port communications. There is a problem of poor user experience and further improvement is needed. Summary of the invention

[0004] Based on this, the embodiment of the present application provides an automatic testing method and system based on serial port communication to solve the problem of poor user experience in the prior art.

[0005] In a first aspect, an embodiment of the present application provides an automatic testing method based on serial port communication, which is applied to a host computer and a slave computer, and the method includes: The host computer automatically generates serial port test data information in response to the serial port communication test instruction, and sends the serial port test data information to the slave computer; The lower computer performs code conversion processing on the serial port test data information to generate code conversion data information, and the lower computer sends the code conversion data information to the upper computer; The host computer encodes the serial port test data information based on the coding rules of the lower computer to generate encoded data information; The host computer generates test result information according to the encoded data information and the recoded data information.

[0006] Compared with the prior art, the beneficial effects are as follows: in the automatic testing method based on serial port communication provided in the embodiment of the present application, the terminal device can first control the upper computer to respond to the serial port communication test instruction, automatically generate serial port test data information, and send the serial port test data information to the lower computer, and then control the lower computer to perform code conversion processing on the serial port test data information, effectively generate the code conversion data information, and send the code conversion data information to the upper computer, and then control the upper computer to encode the serial port test data information according to the code conversion rule of the lower computer, effectively generate the encoded data information, and finally control the upper computer to automatically and efficiently generate the test result information according to the encoded data information and the code conversion data information, thereby realizing automatic serial port monitoring, automatically receiving and outputting various data in the test process, reducing the steps of human-computer interaction, improving the user experience, and solving the current problem of poor user experience to a certain extent.

[0007] In a second aspect, an embodiment of the present application provides an automatic testing system based on serial communication, which is applied to a host computer and a slave computer, and the system includes: Serial port test data information generation module: used for the upper computer to automatically generate serial port test data information in response to the serial port communication test instruction, and send the serial port test data information to the lower computer; A code-changing data information generating module: used for the lower computer to code-change the serial port test data information to generate code-changing data information, and the lower computer sends the code-changing data information to the upper computer; Encoded data information generation module: used for the host computer to encode the serial port test data information based on the coding rules of the lower computer to generate encoded data information; Test result information generation module: used by the host computer to generate test result information based on the encoded data information and the recoded data information.

[0008] In a third aspect, an embodiment of the present application provides a terminal 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 of the first aspect described above when executing the computer program.

[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method of the first aspect described above are implemented.

[0010] It can be understood that the beneficial effects of the second to fourth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0012] Figure 1 It is a flowchart of an automatic testing method provided by an embodiment of the present application; Figure 2 is a flowchart of step S100 in the automatic testing method provided in one embodiment of the present application; Figure 3 is a flowchart of step S200 in the automatic testing method provided in one embodiment of the present application; Figure 4 is a schematic diagram of a serial communication protocol structure provided by an embodiment of the present application; Figure 5 is a flowchart of step S300 in the automatic testing method provided in one embodiment of the present application; Figure 6 is a flowchart of step S400 in the automatic testing method provided in one embodiment of the present application; Figure 7 is a module block diagram of an automatic testing system provided by an embodiment of the present application; Figure 8 It is a schematic diagram of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0013] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0014] In the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0015] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0016] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0017] See also Figure 1 , Figure 1 1 is a flow chart of an automatic test method based on serial communication provided by an embodiment of the present application. In the present embodiment, the execution subject of the automatic test method is a terminal device. It is understandable that the types of terminal devices include but are not limited to mobile phones, tablet computers, notebook computers, ultra-mobile personal computers (Ultra-Mobile Personal Computer, UMPC), netbooks, personal digital assistants (Personal Digital Assistant, PDA), etc., and the present embodiment of the application does not impose any restrictions on the specific types of terminal devices.

[0018] See also Figure 1 The automatic testing method provided in the embodiment of the present application includes but is not limited to the following steps: In S100 , the upper computer automatically generates serial port test data information in response to the serial port communication test instruction, and sends the serial port test data information to the lower computer.

[0019] Specifically, the automatic testing method can be applied to a host computer and a slave computer; the terminal device can first control the host computer to respond to a serial communication test instruction, automatically generate serial port test data information, and control the host computer to send the serial port test data information to a specified slave computer.

[0020] In some possible implementations, in order to meet the needs of automatic testing of serial communication, please refer to Figure 2 Step S100 includes but is not limited to the following steps: In S110 , the host computer automatically generates serial port test data information in response to the serial port communication test instruction.

[0021] Specifically, the terminal device may first control the host computer so that the host computer automatically generates serial port test data information in response to a serial port communication test instruction, wherein the serial port communication test instruction is used to instruct the start of a serial port communication test, and the serial port test data information is used to describe data used for the serial port test.

[0022] It should be noted that the common serial port communication test currently often requires two or more serial ports to communicate with each other. Both parties need to perform human-computer interaction, that is, each party needs to set its own serial port information, data format, and transmission frequency. Since most test machines have peripheral input and output, but most of the tested machines are embedded, that is, they do not have independent input and output peripherals, and in actual needs, the performance of the tested machines is also high and low. Even if the network debugging method is used, many command lines are required. Therefore, both ends of the test need to frequently perform human-computer interaction, which is inconvenient to use and can only be manually confirmed, and the test efficiency is low. At the same time, since some tested machines need to test more than one serial port, but the conventional serial port debugging software can only run a program for each serial port separately for control, which will lead to an exponential increase in manual operation steps.

[0023] In S120, the serial port of the upper computer is matched with the serial port of the lower computer to determine at least one serial port to be tested of the lower computer.

[0024] Specifically, after the terminal device controls the host computer to automatically generate serial port test data information, the terminal device can match the serial port of the host computer with the serial port of the slave computer, quickly determine at least one serial port to be tested of the slave computer, thereby realizing automatic identification and matching of the serial port of the slave computer.

[0025] In some possible implementations, in order to match the serial port of the upper computer with the serial port of the lower computer, the terminal device can first obtain the serial port parameter set information of the upper computer, and at the same time obtain the serial port parameter set information of the lower computer, and then match the serial port of the upper computer with the serial port of the lower computer based on the serial port parameter set information, wherein the serial port parameter set information of the upper computer and the serial port parameter set information of the lower computer can both include baud rate information, data bit information, stop bit information, parity information and / or flow control mode information; the baud rate information is used to describe the number of symbols transmitted per second; the data bit information is used to describe the number of valid data bits in a data packet; the stop bit information is used to indicate the end of the data packet; the parity information is used to detect errors in data transmission; the flow control mode information is used to manage the data stream to prevent the receiver from losing data due to slow processing speed.

[0026] In S130 , the upper computer sends serial port test data information to each serial port to be tested of the lower computer.

[0027] Specifically, after the terminal device determines the serial ports to be tested of the lower computer, the terminal device can control the upper computer to perform the processing for each serial port to be tested of the lower computer: first create a system thread to automatically open the serial port with correct parameters and establish an independent system thread for each serial port, and then send the serial port test data information to the serial ports to be tested of the lower computer based on the system thread, thereby realizing automatic detection of multiple serial ports, which not only does not require independent peripherals, but also greatly reduces the need for manual operation, thereby improving test efficiency and user experience.

[0028] In some possible implementations, in order to realize automatic detection of each serial port, step S130 includes but is not limited to the following steps: In S131, the upper computer cyclically sends serial port test data information to the lower computer based on the time interval of the timer until the number of cyclic tests is equal to the specified number threshold.

[0029] Specifically, the terminal device can first control the upper computer to send the serial port test data information to the lower computer in a loop according to the time interval of the timer until the number of cyclic tests is equal to the specified number threshold, thereby realizing multiple serial port access process verifications according to the set parameters, and automatically performing batch tests of a certain intensity, which is helpful to test the stability of serial port access; exemplarily, when the number of serial ports is three and the number threshold is 5 times, the terminal device can first open the serial port of the upper computer, and send the serial port test data information to the lower computer according to the set time interval through the timer function, and then close the serial port of the upper computer, and after waiting for the same time interval, open the serial port of the upper computer again, and send the serial port test data information to the lower computer again, and so on, until all three serial ports perform 5 cycles of automatic testing.

[0030] In S200, the lower computer performs code conversion processing on the serial port test data information to generate code-converted data information, and the lower computer sends the code-converted data information to the upper computer.

[0031] Specifically, after the terminal device controls the upper computer to send the serial port test data information to the lower computer, the terminal device can control the lower computer to transcode the serial port test data information to generate transcoded data information, and then control the lower computer to send the transcoded data information to the upper computer.

[0032] In some possible implementations, in order to effectively ensure the data integrity of the communication test and to be simple and convenient to use, please refer to Figure 3 Step S200 includes but is not limited to the following steps: In S210, the lower computer performs code conversion processing on the serial port test data information to generate code-converted data information.

[0033] Specifically, after the terminal device controls the upper computer to send the serial port test data information to the lower computer, the terminal device can control the lower computer to perform code modification processing on the serial port test data information to generate modified data information, wherein the code modification processing is to add 1 to the frame header of the serial port test data information.

[0034] It should be noted that the serial communication protocol used in the embodiments of the present application uses hexadecimal original code as the basic format of the communication protocol; for example, please refer to Figure 4 , Figure 4 The composition mode corresponding to the serial communication protocol of this embodiment is used to represent that the overall byte length of the serial communication protocol can be greater than or equal to 3. The frame header of the serial communication protocol can be 1 to 4 bytes; the cyclic code of the serial communication protocol can be 1 byte, and by automatically comparing and calculating the inter-frame relationship of the received numbers, it can be effectively determined whether there are missed frames and duplicate frames; the sum check of the serial communication protocol can be 1 byte, and the calculation method of the sum check can be to sum all the previous bytes and take the lower byte, so that it can be effectively determined whether there is an error frame by automatically comparing and calculating the intra-frame relationship of the received numbers, wherein the summing and taking the lower byte can adopt the existing technology, so it is not repeated.

[0035] Without loss of generality, the serial communication protocol can set the identification part of the protocol through the frame header, including the cyclic check and the sum check content by default, and specify the number of bytes of the whole packet of data through the byte length, so as to achieve the flexibility of meeting different detection conditions through the frame header and the byte length, and meet the setting of specific identification and specific length data, and can automatically fill in the data content at the same time, through the number that increases byte by byte, clearly showing the number of bytes of the surface data content and the fixed data relationship, which can not only effectively ensure the data completeness of the communication test, but also make it simpler and more convenient to use.

[0036] In a possible implementation, the code conversion process may be extended to multiple bytes, addition, subtraction, multiplication, division, AND, OR, and the like, and combinations thereof.

[0037] In S220, the lower computer sends the modified data information to the upper computer; Specifically, after the terminal device controls the lower computer to generate the recoded data information, the terminal device can control the lower computer to send the recoded data information to the upper computer.

[0038] In S300, the upper computer encodes the serial port test data information based on the encoding rule of the lower computer to generate encoded data information.

[0039] Specifically, after the terminal device controls the lower computer to send the modified data information to the upper computer, the terminal device can control the upper computer to encode the serial port test data information based on the modification rules of the lower computer to generate encoded data information, wherein the modification rules of the lower computer can be to add 1 to the frame header of the serial port test data information.

[0040] In some possible implementations, in order to achieve automatic encoding, automatic comparison, automatic cycle testing and automatic statistics of serial communication, please refer to Figure 5 Step S300 includes but is not limited to the following steps: In S310, the host computer creates a receiving thread, and receives the modified data information based on the receiving thread.

[0041] Specifically, the terminal device may first control the host computer to create a receiving thread, and then control the host computer to receive the modified data information sent by the lower computer based on the receiving thread.

[0042] In S320, the upper computer encodes the serial port test data information based on the encoding rule of the lower computer to generate encoded data information.

[0043] Specifically, after the terminal device controls the upper computer to receive the modified data information, the terminal device can control the upper computer to encode the serial port test data information based on the modification rules of the lower computer to generate encoded data information, wherein the modification rules of the lower computer can be to add 1 to the frame header of the serial port test data information.

[0044] In S400, the host computer generates test result information according to the encoded data information and the recoded data information.

[0045] Specifically, after the terminal device controls the host computer to generate coded data information, the terminal device can control the host computer to accurately generate test result information based on the coded data information and the modified data information, wherein the test result information includes normal communication information or abnormal communication information. The normal communication information is used to describe the status of the serial port communication as normal, and the abnormal communication information is used to describe the status of the serial port communication as abnormal.

[0046] In some possible implementations, in order to further improve user experience, before step S400, the method further includes but is not limited to the following steps: In S401, the host computer stores the encoded data information in a buffer.

[0047] Specifically, the terminal device may first control the host computer to store the encoded data information into a preset buffer.

[0048] Accordingly, see Figure 6 Step S400 includes but is not limited to the following steps: In S410, the host computer determines whether the modified data information completely matches the encoded data information in the buffer.

[0049] Specifically, the terminal device can control the host computer to effectively determine whether the modified data information completely matches the encoded data information in the buffer.

[0050] For example, the terminal device may first control the host computer to determine whether the number of data bytes is greater than or equal to the number of data bytes in one frame. If the number of data bytes is greater than or equal to the number of data bytes in one frame, the terminal device may control the host computer to determine whether the recoded data information completely matches the coded data information in the buffer starting from the first byte. If the number of data bytes is less than the number of data bytes in one frame, wait for the next data comparison.

[0051] In S420, if the host computer determines that the modified data information completely matches the coded data information in the buffer, the coded data information in the buffer is deleted and normal communication information is generated, otherwise abnormal communication information is generated.

[0052] For example, if the host computer determines that the recoded data information completely matches the coded data information in the buffer, the terminal device can control the host computer to delete the coded data information in the buffer, and then update the correct number of bytes and frames, and generate normal communication information at the same time. If the host computer determines that the recoded data information does not completely match the coded data information in the buffer, the terminal device can generate abnormal communication information, thereby realizing data comparison in each independent thread, greatly improving data testing efficiency, reducing the workload of manual operations, and improving user experience.

[0053] Without loss of generality, the terminal device can control the host computer to perform automatic data comparison processing in the receiving thread, automatically count the number of received bytes, the number of matched frames, the number of erroneous bytes and frames, and record the statistical results, that is, automatically count the correctness of data communication during this cycle test.

[0054] The implementation principle of the automatic testing method based on serial port communication in the embodiment of the present application is as follows: the terminal device can first control the upper computer to respond to the serial port communication test instruction, automatically generate serial port test data information, and send the serial port test data information to the lower computer, and then control the lower computer to perform code conversion processing on the serial port test data information, effectively generate the code conversion data information, and send the code conversion data information to the upper computer, and then control the upper computer to encode the serial port test data information according to the code conversion rules of the lower computer, effectively generate the encoded data information, and finally control the upper computer to automatically and efficiently generate the test result information according to the encoded data information and the code conversion data information, thereby realizing automatic serial port monitoring, automatic data reception and code conversion output, reducing the steps of human-computer interaction, and improving the user experience.

[0055] It should be noted that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0056] The embodiment of the present application also provides an automatic test system based on serial communication, which is applied to a host computer and a slave computer. For ease of description, only the parts related to the present application are shown, such as Figure 7 As shown, the system 70 includes: Serial port test data information generating module 71: used for the upper computer to automatically generate serial port test data information in response to the serial port communication test instruction, and send the serial port test data information to the lower computer; The recoded data information generating module 72 is used for the lower computer to recode the serial port test data information to generate recoded data information, and the lower computer sends the recoded data information to the upper computer; Encoded data information generating module 73: for the host computer based on the lower computer code change rules, the serial test data information is encoded and processed to generate encoded data information; The test result information generating module 74 is used by the host computer to generate the test result information according to the encoding data information and the recoding data information.

[0057] Optionally, the serial port test data information generating module 71 includes: Serial port test data information generation submodule: used for the host computer to automatically generate serial port test data information in response to the serial port communication test instruction; The serial port determination submodule to be tested is used to match the serial port of the upper computer with the serial port of the lower computer, and determine at least one serial port to be tested of the lower computer; Serial port test data information sending submodule: used by the upper computer to send serial port test data information to each serial port to be tested on the lower computer.

[0058] Optionally, the serial port test data information sending submodule includes: Serial port test data information sending unit: used for the upper computer to cyclically send serial port test data information to the lower computer based on the time interval of the timer until the number of cyclic tests is equal to the specified number threshold.

[0059] Optionally, the above-mentioned code-changing data information generating module 72 includes: The recoded data information generating submodule is used for the lower computer to recode the serial port test data information to generate recoded data information, wherein the recoded processing is to add 1 to the frame header of the serial port test data information; The recoded data information sending submodule is used for the lower computer to send the recoded data information to the upper computer; Accordingly, the above-mentioned encoding data information generating module 73 includes: The recoded data information receiving submodule is used for the host computer to create a receiving thread and receive the recoded data information based on the receiving thread; Encoded data information generation submodule: used by the upper computer to encode the serial port test data information based on the encoding rules of the lower computer to generate encoded data information.

[0060] Optionally, the test result information includes normal communication information or abnormal communication information; the system 70 further includes: Encoded data information storage module: used by the host computer to store the encoded data information into the buffer; Accordingly, the test result information generating module 74 includes: The recoded data information judgment submodule is used by the host computer to judge whether the recoded data information completely matches the coded data information in the buffer; Normal communication information generation submodule: used to delete the coded data information in the buffer and generate normal communication information if the host computer determines that the modified data information completely matches the coded data information in the buffer, otherwise it generates abnormal communication information.

[0061] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0062] The present application also provides a terminal device, such as Figure 8 As shown, the terminal device 80 of this embodiment includes: a processor 81, a memory 82, and a computer program 83 stored in the memory 82 and executable on the processor 81. When the processor 81 executes the computer program 83, the steps in the above-mentioned automatic test method embodiment are implemented, for example Figure 1 Steps S100 to S400 shown; or, when the processor 81 executes the computer program 83, the functions of each module in the above device are realized, for example Figure 7 The functions of the modules 71 to 74 are shown.

[0063] The terminal device 80 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server, and the terminal device 80 includes but is not limited to a processor 81 and a memory 82. Those skilled in the art will appreciate that Figure 8 It is only an example of the terminal device 80 and does not constitute a limitation of the terminal device 80. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device 80 may also include input and output devices, network access devices, buses, etc.

[0064] Among them, the processor 81 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.; the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0065] The memory 82 may be an internal storage unit of the terminal device 80, such as a hard disk or memory of the terminal device 80, or an external storage device of the terminal device 80, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 80; further, the memory 82 may include both an internal storage unit and an external storage device of the terminal device 80, and the memory 82 may also store a computer program 83 and other programs and data required by the terminal device 80, and the memory 82 may also be used to temporarily store data that has been output or is to be output.

[0066] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of each of the above method embodiments can be implemented. Among them, the computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form, etc.; the computer-readable medium may include: any entity or device that can carry computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0067] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, all equivalent changes made according to the methods, principles, and structures of the present application should be included in the protection scope of the present application.

Claims

1. An automatic testing method based on serial communication, applied to a host computer and a slave computer, characterized in that: The method comprises: The host computer automatically generates serial port test data information in response to the serial port communication test instruction, and sends the serial port test data information to the slave computer; The lower computer performs code conversion processing on the serial port test data information to generate code conversion data information, and the lower computer sends the code conversion data information to the upper computer; The host computer encodes the serial port test data information based on the coding rules of the lower computer to generate encoded data information; The host computer generates test result information according to the encoded data information and the recoded data information.

2. The method according to claim 1, characterized in that: The host computer automatically generates serial port test data information in response to the serial port communication test instruction, and sends the serial port test data information to the slave computer, including: The host computer automatically generates serial port test data information in response to the serial port communication test instruction; Matching the serial port of the upper computer with the serial port of the lower computer to determine at least one serial port to be tested of the lower computer; The host computer sends the serial port test data information to each of the serial ports to be tested of the slave computer.

3. The method according to claim 2, characterized in that The host computer sends the serial port test data information to each serial port to be tested of the slave computer, including: The upper computer cyclically sends the serial port test data information to the lower computer based on the time interval of the timer until the number of cyclic tests is equal to the specified number threshold.

4. The method according to claim 3, characterized in that: The lower computer performs code conversion processing on the serial port test data information to generate code-converted data information, and the lower computer sends the code-converted data information to the upper computer, including: The lower computer performs code modification processing on the serial port test data information to generate code-modified data information, wherein the code modification processing is to add 1 to the frame header of the serial port test data information; The lower computer sends the recoded data information to the upper computer; Correspondingly, the upper computer encodes the serial port test data information based on the encoding rule of the lower computer to generate encoded data information, including: The host computer creates a receiving thread, and receives the recoded data information based on the receiving thread; The upper computer encodes the serial port test data information based on the encoding rule of the lower computer to generate encoded data information.

5. The method according to claim 4, characterized in that The test result information includes normal communication information or abnormal communication information; Before the host computer generates test result information according to the encoded data information and the recoded data information, the method further includes: The host computer stores the coded data information in a buffer; Correspondingly, the host computer generates test result information according to the encoded data information and the recoded data information, including: The host computer determines whether the recoded data information completely matches the coded data information in the buffer; If the host computer determines that the recoded data information completely matches the coded data information in the buffer, the coded data information in the buffer is deleted and the normal communication information is generated; otherwise, the abnormal communication information is generated.

6. An automatic test system based on serial communication, applied to a host computer and a slave computer, characterized in that: The system comprises: Serial port test data information generation module: used for the upper computer to automatically generate serial port test data information in response to the serial port communication test instruction, and send the serial port test data information to the lower computer; A code-changing data information generating module: used for the lower computer to code-change the serial port test data information to generate code-changing data information, and the lower computer sends the code-changing data information to the upper computer; Encoded data information generation module: used for the host computer to encode the serial port test data information based on the coding rules of the lower computer to generate encoded data information; Test result information generation module: used by the host computer to generate test result information based on the encoded data information and the recoded data information.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Data transmission system and method based on double serial ports and electronic equipment

    CN115633027A

  • Function detection system of multi-channel serial port chip

    CN117572205A

  • Serial port test method and device, electronic equipment and computer readable storage medium

    CN119088632A