Serial port test method and device, electronic equipment and computer readable storage medium
By obtaining and running test scripts, the problems of complex operation and low efficiency in the existing technology are solved, and efficient and accurate serial port test results are achieved.
Patent Information
- Application Number
- CN202411571139.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2024-12-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, serial port testing requires integrating multi-interface penetration protocols, serial port debugging and script automation programs on the upper computer. The operation is complex, low efficiency and susceptible to human errors.
By obtaining test scripts, running scripts to transmit and receive data, automatically judge the serial port test results, avoiding human operations and subjective judgments.
It improves the efficiency and accuracy of serial port testing, simplifies the operation process, and reduces the impact of human errors.
Smart Images

Figure CN119088632A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automated testing technology, and in particular to a serial port testing method, device, electronic equipment and computer-readable storage medium. Background Art
[0002] Serial interface is abbreviated as serial port, also known as serial communication interface or serial communication interface. It is an expansion interface using serial communication. The serial interface uses a data transmission method that transmits data one bit at a time. The communication line is simple, two-way communication can be achieved, and the communication cost is low. It is suitable for long-distance communication. Serial port testing refers to the testing activities of the serial interface, which checks the performance and function of the device by sending and receiving commands.
[0003] In the related art, the serial interface is usually tested by the following method: the host computer sends the test command to the test board, the test board executes the command sent by the host computer, and reads the serial port log information to determine whether the test device correctly performs the relevant operation to obtain the serial port test result. However, the above method requires the integration of multi-interface penetration protocol, serial port debugging and script automation program in the host computer, which is complicated to operate. Summary of the invention
[0004] In view of this, the embodiments of the present disclosure propose a serial port testing method, device, electronic device and computer-readable storage medium to solve the problem in the related art that it is necessary to integrate multiple interface penetration protocols, serial port debugging and script automation programs in the host computer, and the operation is complicated.
[0005] According to a first aspect of the present disclosure, a serial port testing method is provided, including: obtaining a test script; transmitting first test data to a second circuit board based on a target serial port by running the test script; receiving second test data returned by the second circuit board through the target serial port; and determining a test result of the target serial port based on the first test data and the second test data.
[0006] According to a second aspect of the present disclosure, a serial port testing device is provided, including: an acquisition module for acquiring a test script; a test module for transmitting first test data to a second circuit board based on a target serial port by running the test script; the test module is also used to receive second test data returned by the second circuit board through the target serial port; the test module is also used to determine a test result of the target serial port based on the first test data and the second test data.
[0007] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory storing a program, wherein the program comprises instructions, and when the instructions are executed by the processor, the processor executes the above-mentioned serial port test method.
[0008] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned serial port testing method.
[0009] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects: In the serial port testing method provided in the exemplary implementation of the present disclosure, a test script is obtained; by running the test script, first test data is transmitted to the second circuit board based on the target serial port; the second test data returned by the second circuit board through the target serial port is received; based on the first test data and the second test data, the test result of the target serial port is determined. In the serial port testing method of the embodiment of the present disclosure, after the first circuit board obtains the test script, the first test data can be sent to the second circuit board through the target serial port by running the obtained test script, and after obtaining the second test data returned by the second circuit board, it can be determined whether the target serial port passes the test based on the sent first test data and the received second test data. At the same time, since the first circuit board can automatically execute the test process through the test script after obtaining the test script, the test efficiency can be improved, and the influence of human errors and subjective judgments can be avoided, thereby improving the accuracy and reliability of the test results.
[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Further details, features and advantages of the present disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which: Figure 1 A flowchart of a serial port testing method according to an exemplary embodiment of the present disclosure is shown; Figure 2 An interactive flow chart of another serial port testing method according to an exemplary embodiment of the present disclosure is shown; Figure 3 A schematic block diagram of a serial port testing device according to an exemplary embodiment of the present disclosure is shown; Figure 4 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0012] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0013] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0014] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0015] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0016] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0017] The embodiments of the present disclosure provide a serial port testing method, device, electronic device and computer readable storage medium. The following describes the scheme of the present disclosure with reference to the accompanying drawings.
[0018] The present disclosure first provides a serial port testing method. Figure 1 As shown, the serial port testing method is applied to the first circuit board, and specifically includes the following steps: S110: Obtain a test script; S120: Transmitting first test data to the second circuit board based on the target serial port by running the test script; S130: receiving second test data returned by the second circuit board through the target serial port; S140: Determine a test result of the target serial port based on the first test data and the second test data.
[0019] In the serial port testing method provided by the embodiment of the present disclosure, after obtaining the test script, the first circuit board can send the first test data to the second circuit board through the target serial port by running the obtained test script. After obtaining the second test data returned by the second circuit board, it can be determined whether the target serial port passes the test based on the sent first test data and the received second test data. At the same time, since the first circuit board can automatically execute the test process through the test script after obtaining the test script, the test efficiency can be improved, and the influence of human errors and subjective judgments can be avoided, thereby improving the accuracy and reliability of the test results.
[0020] Next, in another embodiment, the above steps are described in more detail.
[0021] In step S110 , a test script is obtained.
[0022] In the disclosed embodiment, the test script is a series of instructions for executing the serial port test. By running the test script, the functional test of the corresponding serial port can be implemented. Exemplarily, the test script can be used to test whether the corresponding serial port can communicate normally and whether the data transmission during the communication process is normal.
[0023] In the disclosed embodiment, the above serial port is also called a serial communication interface, which transmits data by sequentially transmitting one bit at a time. The serial communication interface has a simple communication line, can realize two-way communication, and has low communication cost, and is suitable for long-distance communication.
[0024] In the embodiment of the present disclosure, illustratively, the above serial communication interface may be an RS485 interface.
[0025] In the disclosed embodiment, the RS485 interface is an interface for data transmission, which is an interface implemented based on differential transmission technology, can support multi-point connection, and has the advantages of high speed, security and reliability. The RS485 interface supports half-duplex communication (RS, Recommended Standard), and the RS in the RS485 interface represents a half-duplex communication mode. Specifically, the RS485 interface includes a set of standard interface definitions, such as device interface, data transmission format, control signal and other functions.
[0026] In the disclosed embodiments, the above-mentioned differential transmission is a signal transmission technology. Different from the traditional method of one signal line and one ground line, differential transmission transmits signals on both lines. The two signals have the same amplitude and opposite phase. The signal transmitted on these two lines is a differential signal. The signal receiving end determines the logical state sent by the transmitting end by comparing the difference between the two voltages. On the circuit board, the differential routing must be two lines of equal length, equal width, close proximity, and on the same layer.
[0027] In the disclosed embodiments, the above-mentioned half-duplex data transmission means that data can be transmitted in two directions of a signal carrier, but not at the same time. That is, at any time during the communication process, information can be transmitted from A to B, and from B to A, but at the same time, only one direction of transmission can exist, that is, at the same time, only from A to B, or from B to A.
[0028] In the embodiment of the present disclosure, the above-mentioned first circuit board is a circuit board used to test whether the serial communication interface function is normal. The first circuit board and the second circuit board below realize data transmission based on the serial communication interface. Exemplarily, the serial communication interface at this time can be the above-mentioned RS485 interface.
[0029] In the disclosed embodiment, the test script can be stored in the host computer, and the process of the first circuit board obtaining the test script can be implemented as follows: establish a network connection between the host computer and the first circuit board; the host computer sends the test script to the first circuit board through the established network connection; the first circuit board stores the obtained test script in the board. It should be noted that obtaining the test script by this method requires ensuring that the network between the host computer and the first circuit board is unobstructed.
[0030] In the disclosed embodiment, the host computer refers to a computer or single-chip microcomputer that can directly send operation instructions, generally providing a user operation interactive interface and displaying feedback data to the user. At this time, the first circuit board can be regarded as a lower computer that establishes a network connection with the host computer. Among them, the lower computer refers to a computer or single-chip microcomputer directly connected to the machine, which is generally used to receive and feedback the instructions of the host computer, and control the machine to perform actions and read data from the machine sensor according to the instructions. The following communication can be performed between the host computer and the lower computer: the host computer sends a control command to the lower computer, and the lower computer receives this command and performs the corresponding action; the host computer sends a status acquisition command to the lower computer, and after the lower computer receives the status acquisition command, it calls the corresponding sensor to measure, and converts the measured data into digital information and feeds it back to the host computer; the lower computer actively sends status information or alarm information to the host computer.
[0031] In the disclosed embodiment, the above-mentioned acquisition of the test script can, illustratively, also be implemented as follows: real-time detection of whether a storage medium is connected to the data reading interface; if it is detected that the storage medium is connected to the data reading interface, reading the test script from a specified directory of the storage medium.
[0032] In the embodiment of the present disclosure, the storage medium may be a USB flash drive, and the test script may be pre-stored in a designated directory of the USB flash drive. For example, the designated directory may be pre-established in the USB flash drive, and the test script may be stored in the designated directory.
[0033] In the disclosed embodiment, the first circuit board detects in real time whether a storage medium is connected to the data reading interface, so that when the storage medium is detected to be connected, it further inquires whether the storage medium has the above-mentioned designated directory, and obtains the test script under the designated directory. Specifically, the first circuit board can determine whether a USB flash drive is connected by detecting the voltage change of the Universal Serial Bus (USB) interface, and when the USB flash drive is detected to be connected, it searches for the above-mentioned designated directory in the USB flash drive, and after finding the designated directory, it reads the test script in the designated directory and writes it to the card board.
[0034] In the disclosed embodiment, since the storage medium such as the USB flash drive is connected to the first circuit board through the USB interface, there is no requirement for the network to obtain the test script based on this method. That is, in the absence of a network, the test script can also be obtained, and the serial communication interface can be tested by running the test script, which has a wider applicability.
[0035] In step S120, the first test data is transmitted to the second circuit board based on the target serial port by running the test script.
[0036] In the embodiment of the present disclosure, the target serial port is a serial communication interface for executing the test based on the test script. Exemplarily, the target serial port may be the RS485 interface.
[0037] In the embodiment of the present disclosure, the first test data is data used to test whether the target serial port can communicate normally and whether the data transmission during the communication process is normal.
[0038] In the embodiment of the present disclosure, the first test data may be a combination of characters, numbers or symbols. For example, the first test data may be "ABCD".
[0039] In the embodiment of the present disclosure, the second circuit board is used to receive the first test data sent by the first circuit board and return data to the first circuit board to implement the test of the target serial port function.
[0040] In the embodiment of the present disclosure, the above-mentioned transmission of the first test data to the second circuit board based on the target serial port by running the test script can be achieved as follows: after copying the test script to the board, setting the above-mentioned target serial port to the sending data mode, and using the target serial port to send the above-mentioned first test data to the above-mentioned second circuit board.
[0041] In step S130, second test data returned by the second circuit board through the target serial port is received.
[0042] In the embodiment of the present disclosure, the second test data is data returned by the second circuit board to the first circuit board after receiving the first test data sent by the first circuit board, so that the first circuit board determines the test result of the target serial port based on the second test data and the first test data.
[0043] In the embodiment of the present disclosure, the above-mentioned second test data can be the first test data, that is, after receiving the first test data sent by the first circuit board, the second circuit board returns the received first test data to the first circuit board, so that the first circuit board determines the test result of the target serial port based on the sent and received first test data.
[0044] In the disclosed embodiment, the second test data may be data obtained by processing the first test data. That is, after receiving the first test data sent by the first circuit board, the second circuit board performs data processing operations such as encryption on the received first test data to obtain the second test data, and returns the data to the first circuit board, so that the first circuit board determines the test result of the target serial port based on the sent first test data and the received processed second test data.
[0045] In the embodiment of the present disclosure, the second test data is the encrypted data obtained after the second circuit board performs encryption operation on the first test data. Then, the second circuit board performs data encryption operation on the received first test data to obtain the second test data. The process can be implemented as follows: the first test data is arranged in reverse order. Taking the first test data as "ABCD" as an example, this step performs reverse order on ABCD to obtain DCBA; based on the American Standard Code for Information Interchange (ASCII), the characters are converted into ASCII codes. For example, the above string DCBA is converted into ASCII code, which should be 068067066065; a random number from 0 to 9 is added every three digits. For example, according to this rule, a random number is added to the ASCII code 068067066065 obtained by the above conversion to obtain 0685067306680651. It should be noted that the above scenario is an exemplary description, and the protection scope of the embodiment of the present disclosure is not limited thereto. For example, the second circuit board can also use other encryption operations to encrypt the above first test data to obtain the second test data.
[0046] In the disclosed embodiment, by performing an encryption operation on the first test data to obtain the second test data, the second test data is then returned to the first circuit board through the target serial port, thereby ensuring the integrity and confidentiality of the data during data transmission, and eliminating interference of other factors in the serial port test.
[0047] In step S140 , a test result of the target serial port is determined based on the first test data and the second test data.
[0048] In the embodiment of the present disclosure, after receiving the second test data returned by the second circuit board, the first circuit board may determine the test result of the target serial port based on the first test data and the second test data.
[0049] In an embodiment of the present disclosure, if the second circuit board does not process the first test data after receiving the first test data, that is, the second circuit board directly returns the received first test data to the circuit board as the second test data, then the above-mentioned test result of determining the target serial port based on the first test data and the second test data can be implemented as follows: compare the first test data and the second test data; if the first test data is consistent with the second test data, then it is judged that the target serial port has passed the test; if the first test data is inconsistent with the second test data, then it is judged that the target serial port has not passed the test.
[0050] In an embodiment of the present disclosure, if the second circuit board performs a data processing operation on the first test data after receiving the first test data, then the first circuit board needs to perform a reverse operation of the above data processing operation on the received second test data after receiving the second test data returned by the second circuit board, and compare the data obtained by the reverse operation with the first test data. If the comparison is consistent, it is determined that the target serial port has passed the test; if the comparison is inconsistent, it is determined that the target serial port has failed the test.
[0051] In the disclosed embodiment, if the second test data is encrypted data obtained after the second circuit board performs an encryption operation on the first test data, then the test result of the target serial port determined based on the first test data and the second test data can be implemented as follows: perform a decryption operation corresponding to the encryption operation on the second test data to obtain decrypted data corresponding to the second test data; compare the decrypted data with the first test data, and determine the test result of the target serial port based on the comparison result. Among them, the comparison of the decrypted data with the first test data and the determination of the test result of the target serial port based on the comparison result can be specifically implemented as follows: compare the decrypted data with the first test data; if the decrypted data is consistent with the first test data, it is determined that the target serial port has passed the test; if the decrypted data is inconsistent with the first test data, it is determined that the target serial port has not passed the test.
[0052] In the embodiment of the present disclosure, the decryption operation corresponding to the encryption operation is performed on the second test data to obtain decrypted data corresponding to the second test data. Exemplarily, it can be implemented as follows: based on the encryption operation, an inverse operation of the encryption operation is determined to obtain a decryption operation; and a decryption operation is performed on the second test data to obtain decrypted data corresponding to the second test data.
[0053] In the embodiment of the present disclosure, taking the first test data as "ABCD" and the second test data obtained by encryption operation as 0685067306680651 as an example, the decryption operation is specifically implemented as follows: for the second test data 0685067306680651, delete one digit every three digits to obtain 068067066065; convert the ASCII code into the character string DCBA based on the standard information exchange code; arrange the character string DCBA in reverse order to obtain ABCD.
[0054] It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiment of the present disclosure is not limited to this. Other data encryption algorithms and their corresponding decryption algorithms can also be used to implement the above process, such as symmetric encryption algorithms, public key encryption algorithms, etc.
[0055] In an embodiment of the present disclosure, after determining the test result of the target serial port based on the first test data and the second test data, the test result can also be displayed to the tester. Exemplarily, the above test result can be displayed in the following manner: based on the test result, the corresponding signal light is lit, and the above signal light is used to indicate whether the target serial port passes the test. Specifically, if the target serial port passes the test, the light emitting diode (LED) is controlled to light green; if the target serial port fails the test, the LED is controlled to light red. It should be noted that the above scenario is only an exemplary description, and displaying the test results in other ways also falls within the protection scope of the embodiment of the present disclosure.
[0056] In the serial port testing method provided by the embodiment of the present disclosure, after obtaining the test script, the first circuit board can send the first test data to the second circuit board through the target serial port by running the obtained test script. After obtaining the second test data returned by the second circuit board, it can be determined whether the target serial port passes the test based on the sent first test data and the received second test data. At the same time, since the first circuit board can automatically execute the test process through the test script after obtaining the test script, the test efficiency can be improved, and the influence of human errors and subjective judgments can be avoided, thereby improving the accuracy and reliability of the test results.
[0057] Below, in another embodiment, taking the above-mentioned target serial port as an RS485 interface as an example, the process of the above-mentioned serial port testing method is described in detail: In the disclosed embodiment, the test board (corresponding to the first circuit board) reads the RS485 serial port test program (corresponding to the test script) from the USB flash drive (corresponding to the storage medium), and runs the RS485 serial port test program to realize data transmission with the auxiliary board (corresponding to the second circuit board) through the RS485 serial port (corresponding to the target serial port), thereby realizing the test of the RS485 serial port. Figure 2 As shown in the figure, the U disk, test board and auxiliary board can realize the interface test of RS485 serial port through the following interactive steps: S210: Store the RS485 serial port test program to a specified directory in the U disk.
[0058] In the embodiment of the present disclosure, this step is used to place the RS485 serial port test program in a specified directory, which is pre-set in the startup script of the test board (corresponding to the above-mentioned first circuit board). By executing the above-mentioned startup script, it can be detected whether the connected storage device contains the specified directory.
[0059] In the disclosed embodiment, in addition to pre-setting the designated directory, the above-mentioned startup script will also copy the RS485 serial port test program under the designated directory to the test board (corresponding to the above-mentioned first circuit board), and execute the RS485 serial port test program to determine whether the RS485 serial port can communicate normally and whether the data transmission during the communication process is normal through the RS485 serial port test program.
[0060] S220: When it is detected that a USB flash drive is inserted, it is detected whether a specified directory exists in the USB flash drive.
[0061] In the embodiment of the present disclosure, when the test board detects that a USB flash drive is inserted, it can further detect whether the USB flash drive contains the above-mentioned designated directory. If the designated directory is detected in the above-mentioned USB flash drive, then continue to execute step S230.
[0062] S230: Get the RS485 serial port test program from the specified directory of the USB flash drive.
[0063] In the disclosed embodiment, when a designated directory is detected in the USB flash drive, the test board copies the RS485 serial port test program from the designated directory in the USB flash drive.
[0064] S240: Automatically run the RS485 serial port test program.
[0065] In the disclosed embodiment, after the RS485 serial port test program is copied to the test board, the test board automatically runs the RS485 serial port test program.
[0066] S250: Sends specified data to the auxiliary board through the RS485 serial port.
[0067] In the embodiment of the present disclosure, the designated data is the first test data. Exemplarily, the designated data may be ABCD. Specifically, the step may be implemented as follows: the test board sets the RS485 serial port to a data transmission mode, and sends the designated data to the auxiliary board through the RS485 serial port.
[0068] S260: Receive and encrypt designated data.
[0069] In the disclosed embodiment, the auxiliary board receives the designated data sent by the test board in this step, and performs encryption operation on the received designated data. Taking the designated data ABCD as an example, the encryption process can be specifically implemented by the following steps: sorting the designated data ABCD in reverse order to obtain DCBA; converting the characters into ASCII codes based on the standard information exchange code, that is, converting the above string DCBA into 068067066065; adding a random number from 0 to 9 every three digits, for example, adding a random number to the ASCII code 068067066065 obtained by the above conversion according to this rule, 0685067306680651 can be obtained.
[0070] In the disclosed embodiment, by performing encryption operation on the designated data and returning the encrypted data obtained by the encryption operation to the test board through the RS485 serial port, the integrity and confidentiality of the data can be ensured during the data transmission process, and the interference of other factors on the serial port test can be eliminated.
[0071] S270: Send the encrypted data to the test board.
[0072] In the disclosed embodiment, the auxiliary board sends the encrypted designated data (corresponding to the second test data) to the test board through the RS485 serial port, so that the subsequent test board determines whether the RS485 serial port passes the test based on the encrypted designated data and the original designated data.
[0073] S280: Decrypt the received data.
[0074] In the disclosed embodiment, after receiving the designated data returned by the auxiliary board after the encryption operation, the test board performs the decryption operation corresponding to the above encryption operation on the received encrypted data. Specifically, taking the encrypted data obtained by the above encryption as 0685067306680651 as an example, the decryption process of the encrypted data can be specifically implemented as follows: for the encrypted data 0685067306680651, delete one digit every three digits to obtain 068067066065; convert the ASCII code into the string DCBA based on the standard information exchange code; and arrange the string DCBA in reverse order to obtain ABCD.
[0075] S290: Determine whether the decrypted data is consistent with the sent specified data.
[0076] In the disclosed embodiment, after the test board performs a decryption operation on the encrypted data corresponding to the specified data, the test board compares the specified data and the decrypted data. If the comparison result is consistent, it is determined that the RS485 serial port has passed the test and step S291 is continued; if the comparison result is inconsistent, it is determined that the RS485 serial port has not passed the test and step S292 is continued.
[0077] S291: control the LED to light green; S292: Control the LED to light up red.
[0078] In the serial port test method provided in the embodiment of the present disclosure, after obtaining the RS485 serial port test program, the test board sends specified data to the auxiliary board through the RS485 serial port by running the obtained serial port test program. After the auxiliary board performs encryption operation on the specified data, the encrypted data is returned to the test board. The test board can judge whether the RS485 serial port passes the test based on the specified data and the data returned by the auxiliary board. In the above process, after obtaining the test program, the test board can automatically run the obtained test program to execute the test process, thereby improving the test efficiency, avoiding the influence of human errors and subjective judgments, and improving the accuracy and reliability of the test results. At the same time, since the test board in the embodiment of the present disclosure obtains the RS485 serial port test program by reading the specified directory in the U disk, the test program can also be obtained in the absence of a network, and the RS485 serial communication interface is tested by running the test program, and the applicability is wider. In addition, by performing encryption operations on the specified data and returning the encrypted data obtained by the encryption operation to the test board through the RS485 serial port, the embodiment of the present disclosure can also ensure the integrity and confidentiality of the data during data transmission and eliminate interference with the serial port test by other factors.
[0079] The above mainly introduces the solution provided by the embodiment of the present invention from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present invention can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0080] The embodiment of the present invention can divide the functional modules of the serial port test device according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present invention is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0081] The present disclosure provides a serial port testing device. Figure 3 As shown, the serial port testing device 300 may include an acquisition module 310 and a testing module 320, wherein: Get module, used to get test scripts; A test module, configured to transmit first test data to the second circuit board based on a target serial port by running a test script; The test module is further used to receive second test data returned by the second circuit board through the target serial port; The test module is further used to determine the test result of the target serial port based on the first test data and the second test data.
[0082] In the disclosed embodiment, the acquisition module is specifically used to: detect in real time whether a storage medium is connected to the data reading interface; if it is detected that the storage medium is connected to the data reading interface, read the test script from a specified directory of the storage medium.
[0083] In the disclosed embodiment, the second test data is encrypted data obtained after the second circuit board performs encryption operation on the first test data.
[0084] In the disclosed embodiment, the test module is specifically used to: perform a decryption operation corresponding to the encryption operation on the second test data to obtain decrypted data corresponding to the second test data; compare the decrypted data with the first test data, and determine the test result of the target serial port based on the comparison result.
[0085] In the embodiment of the present disclosure, the above-mentioned test module is specifically used to: compare the decrypted data and the first test data; if the decrypted data is consistent with the first test data, it is determined that the target serial port has passed the test; if the decrypted data is inconsistent with the first test data, it is determined that the target serial port has not passed the test.
[0086] In the disclosed embodiment, the serial port test device further includes a display module, which is specifically used to: based on the test result, light up a corresponding signal light, the signal light is used to indicate whether the target serial port passes the test. Exemplarily, if the target serial port passes the test, the light emitting diode (LED) is controlled to light up green; if the target serial port fails the test, the LED is controlled to light up red.
[0087] In the disclosed embodiment, the test module is specifically used to: determine the inverse operation of the encryption operation based on the encryption operation to obtain the decryption operation; perform the decryption operation on the second test data to obtain the decrypted data corresponding to the second test data.
[0088] In addition, the specific implementation details of the above serial port testing device have been described in detail in the corresponding position of the serial port testing method, so they will not be repeated here.
[0089] Figure 4 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 4 , which shows a structural schematic diagram of an electronic device 400 suitable for implementing the embodiments of the present disclosure. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0090] like Figure 4 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 to a random access memory (RAM) 403 to implement the serial port test method of the embodiment described in the present disclosure. In RAM403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, ROM402, and RAM403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0091] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0092] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart, thereby implementing the serial port test method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0093] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0094] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0095] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0096] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: Get the test script; By running the test script, transmitting the first test data to the second circuit board based on the target serial port; Receiving second test data returned by the second circuit board through the target serial port; A test result of the target serial port is determined based on the first test data and the second test data.
[0097] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0098] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0099] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0100] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0101] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0102] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0103] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0104] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0105] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A serial port testing method, characterized in that: Applied to the first circuit board, comprising: Get the test script; By running the test script, transmitting the first test data to the second circuit board based on the target serial port; Receiving second test data returned by the second circuit board through the target serial port; A test result of the target serial port is determined based on the first test data and the second test data.
2. The serial port testing method according to claim 1, characterized in that: The obtaining of the test script comprises: Real-time detection of whether the data reading interface has storage media access; If it is detected that the storage medium is connected to the data reading interface, the test script is read from a designated directory of the storage medium.
3. The serial port testing method according to claim 1, characterized in that: The second test data is encrypted data obtained after the second circuit board performs encryption operation on the first test data.
4. The serial port testing method according to claim 3, characterized in that: The step of determining a test result of the target serial port based on the first test data and the second test data includes: Performing a decryption operation corresponding to the encryption operation on the second test data to obtain decrypted data corresponding to the second test data; The decrypted data and the first test data are compared, and the test result of the target serial port is determined based on the comparison result of the decrypted data and the first test data.
5. The serial port testing method according to claim 4, characterized in that: The comparing the decrypted data and the first test data, and determining the test result of the target serial port based on the comparison result of the decrypted data and the first test data, includes: comparing the decrypted data and the first test data; If the decrypted data is consistent with the first test data, it is determined that the target serial port passes the test; If the decrypted data is inconsistent with the first test data, it is determined that the target serial port has failed the test.
6. The serial port testing method according to claim 1, characterized in that: After determining the test result of the target serial port, the method further includes: Based on the test result, a corresponding signal light is turned on, and the signal light is used to indicate whether the target serial port passes the test.
7. The serial port testing method according to claim 4, characterized in that: The performing a decryption operation corresponding to the encryption operation on the second test data to obtain decrypted data corresponding to the second test data includes: Determine an inverse operation of the encryption operation based on the encryption operation to obtain the decryption operation; The decryption operation is performed on the second test data to obtain the decrypted data corresponding to the second test data.
8. A serial port testing device, characterized in that: include: Get module, used to get test scripts; A test module, configured to transmit first test data to the second circuit board based on a target serial port by running the test script; The test module is further used to receive second test data returned by the second circuit board through the target serial port; The testing module is further configured to determine a test result of the target serial port based on the first testing data and the second testing data.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.
Citation Information
Patent Citations
System and method for detecting vehicle-mounted equipment based on GMS system
CN111452834A
CAN network automatic test box and use method thereof
CN112650196A
Test method and device based on configurable interface, equipment and medium
CN113468049A
Power distribution 5G communication encryption system and communication encryption method based on Internet of Things
CN115589586A
Automatic test method, device and equipment of circuit board and storage medium
CN115963379A
Cited By
Automatic test method and system based on serial port communication
CN119473745A
