Simulation debugging method and system for serial communication equipment
By enrolling and simulating communication protocols in the simulation and debugging method and system of the serial communication equipment, debugging problems in the existing technology when the communication protocol is unknown or the equipment is difficult to obtain, and automated serial communication data transmission and reception and equipment debugging are realized, reducing operational complexity and cost.
Patent Information
- Application Number
- CN202011314396.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-20
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2040-11-20
AI Technical Summary
The prior art lacks the simulation and debugging method and system of serial communication equipment when the communication protocol is unknown or the equipment is difficult to obtain.
It provides a simulation debugging method and system for serial communication equipment. It adopts a communication protocol between any host and slave through the protocol admission step, and receives instructions from the host to be tested or slave to be tested in the automatic transceiver step, and finds corresponding response information from the admitted communication protocol, and the simulated slave or host sends the response information to the host to be tested or slave to be tested.
It realizes automatic admission and simulated serial communication data transmission and reception when the communication protocol is unknown, which facilitates secondary development and debugging of equipment and reduces debugging costs.
Smart Images

Figure CN114518980B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of serial communication, and in particular to a simulation debugging method and system for serial communication equipment. Background Art
[0002] Serial interface (Serial Interface) is a commonly used debugging and communication interface on instruments and equipment. According to electrical standards and protocols, serial ports can be divided into RS-232, RS-422 and RS-485. The three interfaces can be converted to each other through a converter.
[0003] At present, the conventional communication simulation method of serial port devices is to obtain a detailed communication protocol, write the communication protocol into a single-chip microcomputer to develop a separate simulator for simulation, or use a serial port debugging assistant on the computer to manually send the communication protocol for simulation. Both methods are based on the obtained detailed communication protocol, and the first method is usually that after the communication protocol is written into the program, communication can only be carried out according to the communication protocol specified in the program. If the communication protocol changes, the program needs to be rewritten and then burned into the single-chip microcomputer, which is complicated to operate; the latter method requires manual transmission of the communication protocol, which is easy to cause erroneous operation and inconvenient to use. In addition, if the communication device is not convenient to obtain, the device cannot be debugged normally when the communication protocol is known.
[0004] Therefore, the prior art lacks a method and system for simulating debugging of serial communication devices when the communication protocol is unknown or the communication device is missing and cannot be debugged. Summary of the invention
[0005] In view of the above analysis, an embodiment of the present invention aims to provide a simulation debugging method and system for a serial communication device, so as to solve the problem of simulation debugging of a serial communication device when the existing communication protocol is unknown.
[0006] In order to achieve the above object, the embodiments of the present invention provide the following technical solutions:
[0007] On the one hand, an embodiment of the present invention provides a simulation debugging method for a serial communication device, comprising:
[0008] Protocol admission steps: Admit the communication protocol between any host and slave;
[0009] Automatic sending and receiving step: receiving the instruction of the host or slave under test, searching for the corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test.
[0010] Furthermore, the protocol admission step includes:
[0011] Serial port setting and initialization step: setting the first serial port parameter and the first resource flag connected to the arbitrary host and the second serial port parameter and the second resource flag connected to the arbitrary slave, and initializing the first serial port and the second serial port; the first resource flag and the second resource flag are used to distinguish the serial port data of the arbitrary host and the arbitrary slave;
[0012] Data receiving and recording step: receiving the communication data between any host or any slave, adding the corresponding first resource mark or second resource mark before the communication data, adding the communication data with the added resource mark to the cache data in the buffer area, until the complete cache data is output;
[0013] Communication protocol saving step: saving the complete cache data.
[0014] Furthermore, the data receiving and recording steps include:
[0015] Step S101, read the number of bytes N1 of the buffer data received by the first serial port, N1 ≥ 0;
[0016] Step S102, read the number of bytes N2 of the buffer data received by the second serial port, N2 ≥ 0;
[0017] Step S103, setting the initial value of variable i1 to 0;
[0018] Step S104: when N1≥1, read the buffer data received by the first serial port; when N1=0, execute step S108;
[0019] Step S105, when the variable i1=0, add the first resource flag before the buffer data received by the first serial port, otherwise execute step S106;
[0020] Step S106, adding the buffer data received by the first serial port to the buffer data DataA;
[0021] Step S107, subtract 1 from the number of bytes of data in the buffer area N1, add 1 to the variable i1, and then execute step S104;
[0022] Step S108, setting the initial value of variable i2 to 0;
[0023] Step S109, when N2≥1, read the buffer data received by the second serial port; when N2=0, execute step S113;
[0024] Step S110, when the variable i2=0, adding the second resource flag before the buffer data received by the second serial port, otherwise executing step S111;
[0025] Step S111, adding the buffer data received by the second serial port to the buffer data DataB;
[0026] Step S112, subtract 1 from the number of bytes of data in the buffer area N2, add 1 to the variable i2, and then execute step S109;
[0027] Step S113, outputting the cached data DataA and the cached data DataB;
[0028] Step S114, displaying and adding the cached data DataA and DataB to the cached data Data_S;
[0029] Step S115, clearing the cached data DataA and the cached data DataB;
[0030] Step S116, waiting for a first preset time;
[0031] Step S117: after receiving the serial port closing command, save the cache data Data_S, otherwise execute step S101.
[0032] Furthermore, the automatic sending and receiving step includes:
[0033] System setup and initialization steps: Set the serial port parameters and resource flags of the computer receiving and sending ends, select the accepted communication protocol and read it into the buffer area, and initialize the serial port;
[0034] Data receiving and processing steps: receiving the instruction of the host or slave under test, searching for corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test.
[0035] Furthermore, the system setting and initialization step further includes: reading the communication protocol in the cache data Data_S into the cache area; initializing the serial port;
[0036] When the device under test is a host, the computer receiving end resource flag is set to the first resource flag, and the computer sending end resource flag is set to the second resource flag;
[0037] When the device under test is a slave, the resource flag of the computer receiving end is set to the second resource flag, and the resource flag of the computer sending end is set to the first resource flag.
[0038] Furthermore, the data receiving and processing step includes:
[0039] Step S201, reading the number of bytes N of the buffer data received by the serial port of the computer receiving end, where N≥0;
[0040] Step S202, when N≥1, read one byte of data from the receiving buffer of the serial port of the computer receiving end, and save the data as buffer data Data_R through the shift register, otherwise execute step S215;
[0041] Step S203: When N≠1, execute step S204; otherwise, execute step S205;
[0042] Step S204, subtract 1 from the number of bytes N of data in the buffer area, and then execute step S202;
[0043] Step S205, displaying and saving the cache data Data_R;
[0044] Step S206 , searching the cache data Data_R in the cache data Data_S, and intercepting the data after the cache data Data_R as data Data_Tem1 ;
[0045] Step S207, when the data Data_Tem1 is not empty, search the data Data_Tem1 for the nearest computer receiving end resource mark, and intercept the data before the computer receiving end resource mark as data Data_Tem2; when the data Data_Tem1 is empty, the data Data_Tem2 is empty;
[0046] Step S208, searching the data Data_Tem2 for the nearest resource mark of the computer sending end, and intercepting the data after the resource mark of the computer sending end as data Data_Tem3;
[0047] Step S209: When the data Data_Tem3 is not empty, execute step S210; otherwise, execute step S204;
[0048] Step S210, searching the data Data_Tem3 for the nearest resource mark of the computer sending end, and intercepting the data before the resource mark of the computer sending end as data Data_Tem4;
[0049] Step S211, when the data Data_Tem4 is not empty, sending the data Data_Tem4 through the serial port; when the data Data_Tem4 is empty, sending the data Data_Tem3 through the serial port;
[0050] Step S212, displaying and maintaining the sent data in the display window;
[0051] Step S213, executing the assignment of the data Data_Tem3 to the data Data_Tem2;
[0052] Step S214, wait for a second preset time and then execute step S208;
[0053] Step S215, clearing the cached data Data_R, and then waiting for a third preset time;
[0054] Step S216: After receiving the serial port closing command, save the data and complete the test; otherwise, execute step S201.
[0055] On the other hand, an embodiment of the present invention provides a simulation debugging system for a serial communication device, comprising:
[0056] Protocol recording module, used to record the communication protocol between any host and slave;
[0057] The automatic transceiver module is used to receive the instruction of the host or slave under test, find the corresponding response information from the acquired communication protocol, and simulate the slave or host to send the response information to the host or slave under test.
[0058] Furthermore, the protocol admission module includes:
[0059] A serial port setting and initialization unit, used for setting a first serial port parameter and a first resource flag for connecting to the arbitrary host and a second serial port parameter and a second resource flag for connecting to the arbitrary slave, and initializing the first serial port and the second serial port; the first resource flag and the second resource flag are used for distinguishing serial port data of the arbitrary host and the arbitrary slave;
[0060] A data receiving and processing unit, used for receiving the communication data between any host or any slave, adding the corresponding first resource mark or second resource mark before the communication data, adding the communication data with the added resource mark to the cached data in the buffer area, until the complete cached data is output;
[0061] The communication protocol storage unit is used to store the complete cache data.
[0062] Furthermore, the automatic transceiver module includes:
[0063] System setting and initialization unit, used to set the serial port parameters and resource flags of the computer receiving and sending ends, select the accepted communication protocol and read it into the buffer area, and initialize the serial port;
[0064] The data receiving and processing unit is used to receive the instruction of the host or slave under test, search for the corresponding response information from the acquired communication protocol, and simulate the slave or host to send the response information to the host or slave under test.
[0065] Furthermore, it also includes: a display module, which is used to display the data information sent and received in the protocol admission module and the automatic sending and receiving module.
[0066] Beneficial effects of the present invention:
[0067] 1. The present invention can realize the communication protocol between recording devices when the communication protocol is unknown, and then simulate one of the devices to automatically send and receive serial communication data with another debugged device, which can facilitate the secondary development and device debugging of the device.
[0068] 2. When the communication protocol is known, if the device that communicates with the debugged device is not easy to obtain, this method can be used to debug the device and reduce the debugging cost.
[0069] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like components throughout the drawings.
[0071] Figure 1 A flowchart of a simulation debugging method for a serial communication device shown in one embodiment of the present application;
[0072] Figure 2 This is a flowchart of the protocol admission sub-steps shown in one embodiment of the present application;
[0073] Figure 3 A sub-flow chart of data receiving and recording steps shown in one embodiment of the present application;
[0074] Figure 4 A Labview program diagram of the protocol admission steps shown in one embodiment of the present application;
[0075] Figure 5 This is a flowchart of the automatic sending and receiving sub-steps shown in one embodiment of the present application;
[0076] Figure 6 A flowchart of data receiving and processing sub-steps shown in one embodiment of the present application;
[0077] Figure 7 A Labview program diagram of the automatic sending and receiving steps shown in one embodiment of the present application;
[0078] Figure 8 A schematic diagram of the structure of a simulation debugging system for a serial communication device shown in another embodiment of the present application;
[0079] Fig. 9 This is a schematic diagram of the protocol admission module structure shown in another embodiment of the present application;
[0080] Fig.10 This is a schematic diagram of the working of the protocol admission module shown in another embodiment of the present application;
[0081] Fig.11 This is a schematic diagram of the structure of an automatic transceiver module shown in another embodiment of the present application;
[0082] Fig.12 This is a working diagram of an automatic transceiver module shown in another embodiment of the present application;
[0083] Fig.13 A schematic diagram of the hardware structure of an electronic device for executing the simulation debugging method of a serial communication device provided in an embodiment of the invention of this application. DETAILED DESCRIPTION
[0084] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0085] like Figure 1 As shown, a specific embodiment of the present invention discloses a simulation debugging method for a serial communication device, comprising:
[0086] S1, protocol acceptance step: accept any communication protocol between the host and the slave; specifically, Figure 2 As shown, this step can obtain the communication protocol between any host and slave through the following sub-steps:
[0087] Specifically, according to electrical standards and protocols, serial ports are divided into RS-232, RS-422 and RS-485, and the three interfaces can be converted to each other through a converter. Optionally, when the device under test uses RS-232 communication or RS-485 two-wire mode communication, the RS-232 communication or RS-485 two-wire communication can be converted to RS-422 four-wire communication mode and then tested using the method of this embodiment.
[0088] Optionally, the present application can accept the communication protocol of any group of devices (host and slave) that are the same as and communicate with the device under test when the communication protocol is unknown.
[0089] S10, serial port setting and initialization step: set the first serial port parameters and the first resource flag for connecting to any host and the second serial port parameters and the second resource flag for connecting to any slave, and initialize the first serial port and the second serial port; the first resource flag and the second resource flag are used to distinguish the serial port data of any host and any slave.
[0090] Specifically, the first serial port is the first receiving end connected to the transmitting end of any host, and the second serial port is the second receiving end connected to the transmitting end of any slave; the serial port parameters include: baud rate, data bit, parity, stop bit, flow control. The resource mark can be set arbitrarily to distinguish the recorded serial port data of any host and the serial port data of the slave. Optionally, the first serial port A of the host is set to correspond to the resource mark AAA, and the second serial port B of the slave is set to correspond to the resource mark BBB.
[0091] Specifically, after the serial port initialization is completed, any host and slave that have entered the communication protocol can begin communication operations.
[0092] Specifically, S20, data receiving and recording step: receiving communication data between any host or any slave, adding the corresponding first resource mark or second resource mark before the communication data, adding the communication data with the added resource mark to the cache data in the buffer area, until the complete cache data is output; specifically, as Figure 3 As shown, this step can obtain the communication protocol between any host and slave through the following sub-steps, including:
[0093] Step S101, read the number of bytes N1 of the buffer data received by the first serial port, where N1≥0; specifically, the buffer data received by the first serial port is the data sent by the host.
[0094] Step S102, reading the number of bytes N2 of the buffer data received by the second serial port, where N2≥0; specifically, the buffer data received by the second serial port is the data sent by the slave.
[0095] Step S103, setting the initial value of variable i1 to 0;
[0096] Step S104, when N1≥1, read the buffer data received by the first serial port; when N1=0, execute step S108; specifically, when N1≥1, the first serial port receives the data sent by the host, read the buffer data received by the first serial port, when N1=0, there is no data in the first serial port, execute step S108, and determine whether there is data in the second serial port.
[0097] Step S105, when variable i1=0, add a first resource flag before the buffer data received by the first serial port, otherwise execute step S106; specifically, when variable i1=0, read the current data for the first time, and add a first resource flag before the buffer data received by the first serial port to indicate that the data is data sent by the host.
[0098] Step S106, adding the buffer data received by the first serial port to the buffer data DataA; specifically, adding the first byte of the buffer data received by the first serial port to the buffer data DataA, and at this time DataA contains the first resource tag.
[0099] Step S107, subtract 1 from the number of bytes of data in the buffer area N1, add 1 to the variable i1, and then execute step S104;
[0100] Step S108, setting the initial value of variable i2 to 0;
[0101] Step S109, when N2≥1, read the buffer data received by the second serial port; when N2=0, execute step S113; specifically, when N2≥1, the second serial port receives the data sent by the host, and reads the buffer data received by the second serial port. When N1=0, there is no data in the second serial port, and the first group of corresponding data is recorded.
[0102] Step S110, when variable i2=0, add a second resource flag before the buffer data received by the second serial port, otherwise execute step S111; specifically, when variable i2=0, read the current data for the first time, and add a second resource flag before the buffer data received by the second serial port to indicate that the data is sent by the slave.
[0103] Step S111, adding the buffer data received by the second serial port to the buffer data DataB; specifically, adding the first byte of the buffer data received by the second serial port to the buffer data DataB, and at this time DataB contains the second resource tag.
[0104] Step S112, subtract 1 from the number of bytes of data in the buffer area N2, add 1 to the variable i2, and then execute step S109;
[0105] Step S113, outputting the cache data DataA and the cache data DataB; specifically, the output cache data DataA and the cache data DataB are data for communication between the host and the slave.
[0106] Step S114, display and add cache data DataA and DataB to cache data Data_S; specifically, add the acquired data of the host and slave communication each time to the cache data Data_S, and the finally generated Data_S includes all the data of the host and slave communication.
[0107] Step S115, clearing the cached data DataA and the cached data DataB; specifically, after one communication is completed, clearing the cached data DataA and the cached data DataB, and re-recording the next communication data.
[0108] Step S116, waiting for a first preset time; optionally, the first preset time is 10 ms.
[0109] Step S117, after receiving the serial port closing command, save the cached data Data_S, otherwise execute step S101, specifically, after receiving the serial port closing command, save the final cached data Data_S, otherwise continue to record the communication data.
[0110] S30, communication protocol saving step: saving the complete cache data to generate a complete communication protocol.
[0111] Alternatively, see Figure 4 ,The protocol acceptance steps of this application can be implemented through the Labview program, first performing the serial port setting and initialization steps, then performing the data receiving and acceptance steps, and finally performing the communication protocol saving step to complete the protocol acceptance.
[0112] Specifically, S2, automatic sending and receiving step: receiving the command of the host or slave under test, searching for the corresponding response information from the recorded communication protocol, and simulating the slave or host to send the response information to the host or slave under test. Figure 5 As shown, this step can be achieved through the following sub-steps, including:
[0113] S50, system setting and initialization steps: setting the serial port parameters and resource flags of the computer receiving and sending ends, selecting the accepted communication protocol and reading it into the buffer area, and initializing the serial port;
[0114] Specifically, it also includes: reading the communication protocol in the cache data Data_S into the cache area; initializing the serial port;
[0115] Optionally, the present application also selects a known communication protocol, adds a resource tag to the known protocol, and reads the communication protocol with the added resource tag into the cache.
[0116] Specifically, when the device under test is a host, the resource flag of the computer receiving end is set to the first resource flag, and the resource flag of the computer sending end is set to the second resource flag; when the device under test is a slave, the resource flag of the computer receiving end is set to the second resource flag, and the resource flag of the computer sending end is set to the first resource flag. Specifically, the resource flag of the computer receiving end here should be consistent with that of the host under test or the slave under test, and the resource flag of the host under test or the slave under test should be consistent with the resource flag of the host or slave set in the protocol admission step, and the computer sending end should be consistent with the resource flag of the simulated device. For example, in the protocol admission step, the front end of the data sent by the host is marked as AAA, and the front end of the data sent by the slave is marked as BBB. If the computer is to simulate the response sent by the slave, the resource flag of the computer receiving end is set to AAA, and the resource flag of the computer sending end is set to BBB; conversely, if the computer is to simulate the response of the host, the resource flag of the computer receiving end is set to BBB, and the resource flag of the computer sending end is set to AAA.
[0117] Specifically, S60, data receiving and processing step: receiving the instruction of the host or slave under test, searching for the corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test. Figure 6 As shown, this step can be implemented through the following sub-steps, including:
[0118] Step S201, read the number of bytes N of buffer data received by the serial port of the computer receiving end, where N≥0; specifically, the buffer data received by the serial port of the computer receiving end is data sent by the host or slave under test.
[0119] Step S202, when N≥1, read one byte of data from the receiving buffer of the serial port of the computer receiving end, and save the data as buffer data Data_R through the shift register, otherwise execute step S215;
[0120] Step S203: When N≠1, execute step S204; otherwise, execute step S205;
[0121] Step S204, subtract 1 from the number of bytes N of data in the buffer area, and then execute step S202;
[0122] Step S205 , display and save the cached data Data_R; specifically, the cached data Data_R is an instruction sent by the tested host or the tested slave.
[0123] Step S206 , searching the cache data Data_R in the cache data Data_S, and intercepting the data after the cache data Data_R as data Data_Tem1 ;
[0124] Step S207, when the data Data_Tem1 is not empty, search the data Data_Tem1 for the nearest computer receiving end resource mark, and intercept the data before the computer receiving end resource mark as data Data_Tem2; when the data Data_Tem1 is empty, the data Data_Tem2 is empty;
[0125] Step S208, searching the data Data_Tem2 for the nearest computer sending end resource mark, and intercepting the data after the computer sending end resource mark as data Data_Tem3;
[0126] Step S209: When the data Data_Tem3 is not empty, execute step S210; otherwise, execute step S204;
[0127] Step S210, searching the data Data_Tem3 for the nearest computer sending end resource mark, and intercepting the data before the computer sending end resource mark as data Data_Tem4;
[0128] Step S211, when the data Data_Tem4 is not empty, send the data Data_Tem4 through the serial port; when the data Data_Tem4 is empty, send the data Data_Tem3 through the serial port;
[0129] Step S212, displaying and maintaining the sent data in the display window;
[0130] Step S213, executing data Data_Tem3 and assigning it to data Data_Tem2;
[0131] Step S214, wait for the second preset time and then execute; specifically, by executing the assignment of data Data_Tem3 to data Data_Tem2, wait for the second preset time and then execute step S208 to automatically reply the corresponding multiple data. Optionally, the second preset time is 1S.
[0132] Step S215, clear the cached data Data_R, and then wait for a third preset time; optionally, the third preset time is 10ms.
[0133] Step S216: After receiving the serial port closing command, save the data and complete the test; otherwise, execute step S201.
[0134] Specifically, the computer simulates one of the devices to automatically communicate with the debugged device through a serial port, and finally displays data. The debugging can be performed according to the reply data of the tested device.
[0135] See also Figure 7,The automatic sending and receiving steps of this application can be implemented through the Labview program, first perform the system setting and initialization steps, select the communication protocol file path, then receive and process the data, and finally display and keep the sent data in the display window, which is convenient for the staff to debug.
[0136] See also Figure 8 , Another embodiment of the present application provides a simulation debugging system for a serial communication device, including: a protocol acquisition module 70, an automatic transceiver module 80;
[0137] Specifically, the protocol acquisition module 70 is used to acquire the communication protocol between any host and slave, such as Fig. 9 As shown, including:
[0138] The serial port setting and initialization unit 301 is used to set the first serial port parameters and the first resource flag connected to the arbitrary host and the second serial port parameters and the second resource flag connected to the arbitrary slave, and initialize the first serial port and the second serial port; the first resource flag and the second resource flag are used to distinguish the serial port data of the arbitrary host and the arbitrary slave;
[0139] The data receiving and processing unit 302 is used to receive the communication data between any host or any slave, add the corresponding first resource mark or second resource mark before the communication data, and add the communication data with the added resource mark to the cached data in the buffer area until the complete cached data is output;
[0140] The communication protocol storage unit 303 is used to store the complete cache data.
[0141] See also Fig.10 , which is a working diagram of the protocol admission module of this application. The host and the slave are any group of communicating devices, and the protocol admission module is divided into two or more receiving ports through a switching device, which are respectively connected to any host or any slave to receive data sent by any host or any slave.
[0142] Specifically, Fig.11 As shown, the automatic transceiver module 80 is used to receive the instruction of the host or slave under test, find the corresponding response information from the acquired communication protocol, and simulate the slave or host to send the response information to the host or slave under test, including:
[0143] The system setting and initialization unit 401 is used to set the serial port parameters and resource flags of the computer receiving end and the sending end, select the accepted communication protocol and read it into the buffer area, and initialize the serial port;
[0144] The data receiving and processing unit 402 is used to receive the instruction of the host or slave under test, search for the corresponding response information from the acquired communication protocol, and simulate the slave or host to send the response information to the host or slave under test.
[0145] Specifically, the simulation debugging system of the serial communication device also includes: a display module for displaying the data information sent and received in the protocol recording module and the automatic transceiver module.
[0146] See also Fig.12 , which is a working diagram of the automatic transceiver module of this application. The computer end is the automatic transceiver module, and the computer receiving end receives the instructions of the host or slave under test. After the automatic transceiver module processes the data, the computer sending end sends it to the host or slave under test.
[0147] Compared with the prior art, the simulation debugging method and system of serial communication equipment proposed in the present invention first record the communication protocol between a group of communication devices with an unknown communication protocol through protocol recording, save it after processing, then connect to the host or slave under test, and after receiving the data sent by the host or slave under test, find the corresponding corresponding information from the recorded communication protocol, simulate the slave or host to send the response information to the host or slave under test, and finally save the test results for staff to view.
[0148] See also Fig.13 Another embodiment of the present invention further provides an electronic device for executing the simulation debugging method of the serial communication device in the above embodiment. The electronic device includes:
[0149] One or more processors 710 and memory 720, Fig.13 A processor 710 is taken as an example.
[0150] The electronic device for executing the simulation debugging method of the serial communication device may further include: an input device 730 and an output device 740 .
[0151] The processor 710, the memory 720, the input device 730 and the output device 740 may be connected via a bus or other means. Fig.13 The example of connecting through bus is taken in the following.
[0152] The memory 720, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules (units) corresponding to the simulation debugging method of the serial communication device in the embodiment of the present invention. The processor 710 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 720, that is, the icon display method of the above method embodiment is realized.
[0153] The memory 720 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store information on the number of reminder items of the acquired application, etc. In addition, the memory 720 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 720 may optionally include a memory remotely disposed relative to the processor 710, and these remote memories may be connected to a processing device for list item operations via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0154] The input device 730 can receive input digital or character information and generate key signal input related to user settings and function control of the simulation debugging device of the serial communication device. The output device 740 can include display devices such as a display screen.
[0155] The one or more modules are stored in the memory 720, and when executed by the one or more processors 710, the simulation debugging method of the serial communication device in any of the above method embodiments is executed.
[0156] The above-mentioned product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided by the embodiment of the present invention.
[0157] The electronic device of the embodiment of the present invention may exist in various forms, including but not limited to:
[0158] (1) Mobile communication devices: These devices are characterized by their mobile communication functions and their main purpose is to provide voice and data communications. These terminals include: smart phones (such as iPhone), multimedia phones, functional phones, and low-end phones.
[0159] (2) Ultra-mobile personal computer devices: These devices fall into the category of personal computers, have computing and processing capabilities, and generally also have mobile Internet access features. These terminals include: PDA, MID and UMPC devices, such as iPad.
[0160] (3) Portable entertainment devices: These devices can display and play multimedia content. They include audio and video players (such as iPods), handheld game consoles, e-books, as well as smart toys and portable car navigation devices.
[0161] (4) Server: A device that provides computing services. The server consists of a processor, hard disk, memory, system bus, etc. The server is similar to a general computer architecture, but because it needs to provide highly reliable services, it has higher requirements in terms of processing power, stability, reliability, security, scalability, and manageability.
[0162] (5) Other electronic devices with reminder recording function.
[0163] The device embodiments described above are merely illustrative, wherein the units (modules) described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, i.e., they may be located in one place or distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0164] An embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the simulation debugging method of the serial communication device in any of the above method embodiments.
[0165] An embodiment of the present invention provides a computer program product, wherein the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, wherein when the program instructions are executed by an electronic device, the electronic device executes the simulation debugging method of the serial communication device in any of the above method embodiments.
[0166] Through the description of the above implementation methods, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.
[0167] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the principles or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A simulation debugging method for a serial communication device, characterized in that: include: Protocol admission steps: Admit the communication protocol between any host and slave; Automatic sending and receiving step: receiving the instruction of the host or slave under test, searching for the corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test; The protocol admission steps include: Serial port setting and initialization step: setting the first serial port parameter and the first resource flag connected to the arbitrary host and the second serial port parameter and the second resource flag connected to the arbitrary slave, and initializing the first serial port and the second serial port; the first resource flag and the second resource flag are used to distinguish the serial port data of the arbitrary host and the arbitrary slave; Data receiving and recording step: receiving the communication data between any host or any slave, adding the corresponding first resource mark or second resource mark before the communication data, adding the communication data with the added resource mark to the cache data in the buffer area, until the complete cache data is output; Communication protocol saving step: saving the complete cache data.
2. The simulation debugging method of the serial communication device according to claim 1, characterized in that: The data receiving and recording steps include: Step S101, read the number of bytes N1 of the buffer data received by the first serial port, N1 ≥ 0; Step S102, read the number of bytes N2 of the buffer data received by the second serial port, N2 ≥ 0; Step S103, setting the initial value of variable i1 to 0; Step S104: when N1≥1, read the buffer data received by the first serial port; when N1=0, execute step S108; Step S105, when the variable i1=0, adding the first resource flag before the buffer data received by the first serial port, otherwise executing step S106; Step S106, adding the buffer data received by the first serial port to the buffer data DataA; Step S107, subtract 1 from the number of bytes of data in the buffer area N1, add 1 to the variable i1, and then execute step S104; Step S108, setting the initial value of variable i2 to 0; Step S109, when N2≥1, read the buffer data received by the second serial port; when N2=0, execute step S113; Step S110, when the variable i2=0, adding the second resource flag before the buffer data received by the second serial port, otherwise executing step S111; Step S111, adding the buffer data received by the second serial port to the buffer data DataB; Step S112, subtract 1 from the number of bytes of data in the buffer area N2, add 1 to the variable i2, and then execute step S109; Step S113, outputting the cached data DataA and the cached data DataB; Step S114, displaying and adding the cached data DataA and DataB to the cached data Data_S; Step S115, clearing the cached data DataA and the cached data DataB; Step S116, waiting for a first preset time; Step S117: after receiving the serial port closing command, save the cache data Data_S, otherwise execute step S101.
3. The simulation debugging method of the serial communication device according to claim 1, characterized in that: The automatic sending and receiving step comprises: System setup and initialization steps: Set the serial port parameters and resource flags of the computer receiving and sending ends, select the accepted communication protocol and read it into the buffer area, and initialize the serial port; Data receiving and processing steps: receiving the instruction of the host or slave under test, searching for corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test.
4. The simulation debugging method of the serial communication device according to claim 2 or 3, characterized in that: The system setting and initialization step further includes: reading the communication protocol in the cache data Data_S into the cache area; initializing the serial port; When the device under test is a host, the computer receiving end resource flag is set to the first resource flag, and the computer sending end resource flag is set to the second resource flag; When the device under test is a slave, the resource flag of the computer receiving end is set to the second resource flag, and the resource flag of the computer sending end is set to the first resource flag.
5. The simulation debugging method of the serial communication device according to claim 3, characterized in that: The data receiving and processing steps include: Step S201, reading the number of bytes N of the buffer data received by the serial port of the computer receiving end, where N≥0; Step S202, when N≥1, read one byte of data from the receiving buffer of the serial port of the computer receiving end, and save the data as buffer data Data_R through the shift register, otherwise execute step S215; Step S203: When N≠1, execute step S204; otherwise, execute step S205; Step S204, subtract 1 from the number of bytes N of data in the buffer area, and then execute step S202; Step S205, displaying and saving the cache data Data_R; Step S206 , searching the cache data Data_R in the cache data Data_S, and intercepting the data after the cache data Data_R as data Data_Tem1 ; Step S207, when the data Data_Tem1 is not empty, search the data Data_Tem1 for the nearest computer receiving end resource mark, and intercept the data before the computer receiving end resource mark as data Data_Tem2; when the data Data_Tem1 is empty, the data Data_Tem2 is empty; Step S208, searching the data Data_Tem2 for the nearest resource mark of the computer sending end, and intercepting the data after the resource mark of the computer sending end as data Data_Tem3; Step S209: When the data Data_Tem3 is not empty, execute step S210; otherwise, execute step S204; Step S210, searching the data Data_Tem3 for the nearest resource mark of the computer sending end, and intercepting the data before the resource mark of the computer sending end as data Data_Tem4; Step S211, when the data Data_Tem4 is not empty, sending the data Data_Tem4 through the serial port; when the data Data_Tem4 is empty, sending the data Data_Tem3 through the serial port; Step S212, displaying and maintaining the sent data in the display window; Step S213, executing the assignment of the data Data_Tem3 to the data Data_Tem2; Step S214, wait for a second preset time and then execute step S208; Step S215, clearing the cached data Data_R, and then waiting for a third preset time; Step S216: After receiving the serial port closing command, save the data and complete the test; otherwise, execute step S201.
6. A simulation debugging system for serial communication equipment, characterized in that: include: Protocol recording module, used to record the communication protocol between any host and slave; An automatic transceiver module, used for receiving instructions from the host or slave under test, searching for corresponding response information from the acquired communication protocol, and simulating the slave or host to send the response information to the host or slave under test; The protocol admission modules include: A serial port setting and initialization unit, used for setting a first serial port parameter and a first resource flag for connecting to the arbitrary host and a second serial port parameter and a second resource flag for connecting to the arbitrary slave, and initializing the first serial port and the second serial port; the first resource flag and the second resource flag are used for distinguishing serial port data of the arbitrary host and the arbitrary slave; A data receiving and processing unit, used for receiving the communication data between any host or any slave, adding the corresponding first resource mark or second resource mark before the communication data, adding the communication data with the added resource mark to the cached data in the buffer area, until the complete cached data is output; The communication protocol storage unit is used to store the complete cache data.
7. The simulation debugging system of serial communication equipment according to claim 6, characterized in that: The automatic transceiver module comprises: System setting and initialization unit, used to set the serial port parameters and resource flags of the computer receiving and sending ends, select the accepted communication protocol and read it into the buffer area, and initialize the serial port; The data receiving and processing unit is used to receive the instruction of the host or slave under test, search for the corresponding response information from the acquired communication protocol, and simulate the slave or host to send the response information to the host or slave under test.
8. The simulation debugging system of serial communication equipment according to claim 6, characterized in that: Also includes: The display module is used to display the data information sent and received in the protocol admission module and the automatic sending and receiving module.
Citation Information
Patent Citations
Main control panel test method, device and system
CN103576667A
Communication mode recognizing method
CN103631747A