A control test method for electronic control unit (ECU) of new energy vehicle
By performing homologous calculation of binary test data and test codes and verification of sha256 digest algorithm, the leakage problem of fuzzy test data sets in ECU test of new energy vehicles is solved, and the safety and reliability of ECU tests are achieved.
Patent Information
- Application Number
- CN202411192220.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2044-08-28
AI Technical Summary
The testing method of the ECU of the electronic control unit of the new energy vehicle in the prior art fails to effectively process the fuzzy test data set, resulting in the risk of source code leakage.
By calculating the binary test data with the binary test code, we ensure that the number of characters of P and Q is consistent, and the correctness of the automotive test data is used to verify the accuracy of the car test data to prevent leakage during the transmission process.
It ensures the security of automotive test data, prevents leakage during the transmission process, and improves the safety and reliability of ECU tests.
Smart Images

Figure CN119065352B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automobile technology, and in particular to a control and testing method for an electronic control unit (ECU) of a new energy vehicle. Background Art
[0002] CAN is a serial communication protocol bus designed for real-time applications and effectively supports distributed control systems. It is one of the most widely used fieldbuses worldwide. The CAN protocol was originally developed by Bosch in Germany in the 1980s specifically for the automotive industry. Due to its high performance, high reliability, and unique CAN-bus technology, it has gained increasing attention and is widely used in industrial control. Patent application number 202011339860X, entitled "A Vehicle ECU Security Testing Method and Apparatus," discloses a method that includes: acquiring vehicle CAN bus data, dividing CAN bus data with the same frame ID into a single dataset as a raw dataset; where different frame IDs correspond to different ECUs; determining whether each raw dataset belongs to a single-value dataset, a multi-value dataset, or a full-value dataset; constructing a corresponding fuzzy test dataset based on the characteristics of each raw dataset; and transmitting the data in each fuzzy test dataset to the CAN bus to determine the security of each vehicle ECU. However, this invention does not implement security processing for the fuzzy test dataset, which may lead to source code leakage. Summary of the Invention
[0003] The present invention aims to at least solve the technical problems existing in the prior art, and in particular innovatively proposes a control test method for an electronic control unit (ECU) of a new energy vehicle.
[0004] In order to achieve the above-mentioned object of the present invention, the present invention provides a control test method for an electronic control unit (ECU) of a new energy vehicle, comprising the following steps:
[0005] S1, the new energy vehicle electronic control unit ECU obtains the test code and test data sent by the host computer;
[0006] S2, the new energy vehicle electronic control unit ECU converts the test data obtained in step S1 into binary test data;
[0007] S3, the new energy vehicle electronic control unit ECU converts the test code obtained in step S1 into a binary test code;
[0008] S4, the new energy vehicle electronic control unit ECU determines the size relationship between P and Q, making the sizes of P and Q consistent;
[0009] S5, performing parity calculation on the binary test data obtained in step S4 and the binary test code to obtain vehicle test data;
[0010] In S6, the automotive test data is sent to the test unit via CAN communication for testing.
[0011] In a preferred embodiment of the present invention, in step S4, the method for making the magnitude between P and Q the same is as follows:
[0012] If P > Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then q zeros or ones are added after the binary test code; proceed to the next step;
[0013] If P < Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then p bits are subtracted from the binary test code; proceed to the next step;
[0014] If P = Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then proceed to the next step.
[0015] In a preferred embodiment of the present invention, step S4 is
[0016] The electronic control unit ECU of the new energy vehicle determines the magnitude relationship between P and Q:
[0017] If P > Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then q zeros are added after the binary test code; proceed to the next step;
[0018] If P < Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then p bits are subtracted from the binary test code; proceed to the next step;
[0019] If P = Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then proceed to the next step.
[0020] In a preferred embodiment of the present invention, the calculation method of q in step S4 is:
[0021] q = P - Q, <O000085>where q is the number of added ones;
[0023] P represents the number of characters of the binary test data;
[0024] Q represents the number of characters of the binary test code.
[0025] In a preferred embodiment of the present invention, the calculation method of p in step S4 is:
[0026] p = Q - P,
[0027] where p represents the number of subtracted ones;
[0028] P represents the number of characters in the binary test data;
[0029] Q represents the number of character bits in the binary test code.
[0030] In a preferred embodiment of the present invention, in step S5, the binary test data obtained in step S4 is subjected to parity calculation with the binary test code to obtain the vehicle test data as follows:
[0031] P1P2P3…P J ⊙Q1Q2Q3…Q J =P1′P2′P3′…P J ′,
[0032] Wherein, P1 represents the value at the first position from left to right in the binary test data;
[0033] P2 represents the value at the second position from left to right in the binary test data;
[0034] P3 represents the value at the third position from left to right in the binary test data;
[0035] P J Indicates the value at the Jth position from left to right in the binary test data;
[0036] Q1 represents the value of the first bit from left to right in the binary test code;
[0037] Q2 represents the value of the second bit from left to right in the binary test code;
[0038] Q3 represents the value of the third bit from left to right in the binary test code;
[0039] Q J Indicates the value at the Jth position from left to right in the binary test code;
[0040] P1′ represents the first value from left to right in the car test data;
[0041] P2′ represents the second value from left to right in the car test data;
[0042] P3′ represents the third value from left to right in the vehicle test data;
[0043] P J ′ represents the value at the Jth position from left to right in the car test data;
[0044] ⊙ represents the same position operator;
[0045] J represents the total number of digits;
[0046] P1P2P3…P J Represents binary test data;
[0047] Q1Q2Q3…Q J represents a binary test code;
[0048] P1′P2′P3′…P J ′ represents the car test data.
[0049] In a preferred embodiment of the present invention, P j The calculation method of ′ is:
[0050]
[0051] Among them, P j ' represents the value at the jth position from left to right in the test data to be sent;
[0052] If means logical condition if;
[0053] P j Represents the value at the jth position from left to right in the binary test data;
[0054] Q j Indicates the value at the jth position from left to right in the binary test code;
[0055] or indicates logical condition or;
[0056] and represents the logical condition and;
[0057] J represents the total number of digits.
[0058] In summary, due to the adoption of the above technical solution, the present invention can ensure the security of automobile test data and prevent leakage during the transmission process.
[0059] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:
[0061] Figure 1 It is a schematic block diagram of the process of the present invention. DETAILED DESCRIPTION
[0062] Embodiments of the present invention will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where like or similar reference numerals denote like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present invention and should not be construed as a limitation to the present invention.
[0063] The present invention discloses a method for controlling and testing an electronic control unit (ECU) of a new energy vehicle, as Figure 1 shown, which includes the following steps:
[0064] S1, the electronic control unit (ECU) of the new energy vehicle obtains the test code and test data sent by the host computer (laptop or computer PC);
[0065] S2, the electronic control unit (ECU) of the new energy vehicle converts the test data obtained in step S1 into binary test data;
[0066] S3, the electronic control unit (ECU) of the new energy vehicle converts the test code obtained in step S1 into binary test code;
[0067] S4, the electronic control unit (ECU) of the new energy vehicle determines the size relationship between P and Q:
[0068] If P > Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then add q zeros or ones after the binary test code; proceed to the next step;
[0069] If P < Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then reduce p bits after the binary test code; proceed to the next step;
[0070] If P = Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then proceed to the next step;
[0071] Make the number of characters of P and Q the same through step S4;
[0072] S5, perform bitwise calculation on the binary test data and the binary test code after step S4 to obtain vehicle test data;
[0073] S6, send the vehicle test data to the test unit through CAN communication for testing. The test unit can be an engine system, an air conditioning system, an indicator light system, etc.
[0074] In a preferred embodiment of the present invention, step S4 is
[0075] The electronic control unit (ECU) of the new energy vehicle determines the size relationship between P and Q:
[0076] If P > Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then add q zeros after the binary test code; perform the next step;
[0077] If P < Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then reduce p bits after the binary test code; perform the next step;
[0078] If P = Q, where P is the number of characters of the binary test data and Q is the number of characters of the binary test code, then perform the next step.
[0079] In a preferred embodiment of the present invention, the calculation method of q in step S4 is:
[0080] q = P - Q,
[0081] where q is the number of added zeros;
[0082] P represents the number of characters of the binary test data;
[0083] Q represents the number of characters of the binary test code.
[0084] In a preferred embodiment of the present invention, the calculation method of p in step S4 is:
[0085] p = Q - P,
[0086] where p represents the number of reduced bits;
[0087] P represents the number of characters of the binary test data;
[0088] Q represents the number of characters of the binary test code.
[0089] In a preferred embodiment of the present invention, in step S5, the method of obtaining the vehicle test data by performing bit - by - bit calculation of the binary test data after step S4 and the binary test code is:
[0090] P1P2P3…P J ⊙Q1Q2Q3…Q J =P1′P2′P3′…P J ′,
[0091] [[ID=5l]]where P1 represents the value at the 1st position from left to right in the binary test data; P2 represents the value at the 2nd position from left to right in the binary test data;
[0092] P3 represents the value at the 3rd position from left to right in the binary test data;
[0093] P J represents the value at the Jth position from left to right in the binary test data;
[0094] Q1 represents the value of the first bit from left to right in the binary test code;
[0095] Q2 represents the value of the second bit from left to right in the binary test code;
[0096] Q3 represents the value of the third bit from left to right in the binary test code;
[0097] Q J Indicates the value at the Jth position from left to right in the binary test code;
[0098] P1′ represents the first value from left to right in the car test data;
[0099] P2′ represents the second value from left to right in the car test data;
[0100] P3′ represents the third value from left to right in the car test data; P J ′ represents the value at the Jth position from left to right in the car test data;
[0101] ⊙ represents the same position operator;
[0102] J represents the total number of digits;
[0103] P1P2P3…P J Represents binary test data;
[0104] Q1Q2Q3…Q J represents a binary test code;
[0105] P1′P2′P3′…P J ′ represents the car test data.
[0106] In a preferred embodiment of the present invention, P j The calculation method of ′ is:
[0107]
[0108] Among them, P j ' represents the value at the jth position from left to right in the test data to be sent; if represents the logical condition if;
[0109] P j Represents the value at the jth position from left to right in the binary test data;
[0110] Q j Indicates the value at the jth position from left to right in the binary test code;
[0111] or indicates logical condition or;
[0112] and represents the logical condition and;
[0113] J represents the total number of digits.
[0114] In a preferred embodiment of the present invention, step S5 further includes calculating the vehicle code corresponding to the vehicle test data and determining whether the binary vehicle code is consistent with the binary test code:
[0115] If the binary car code is consistent with the binary test code, the car test data is correct car test data;
[0116] If the binary vehicle code is inconsistent with the binary test code, the vehicle test data is erroneous vehicle test data.
[0117] In a preferred embodiment of the present invention, the method for calculating the vehicle code corresponding to the vehicle test data is:
[0118] Cardatastring=Datastringenerateway(Cartestcode),
[0119] Among them, Cardatastring represents the car code calculated based on the car test data;
[0120] Datastringenerateway() represents the calculation method of the car code, which can use the sha256 digest algorithm;
[0121] Cartestcode represents car test data.
[0122] In a preferred embodiment of the present invention, in step S1, the method for generating test data includes the following steps:
[0123] S11, obtaining the test data to be sent;
[0124] S12, converting the test data obtained in step S11 into binary test data, and generating a test code of the test data according to the binary test data;
[0125] S13, converting the test code in step S12 into a binary test code;
[0126] S14, determine the size relationship between U and V:
[0127] If U>V, where U is the number of bits in the binary test data and V is the number of bits in the binary test code, then add v 0s or 1s after the binary test code and proceed to the next step.
[0128] If U < V, where U is the number of character bits of the binary test data and V is the number of character bits of the binary test code, then reduce u bits at the end of the binary test code; perform the next step;
[0129] If U = V, where U is the number of character bits of the binary test data and V is the number of character bits of the binary test code, then perform the next step;
[0130] Make the number of character bits of U and V the same through step S14;
[0131] S15. Perform bit-by-bit calculation on the binary test data after step S14 and the binary test code to obtain the actual test data to be sent;
[0132] S16. Send the test code and the actual test data to be sent to the test vehicle using the host computer.
[0133] In a preferred embodiment of the present invention, step S14 is as follows:
[0134] Judge the size relationship between U and V:
[0135] If U > V, where U is the number of character bits of the binary test data and V is the number of character bits of the binary test code, then add v zeros at the end of the binary test code; perform the next step;
[0136] If U < V, where U is the number of character bits of the binary test data and V is the number of character bits of the binary test code, then reduce u bits at the end of the binary test code; perform the next step;
[0137] If U = V, where U is the number of character bits of the binary test data and V is the number of character bits of the binary test code, then perform the next step;
[0138] Make the number of character bits of U and V the same through step S14.
[0139] In a preferred embodiment of the present invention, the calculation method of v in step S14 is as follows:
[0140] v = U - V,
[0141] where v is the number of added bits;
[0142] U represents the number of character bits of the binary test data;
[0143] V represents the number of character bits of the binary test code.
[0144] In a preferred embodiment of the present invention, the calculation method of u in step S14 is as follows:
[0145] u = V - U,
[0146] where u represents the number of reduced bits;
[0147] U represents the number of characters in the binary test data;
[0148] V represents the number of character bits in the binary test code.
[0149] In a preferred embodiment of the present invention, in step S15, the binary test data after step S14 is subjected to parity calculation with the binary test code to obtain the actual test data to be sent as follows:
[0150] U1U2U3…U K ⊙V1V2V3…V K =U1′U2′U3′…U′ K ,
[0151] Among them, U1 represents the value at the first position from left to right in the binary test data;
[0152] U2 represents the value at the second position from left to right in the binary test data;
[0153] U3 represents the value at the third position from left to right in the binary test data;
[0154] U K Indicates the value at the Kth position from left to right in the binary test data;
[0155] V1 represents the value of the first bit from left to right in the binary test code;
[0156] V2 represents the value of the second bit from left to right in the binary test code;
[0157] V3 represents the value of the third bit from left to right in the binary test code;
[0158] V K Indicates the value at the Kth position from left to right in the binary test code;
[0159] U1′ represents the value of the first bit from left to right in the actual test data to be sent;
[0160] U2′ represents the value of the second bit from left to right in the actual test data to be sent;
[0161] U3′ represents the value of the third bit from left to right in the actual test data to be sent;
[0162] U′ K Indicates the value at the Kth position from left to right in the actual test data to be sent;
[0163] ⊙ represents the same position operator;
[0164] K represents the total number of digits;
[0165] U1U2U3…U K Represents binary test data;
[0166] V1V2V3…V K represents a binary test code;
[0167] U1′U2′U3′…U′ K Indicates the actual test data to be sent;
[0168] U k The calculation method of ′ is:
[0169]
[0170] Among them, U k ' represents the value at the kth position from left to right in the actual test data to be sent;
[0171] If means logical condition if;
[0172] U k Represents the value at the kth position from left to right in the binary test data;
[0173] V k Indicates the value at the kth position from left to right in the binary test code;
[0174] or indicates logical condition or;
[0175] and represents the logical condition and;
[0176] K represents the total number of digits.
[0177] In a preferred embodiment of the present invention, the method for generating a test code of the test data according to the binary test data in step S12 is:
[0178] Testingstring=Testingstringenerateway(Testdata),
[0179] Among them, Testingstring represents the test code generated according to the obtained test data;
[0180] Testingstringenerateway() indicates the method of generating the test code, which can use the sha256 digest algorithm;
[0181] Testdata means obtaining the test data to be tested.
[0182] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to the embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the claims and their equivalents.
Claims
1. A new energy vehicle electronic control unit ECU control test method, characterized in that: It includes the following steps: S1. The electronic control unit (ECU) of a new energy vehicle obtains the test code and test data sent by the host computer. The generation method of the test data and test code includes the following steps: S11. Obtain the test data to be sent. S12. Convert the test data obtained in step S11 into binary test data, and generate the test code of the test data according to the binary test data. S13. Convert the test code in step S12 into a binary test code. S14. Judge the size relationship between U and V. U is the number of characters of the binary test data, and V is the number of characters of the binary test code: If U > V, add v zeros or ones after the binary test code; v = U - V, and v is the number of added ones; then execute the next step. If U < V, reduce u bits after the binary test code; u = V - U, and u represents the number of reduced bits; then execute the next step. If U = V, then execute the next step. Make the number of characters of U and V the same through step S14. S15. Perform a bit-by-bit calculation on the binary test data and the binary test code after step S14 to obtain the actual test data to be sent. S16. Use the host computer to send the test code and the actual test data to be sent to the test vehicle. S2. The electronic control unit (ECU) of a new energy vehicle converts the test data obtained in step S1 into binary test data. S3. The electronic control unit (ECU) of a new energy vehicle converts the test code obtained in step S1 into a binary test code. S4. The electronic control unit (ECU) of a new energy vehicle judges the size relationship between P and Q. P is the number of characters of the binary test data, and Q is the number of characters of the binary test code, and make P and Q the same in size. The method to make P and Q the same in size is as follows: If P > Q, add q zeros or ones after the binary test code; q = P - Q, and q is the number of added ones; then execute the next step. If P < Q, reduce p bits after the binary test code; p = Q - P, and p represents the number of reduced bits; then execute the next step. If P = Q, then execute the next step. S5. Perform a bit-by-bit calculation on the binary test data and the binary test code after step S4 to obtain the vehicle test data.
2. The new energy vehicle electronic control unit ECU control test method according to claim 1 is characterized in that: S6. Send the vehicle test data to the test unit through CAN communication for testing. , in, Indicates the value at the first position from left to right in the binary test data; Indicates the value at the second position from left to right in the binary test data; Indicates the value at the third position from left to right in the binary test data; Indicates the value at the Jth position from left to right in the binary test data; Indicates the value of the first bit from left to right in the binary test code; Indicates the value of the second bit from left to right in the binary test code; Indicates the value of the third bit from left to right in the binary test code; Indicates the value at the Jth position from left to right in the binary test code; Indicates the value at the first position from left to right in the car test data; Indicates the second value from left to right in the car test data; Indicates the third value from left to right in the car test data; Indicates the value at the Jth position from left to right in the car test data; Represents the bitwise equality operator; In step S5, the method to perform a bit-by-bit calculation on the binary test data and the binary test code after step S4 to obtain the vehicle test data is as follows: Represents binary test data; represents a binary test code; Represents automobile test data.
3. The new energy vehicle electronic control unit ECU control test method according to claim 1 is characterized in that: The calculation method is: ,j=1、2、3、……、J, in, Indicates the value at the jth position from left to right in the test data to be sent; J represents the total number of bits. Represents the value at the jth position from left to right in the binary test data; Indicates the value at the jth position from left to right in the binary test code; if represents the logical condition if. or represents the logical condition or. and represents the logical condition and. J represents the total number of bits.
Citation Information
Patent Citations
White-box testing method and system
CN107038110A
Interface test method and device based on binary data communication, equipment and medium
CN113626322A
Real vehicle test equipment, system and test method thereof
CN115202316A