Vehicle-mounted equipment communication test method and system
By generating variable values for storing variable-length data in test protocols and linked lists, the problem of resource occupancy and low efficiency in on-board equipment communication tests is solved, and efficient data interaction and accurate test results are achieved.
Patent Information
- Application Number
- CN202510543971.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-28
- Publication Date
- 2025-07-18
AI Technical Summary
In the prior art, during the communication testing of on-vehicle equipment, due to the uncertain data length of uncertainty, a large amount of resources are occupied during the data interaction, and the testing efficiency is low.
By generating a test protocol, the variable length of variable length data is set to one, and the offset is generated based on the offset of fixed length data and variable length data. The variable value of variable length data is stored using a linked list, and compared with the expected value to obtain the test results.
It improves the anti-interference ability and testing efficiency during information transmission, ensuring data accuracy and convenience of the testing process.
Smart Images

Figure CN120342920A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle-mounted devices, and particularly to a method and system for testing vehicle-mounted device communication. Background Art
[0002] At present, various types of control information are transmitted in real time between the vehicle-mounted devices of a train to ensure the normal operation of the train. Therefore, it is becoming increasingly important to ensure that the vehicle-mounted devices can communicate normally and output data that meets the specifications.
[0003] In the prior art, to write data into memory, usually a write file storing fixed-length data and variable-length data is obtained. The fixed-length data includes the fixed-length data of a source data and the index information of the variable-length data of this source data, and the variable-length data includes the variable-length data of a source data. And in a byte-aligned manner, all the fixed-length data is read from the write file, and the read fixed-length data is written into memory. According to the index information included in the fixed-length data in the write file, the variable-length data corresponding to the index information is read from the write file, and the read variable-length data is written into memory.
[0004] Currently, in the related art during the writing process, due to the uncertain length of the variable-length data, corresponding information needs to be set for each variable-length data in the data, which occupies a large amount of resources during the data interaction process and results in low test efficiency. Summary of the Invention
[0005] Embodiments of this application provide a method and system for testing vehicle-mounted device communication to at least solve the problem of occupying a large amount of resources and low test efficiency during the data interaction process in the related art.
[0006] In a first aspect, embodiments of this application provide a method for testing vehicle-mounted device communication. The communication data includes variable-length data and fixed-length data, and is characterized by including:
[0007] A test protocol generation step of setting the variable length of any variable-length data to one, generating the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generating a test protocol according to the offset of the fixed-length data and the offset of the variable-length data; wherein, the next data of the current variable-length data is variable-length data or fixed-length data;
[0008] An analysis data step of positioning and extracting the variable value of the variable-length data for testing from the communication data according to the offset of the fixed-length data and the offset of the variable-length data in the test protocol, and generating a first linked list according to the offset and variable value of each variable-length data for testing;
[0009] Data testing steps: Set the expected values of each test variable-length data, obtain the variable values of the test variable-length data from the first linked list, compare the variable values of the test variable-length data with the corresponding expected values of the test variable-length data, and obtain the test results.
[0010] According to the offset in the test protocol, the fixed-length data and variable-length data can be distinguished from the communication data and stored independently, improving the anti-interference ability during information transmission.
[0011] In some of the embodiments, the offset includes a byte offset, and the test protocol generation step further includes:
[0012] Obtain the byte offset and variable length of the previous data of the current variable-length data;
[0013] Sum the byte offset and variable length of the previous data of the current variable-length data to obtain the byte offset of the current variable-length data.
[0014] According to the information of the previous data of the variable-length data, the position of the variable-length data in the communication data can be corresponding, improving the accuracy of data acquisition.
[0015] In some of the embodiments, the test protocol generation step further includes:
[0016] Sum the byte offset of the current variable-length data plus one to obtain the byte offset of the next data of the current variable-length data.
[0017] According to the byte offset of the variable-length data and the set variable length of the variable-length data, the position of the next data can be quickly and accurately determined, improving the positioning accuracy.
[0018] In some of the embodiments, during the process of storing the offset and variable values of each test fixed-length data and the offset and variable values of each test variable-length data in the first linked list respectively, according to the type of the test variable-length data, assign values to the test variable-length data, and store the test variable-length data as a whole in string form or store it byte by byte.
[0019] According to the type of the variable-length data, set the corresponding storage method, which is convenient for extracting the complete variable-length data during the test process, and thus improves the test efficiency.
[0020] In some of the embodiments, the data testing step further includes:
[0021] Obtain the variable value of any test variable-length data from the first linked list;
[0022] Obtain the expected value corresponding to the test variable-length data;
[0023] Compare the variable values of the variable-length data for the comparison test with the expected values corresponding to the variable-length data for the test. If the variable values of the variable-length data for the test are the same as the expected values corresponding to the variable-length data for the test, the test passes; if the variable values of the variable-length data for the test are different from the expected values corresponding to the variable-length data for the test, the test fails.
[0024] Based on the comparison result, determine whether the variable-length data in this test is correct, making the test process more intuitive and convenient.
[0025] In some of these embodiments, the communication data includes output data and further includes:
[0026] Output data extraction step: According to the offset in the test protocol, extract the variable-length data for the test and the fixed-length data for the test from the output data, and generate a second linked list based on the offset and variable value of the fixed-length data for the test in the output data and the offset and variable value of the variable-length data for the test in the output data.
[0027] Decompose the output data according to the test protocol. The decomposed data is not prone to errors and is also convenient for storage.
[0028] In some of these embodiments, the communication data further includes feedback data generated after the output data and further includes:
[0029] Data transmission step: According to the offset order in the test protocol, couple the fixed-length data for the test and the variable-length data for the test in the second linked list to generate a data frame, transmit the data frame, and obtain the feedback data.
[0030] During the process of outputting information outward, couple the output information according to the test protocol to form a complete data frame, avoiding missing data.
[0031] In a second aspect, an embodiment of the present application provides a vehicle-mounted device communication test system. The communication data includes variable-length data and fixed-length data, and includes:
[0032] Test protocol generation module: Configured to set the variable length of any variable-length data to one, generate the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generate a test protocol according to the offset of the fixed-length data and the offset of the variable-length data; wherein, the next data of the current variable-length data is variable-length data or fixed-length data;
[0033] Analysis data module: Configured to locate and extract the variable value of the variable-length data for the test from the communication data according to the offset of the fixed-length data and the offset of the variable-length data in the test protocol, and generate a first linked list according to the offset and variable value of each variable-length data for the test;
[0034] A data testing module, configured to set an expected value for each variable-length data for testing, obtain a variable value of the variable-length data for testing from a first linked list, compare the variable value of the variable-length data for testing with the expected value corresponding to the variable-length data for testing, and obtain a test result.
[0035] In some embodiments, the test system is connected to a device under test, and the communication data includes output data generated by the test system and further includes:
[0036] An output data extraction module, configured to extract variable-length data for testing and fixed-length data for testing from the output data according to an offset in a test protocol, and generate a second linked list based on the offset and variable value of the fixed-length data for testing in the output data and the offset and variable value of the variable-length data for testing in the output data.
[0037] In some embodiments, the communication data further includes feedback data generated by the device under test after receiving the output data, and further includes:
[0038] A data transmission module, configured to couple the fixed-length data for testing and the variable-length data for testing in the second linked list to generate a data frame in the order of the offsets in the test protocol, transmit the data frame to the device under test, and obtain the feedback data.
[0039] Compared with the related art, the vehicle-mounted device communication test method and system provided by the embodiments of the present application solve the problems of occupying a large amount of resources and low test efficiency during the data interaction process by reducing the dimension of the variable-length data and unifying the forms of the variable-length data and the fixed-length data, and improve the test efficiency.
[0040] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more concise and understandable. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments and descriptions thereof of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:
[0042] Figure 1 is a flowchart of a vehicle-mounted device communication test method according to an embodiment of the present application;
[0043] Figure 2 is another flowchart of a vehicle-mounted device communication test method according to an embodiment of the present application;
[0044] Figure 3 is a structural framework diagram of a vehicle-mounted device communication test system according to an embodiment of the present application;
[0045] Figure 4It is another structural framework diagram of the in-vehicle device communication test system according to an embodiment of the present application;
[0046] Figure 5 It is another structural framework diagram of the in-vehicle device communication test system according to an embodiment of the present application. Detailed implementation manners
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be described and explained below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments provided in the present application without creative efforts fall within the scope of protection of the present application.
[0048] Obviously, the accompanying drawings in the following description are only some examples or embodiments of the present application. For those of ordinary skill in the art, the present application can also be applied to other similar scenarios based on these drawings without creative efforts. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacturing or production changes based on the technical content disclosed in the present application are only conventional technical means and should not be understood as the content disclosed in the present application being insufficient.
[0049] Referring to "embodiments" in the present application means that specific features, structures or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase appears in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those of ordinary skill in the art explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments without conflict.
[0050] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the ordinary meanings understood by those of ordinary skill in the technical field to which this application pertains. The words such as "a", "an", "one", "the" and the like involved in this application do not indicate a limitation in quantity and may represent a singular or plural number. The terms "comprise", "include", "have" and any variations thereof involved in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may further include steps or units not listed, or may further include other steps or units inherent to these processes, methods, products or devices. The words such as "connect", "be connected", "couple" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "plurality" involved in this application means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the front and rear associated objects. The terms "first", "second", "third" and the like involved in this application are only used to distinguish similar objects and do not represent a specific order of the objects.
[0051] The on-train equipment includes train network control system equipment, passenger information system controller equipment, signal system equipment, traction control system, braking control system equipment, etc. Each equipment transmits various types of control information in real time within the system or between systems, such as status information, fault information, command information, etc., to ensure the normal operation of the train.
[0052] The commonly used communication protocols for on-train equipment can be TCP / UDP protocol, MVB protocol, TRDP protocol, RS485 protocol, etc. For the convenience of parsing, most of the communication protocols between equipment have a fixed length, such as 32 bytes, 1024 bytes, etc. Each variable in the protocol can correspond to a certain byte and a certain bit. After receiving the data, both communication parties can parse the specific variable value at the fixed position according to the protocol.
[0053] In actual communication, the lengths of many pieces of information, such as fault information, commands, etc., will change with the operation of the train. For example, when device A transmits fault information to device B, device A may have 0, 1 or more faults at a certain moment, and the number of bytes occupied by transmitting the faults will change. The crew control center sends prompt information to the in-car display for display, and the communication byte lengths for information of different contents are different. For example, the display of the next stop arrival, the display of the train speed, the passenger no-smoking prompt, etc. At this time, the specific variable positions in the protocol are no longer fixed, causing certain difficulties in data parsing.
[0054] To verify the product function, the test device needs to simulate the input data and send it to the product under test, and then detect whether the output data of the product meets the specifications.
[0055] For fixed-length communication, the test process is relatively simple. The input variable information is placed into the data frame according to the specified byte and bit offsets and sent to the device. In the output information, the variables to be verified are parsed according to the fixed byte and bit offsets. Finally, the actual feedback variable value is compared with the expected value to obtain the test result.
[0056] The expected value is the data set manually and expected to be achieved. In the transmitted communication data, different variable-length data correspond to different expected values. By judging whether the variable-length data in the communication data is correct, it is further judged whether the test device is operating normally.
[0057] After receiving the communication data, the variable values of multiple variable-length data in the communication data are parsed. For example, according to the data type of the variable-length data, the expected value can be set to "0x01, 0x02, 0x03,...", or can be set to "next station is beijing".
[0058] If there is variable-length information in the communication data, the length of the data frame cannot be estimated, and the internal variable offset will also change continuously, making it difficult to implement automated testing. The general approach is to manually prepare a complete communication data in advance, send it to the device under test, and then use protocol capture software to capture the corresponding output, and manually analyze whether all the data, including the variable-length data, meets the specifications. This process is less efficient.
[0059] The following table is the communication protocol formulated by the conventional communication parties, including fixed-length data and variable-length data, where the variable-length data area and the fixed-length data are presented as ordinary variables in the computer.
[0060]
[0061]
[0062] Considering that there is a lot of variable-length information in the communication of train on-vehicle equipment, to solve the above problems and improve the product test efficiency, this embodiment provides a method for testing the communication of on-vehicle equipment. Figure 1 is a flowchart of the method for testing the communication of on-vehicle equipment according to an embodiment of the present application, as Figure 1 shown. The communication data includes variable-length data and fixed-length data, and this process includes the following steps:
[0063] Test protocol generation step S101: Set the variable length of any variable-length data to one. Generate the offset of the current variable-length data and the offset of the next data of the current variable-length data based on the variable length of the current variable-length data and the previous data of the current variable-length data. Generate a test protocol based on the offset of the fixed-length data and the offset of the variable-length data. Here, the next data of the current variable-length data is either variable-length data or fixed-length data.
[0064] In the test protocol, taking any variable-length data as a reference, the two adjacent data above and below it are respectively the previous data of the variable-length data and the next data of the variable-length data.
[0065] Analysis data step S102: Based on the offset of the fixed-length data and the offset of the variable-length data in the test protocol, locate and extract the variable value of the variable-length data for testing from the communication data, and generate a first linked list according to the offset and variable value of each variable-length data for testing.
[0066] Data testing step S103: Set the expected value of each variable-length data for testing, obtain the variable value of the variable-length data for testing from the first linked list, compare the variable value of the variable-length data for testing with the corresponding expected value of the variable-length data for testing, and obtain the test result.
[0067] Among them, the variable value is used to represent the actual content of the communication data. The variable value of the variable-length data is the actual data content of the variable-length data. After the test protocol is generated, the test protocol can be imported into the test tool. Since there is no longer variable-length data formally in the test protocol and all are unified into variables with fixed offsets, the test tool no longer needs to consider the impact of variable-length data on testing. When writing test cases, the operations of all variables are the same, in the form of "variable = value".
[0068] For example, the variable value of ordinary data can be set as: A = 25. The variable value of the variable-length data of string type can be set as: B = "For your safety, please do not smoke in the carriage". The variable value of the variable-length data of data type can be set as C = "0x11, 0x22, 0x33".
[0069] Through the above steps, a test protocol is generated to reduce the variable-length data to variable-length variables, making the variable-length data and the fixed-length data unified in variable form and simplifying the complex processing process. Through the analysis data step, according to the offset in the test protocol, the fixed-length data and the variable-length data can be distinguished from the communication data and stored independently, improving the anti-interference ability during the information transmission process. Through the data testing step, comparing the obtained variable-length data with the expected value facilitates more accurately testing whether the data is reasonable.
[0070] In the test protocol and communication data, the arrangement order of fixed-length data and variable-length data is fixed and the same. The offset of the fixed-length data is determined according to the data type of the fixed-length data. Fixed-length data includes common variable types in computer storage, such as bool, char, short, int, double, Unsigned char, Unsigned shrot, Unsigned int, etc. The fixed-length variable corresponding to the fixed-length data occupies a fixed number of bytes in storage, such as 1 byte, 2 bytes, 4 bytes, etc., and its corresponding offset is set to 1, 2, 4.
[0071] The variable-length data is a continuous piece of data that changes with the communication time, and the number of bytes occupied by each transmission may be different.
[0072] Since the existing communication protocol has a variable length, the data information has no fixed offset and is difficult to search. In this application, the test protocol is generated to clarify the byte offset and bit offset of all communication variables, so as to accurately store and extract variables according to the byte offset and bit offset. Because the length of the variable-length data is constantly changing, in this application, the variable-length data area is first dimensionally reduced, that is, a variable-length data area is set as a special variable. Regardless of the actual length, whether it contains a single physical meaning or multiple independent physical meanings, it is stored and tested as a whole.
[0073] In the test protocol, for the sake of formal unity, the length occupied by the variable-length variable corresponding to the variable-length data in the protocol is set to 1, which is convenient for arranging the offsets of all variables.
[0074] The following table is the generated test protocol, including fixed-length variables and variable-length variables:
[0075]
[0076]
[0077] Due to the fact that the actual data length is not fixed, a linked list is used to store each variable, and all variable information is stored in a total linked list with byte and bit offsets as indexes, such as: {<byte offset, bit offset, value of variable 1>, <byte offset, bit offset, value of variable 2>,..., <byte offset, bit offset, value of variable N>}. The purpose of doing this is to decouple the variables in the communication and reduce the impact of variable-length variables on other data, so that each variable can be processed independently.
[0078] In some of the embodiments, the offset includes a byte offset, and the test protocol generation step further includes:
[0079] Obtain the byte offset and variable length of the previous data of the current variable-length data.
[0080] Sum the byte offset of the previous data of the current variable-length data and the variable length to obtain the byte offset of the current variable-length data.
[0081] The variables in the test protocol correspond one by one to the content in the communication data. Based on the information of the previous data of the variable-length data, the position of the variable-length data in the communication data can be corresponded, improving the accuracy of data acquisition and thus the efficiency of information interaction.
[0082] For example, if the previous variable offset of the variable-length variable corresponding to the variable-length data is 7, and the type is char, which occupies 1 byte, then the byte offset of the variable-length variable is 7 + 1 = 8.
[0083] In some of these embodiments, the test protocol generation step further includes:
[0084] Sum the byte offset of the current variable-length data plus one to obtain the byte offset of the next data of the current variable-length data.
[0085] Since the variable length of the variable-length data is defined as one, the byte offset of the next data of the variable-length data can also be deduced. The test protocol can improve the data capture efficiency, accurately locate, and reduce the situation where the uncertain length of the variable-length data affects the subsequent data acquisition.
[0086] The length occupied by the variable-length variable in the test protocol is preset to one. The sum of the byte offset of the variable-length variable plus one obtains the byte offset of the next variable adjacent to the variable-length variable.
[0087] In some of these embodiments, during the process of storing the offset and variable value of each fixed-length test data and the offset and variable value of each variable-length test data in the first linked list respectively, according to the type of the variable-length test data, the variable-length test data is assigned a value, and the variable-length test data is stored as a whole in string form or stored one by one in byte form.
[0088] Set the corresponding storage method according to the type of the variable-length data, which is convenient for extracting the complete variable-length data during the test process, thereby improving the test efficiency.
[0089] For a variable-length variable formed by dimensionality reduction of a segment of variable-length data, in order to facilitate understanding of the variable value during the subsequent test process, two variable types, string or data, are set to identify the variable type.
[0090] When the variable-length variable is of string type, it is used to label the character-type variable-length data, which has a clear character meaning. For example, "Next station is XXX". During the test case writing process, the specific text content can be directly assigned, and the computer stores it as a whole in string form, which is more intuitive.
[0091] When the variable-length variable is of the data type, the data type is a byte storage type. This type can be used for all types except character types. When writing test cases, assign values according to the actual test content. For example, "0x01, 0x02,..., 0xXX". All byte data must be 16-bit data starting with 0x, and the bytes are separated by commas. The computer stores them byte by byte.
[0092] The writing of test cases can be changed according to the actual situation.
[0093] In some of these embodiments, the data testing step further includes:
[0094] Obtain the variable value of any test variable-length data from the first linked list.
[0095] Obtain the expected value corresponding to the test variable-length data.
[0096] Compare the variable value of the test variable-length data with the expected value corresponding to the test variable-length data. If the variable value of the test variable-length data is the same as the expected value corresponding to the test variable-length data, the test passes. If the variable value of the test variable-length data is different from the expected value corresponding to the test variable-length data, the test fails.
[0097] For the communication information to be tested, according to the variable byte offset specified in the test protocol, read the variable value of each variable-length data, and call the corresponding set expected value to compare the variable value of each variable-length data with the expected value. According to the comparison result, judge whether the variable-length data of this test is correct, making the test process more intuitive and convenient.
[0098] For example, if the expected value of the variable-length data is "0x01, 0x02, 0x03,...", and the variable value of the read variable-length data is "0x01, 0x03, 0x04,...", then the test judgment conclusion is that it fails. If the expected value of the variable-length data is "nextstation is beijing", and the variable value of the read variable-length data is "next station is beijing", then the test judgment conclusion is that it passes.
[0099] In some of these embodiments, the communication data includes output data, and this test method further includes:
[0100] An output data extraction step, according to the offset in the test protocol, extract the test variable-length data and the test fixed-length data from the output data, and generate a second linked list based on the offset and variable value of the test fixed-length data in the output data and the offset and variable value of the test variable-length data in the output data.
[0101] During the entire test process, when outputting information externally, it is necessary to process the output data in the communication data. The output data is disassembled according to the test protocol. The disassembled data is not prone to errors and is also convenient for storage.
[0102] Both the first linked list and the second linked list can store the offsets and variable values of variable-length data, as well as the offsets and variable values of fixed-length data.
[0103] A set of complete communication data includes fixed-length data and variable-length data. The fixed-length data and variable-length data are disassembled separately according to the test protocol and stored in the first linked list or the second linked list. The fixed-length data and variable-length data from the same set of communication data are stored in the same linked list. When combination is required, the data is re-integrated according to the arrangement order of the fixed-length data and variable-length data in the test protocol. This is not only convenient for disassembling from the communication data and storing separately, with the data not interfering with each other, but also convenient for ensuring the correctness of the data and avoiding data chaos during combination.
[0104] In some of the embodiments, the communication data further includes feedback data generated after the output data, and the test method further includes:
[0105] A data transmission step of coupling the test fixed-length data and test variable-length data in the second linked list to generate a data frame according to the offset order in the test protocol, transmitting the data frame, and obtaining the feedback data.
[0106] During the process of outputting information externally, the output information is coupled according to the test protocol to form a complete data frame, avoiding missing data and reducing the situation of the entire test going wrong due to lack of data.
[0107] The embodiments of the present application are described and illustrated below through preferred embodiments.
[0108] Figure 2 is a flowchart of a vehicle-mounted device communication test method according to a preferred embodiment of the present application. As Figure 2 shown, the vehicle-mounted device communication test method includes the following steps:
[0109] A test protocol generation step S101 of setting the variable length of any variable-length data to one, generating the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generating a test protocol according to the offset of the fixed-length data and the offset of the variable-length data. Wherein, the next data of the current variable-length data is variable-length data or fixed-length data.
[0110] Output data extraction step S201: According to the offsets in the test protocol, extract the variable-length test data and fixed-length test data from the output data, and generate a second linked list based on the offsets and variable values of the fixed-length test data and the offsets and variable values of the variable-length test data in the output data.
[0111] Data transmission step S202: In the order of the offsets in the test protocol, couple the fixed-length test data and variable-length test data in the second linked list to generate a data frame, transmit the data frame, and obtain feedback data.
[0112] Analysis data step S203: According to the offsets of the fixed-length data and variable-length data in the test protocol, locate and extract the variable values of the variable-length test data from the communication data, and generate a first linked list based on the offsets and variable values of each variable-length test data.
[0113] Data testing step S103: Set the expected value of each variable-length test data, obtain the variable value of the variable-length test data from the first linked list, compare the variable value of the variable-length test data with the corresponding expected value of the variable-length test data, and obtain the test result.
[0114] During the test, the test tool sends output data to the in-vehicle device according to the test protocol. After receiving the output data, the in-vehicle device operates according to the output data and returns feedback data to the test tool. The feedback data includes variable-length data and fixed-length data. For the variable-length data in the feedback data, testing is required. Since the data length of the variable-length data is not determined, the variable-length data needs to be accurately extracted through the test protocol, and then it is judged whether the data is reasonable to obtain the test result.
[0115] It should be noted that the steps shown in the above process or the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described here can be executed in a different order.
[0116] This embodiment also provides an in-vehicle device communication test system, which is used to implement the above embodiment and the preferred implementation manners, and those that have been described will not be repeated. As used hereinafter, terms such as "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0117] Figure 3 is a structural block diagram of the in-vehicle device communication test system according to an embodiment of the present application, as Figure 3As shown, the communication data includes variable-length data and fixed-length data, and the test system includes:
[0118] A test protocol generation module 301, configured to set the variable length of any variable-length data to one, generate the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generate a test protocol according to the offset of the fixed-length data and the offset of the variable-length data. Wherein, the next data of the current variable-length data is variable-length data or fixed-length data.
[0119] An analysis data module 302, configured to locate and extract the variable values of the test variable-length data from the communication data according to the offset of the fixed-length data and the offset of the variable-length data in the test protocol, and generate a first linked list according to the offset and variable value of each test variable-length data.
[0120] A data test module 303, configured to set the expected value of each test variable-length data, obtain the variable value of the test variable-length data from the first linked list, compare the variable value of the test variable-length data with the expected value corresponding to the test variable-length data, and obtain a test result.
[0121] Figure 4 is a preferred structural block diagram of an in-vehicle device communication test system according to an embodiment of the present application. As Figure 4 shown, the test system includes Figure 4 all the modules shown. In addition, the test system is connected to the device under test, and the communication data includes output data generated by the test system. The test system further includes:
[0122] An output data extraction module 401, configured to extract test variable-length data and fixed-length data from the output data according to the offset in the test protocol, and generate a second linked list according to the offset and variable value of the test fixed-length data in the output data and the offset and variable value of the variable-length data of the test output data.
[0123] A data transmission module 402, configured to couple the test fixed-length data and the test variable-length data in the second linked list to form a data frame in the order of the offsets in the test protocol, transmit the data frame to the device under test, and obtain feedback data.
[0124] As Figure 5 shown, the test protocol of the present application can cooperate with the existing actual communication protocol. The test system is configured with corresponding test software to detect whether the feedback data is correct. After the test software issues the output data, it passes through the test protocol and is stored in the linked list. The linked list includes fixed-length data and variable-length data. The fixed-length data and variable-length data are coupled to form a complete data frame and are sent to the device under test through the actual communication protocol.
[0125] After receiving the output data, the device under test operates according to the content in the output data and generates feedback data. The feedback data is sent back to the test software. During the transmission of the feedback data, first, the actual communication protocol is transmitted to the test system. The test system decouples the feedback data according to the test protocol, decomposes it into variable-length data and fixed-length data, and stores it in a linked list for the test software to extract the required data for testing.
[0126] The communication data is stored in the memory of the test computer and interacts with the test software at any time. The decoupling operation is to split and store the variables in the communication data, which is convenient for access during subsequent testing.
[0127] After the test system generates the output data, it extracts each variable one by one and places it in the linked list for storage according to the byte offset and bit offset specified by the test protocol.
[0128] Before the data to be output is sent to the device under test, a coupling operation is performed to splice all the variables in the linked list together according to the specified offset order of the test protocol to form a complete frame of data for transmission.
[0129] Through the decoupling and coupling operations of the data, the data with a dynamically changing original length is changed so that each variable can accurately read or modify the variable value according to the offset, making the variable access orderly and facilitating the implementation of subsequent automated testing.
[0130] It should be noted that each of the above modules can be a functional module or a program module, and can be implemented either by software or by hardware. For the modules implemented by hardware, each of the above modules can be located in the same processor; or each of the above modules can also be located in different processors in any combined form.
[0131] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combinations of these technical features do not conflict, they should all be considered as within the scope described in this specification.
[0132] The above embodiments only represent several implementation manners of the present application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A communication test method for in-vehicle devices, where the communication data includes variable-length data and fixed-length data, characterized in that, Including: A test protocol generation step, setting the variable length of any variable-length data to one, generating the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generating a test protocol according to the offset of the fixed-length data and the offset of the variable-length data; wherein, the next data of the current variable-length data is variable-length data or fixed-length data; An analysis data step, positioning and extracting the variable value of the test variable-length data from the communication data according to the offset of the fixed-length data and the offset of the variable-length data in the test protocol, and generating a first linked list according to the offset and variable value of each test variable-length data; A data testing step, setting the expected value of each test variable-length data, obtaining the variable value of the test variable-length data from the first linked list, comparing the variable value of the test variable-length data with the expected value corresponding to the test variable-length data, and obtaining a test result.
2. The vehicle-mounted device communication test method according to claim 1, wherein The offset includes a byte offset, and the test protocol generation step further includes: Obtaining the byte offset and variable length of the previous data of the current variable-length data; Adding the byte offset and variable length of the previous data of the current variable-length data to obtain the byte offset of the current variable-length data.
3. The vehicle-mounted device communication test method according to claim 2, wherein The test protocol generation step further includes: Adding one to the byte offset of the current variable-length data and summing to obtain the byte offset of the next data of the current variable-length data.
4. The vehicle-mounted device communication test method according to claim 1, characterized in that In the process of storing the offset and variable value of each test fixed-length data and the offset and variable value of each test variable-length data in the first linked list respectively, assigning values to the test variable-length data according to the type of the test variable-length data, and storing the test variable-length data as a whole in string form or storing it one by one in byte form.
5. The vehicle-mounted device communication test method according to claim 1, characterized in that The data testing step further includes: Obtaining the variable value of any test variable-length data from the first linked list; Obtaining the expected value corresponding to the test variable-length data; Comparing the variable value of the test variable-length data with the expected value corresponding to the test variable-length data. If the variable value of the test variable-length data is the same as the expected value corresponding to the test variable-length data, the test passes; if the variable value of the test variable-length data is different from the expected value corresponding to the test variable-length data, the test fails.
6. The vehicle-mounted device communication test method according to any one of claims 1-5, characterized in that, The communication data includes output data, and further includes: An output data extraction step, extracting the test variable-length data and test fixed-length data from the output data according to the offset in the test protocol, and generating a second linked list according to the offset and variable value of the test fixed-length data of the output data and the offset and variable value of the test variable-length data of the output data; 7. The vehicle-mounted device communication test method according to any one of claims 6, characterized in that, The communication data further includes feedback data generated after the output data, and further includes: A data transmission step, coupling the test fixed-length data and test variable-length data in the second linked list to generate a data frame according to the offset order in the test protocol, transmitting the data frame, and obtaining feedback data.
8. A vehicle-mounted device communication test system, wherein the communication data includes variable-length data and fixed-length data, characterized in that Including: A test protocol generation module, configured to set the variable length of any variable-length data to one, generate the offset of the current variable-length data and the offset of the next data of the current variable-length data according to the variable length of the current variable-length data and the previous data of the current variable-length data, and generate a test protocol according to the offset of the fixed-length data and the offset of the variable-length data; wherein, the next data of the current variable-length data is variable-length data or fixed-length data; An analysis data module, configured to locate and extract the variable value of the variable-length data for testing from the communication data according to the offset of the fixed-length data and the offset of the variable-length data in the test protocol, and generate a first linked list according to the offset and variable value of each variable-length data for testing; A data testing module, configured to set the expected value of each variable-length data for testing, obtain the variable value of the variable-length data for testing from the first linked list, compare the variable value of the variable-length data for testing with the expected value corresponding to the variable-length data for testing, and obtain a test result.
9. The in-vehicle device communication test system according to claim 8, characterized in that, The test system is connected to the device under test, and the communication data includes output data generated by the test system, and further includes: An output data extraction module, configured to extract the variable-length data for testing and the fixed-length data for testing from the output data according to the offset in the test protocol, and generate a second linked list according to the offset and variable value of the fixed-length data for testing of the output data and the offset and variable value of the variable-length data for testing of the output data.
10. The in-vehicle device communication test system according to claim 9, characterized in that, The communication data further includes feedback data generated by the device under test after receiving the output data, and further includes: A data transmission module, configured to couple the fixed-length data for testing and the variable-length data for testing in the second linked list to generate a data frame according to the offset order in the test protocol, transmit the data frame to the device under test, and obtain the feedback data.