A CAN signal analysis method, device and storage medium
By sorting IDs and arranging coding rules for CAN messages, combined with the analogy method of bit inversion rate and working condition curve, the problem of high cost and long cycle of CAN signal acquisition in vehicle energy flow testing is solved, and rapid identification is achieved. and the effect of reducing testing costs.
Patent Information
- Application Number
- CN202211226960.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-09
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2042-10-09
AI Technical Summary
The prior art has a high cost and a long period of obtaining the required physical quantity during the vehicle energy flow testing process, and fails to effectively classify and identify CAN signals, resulting in a low recognition rate.
By obtaining the CAN message, extract the ID and Data segments, calculate the bit inversion rate of each bit of data under each ID, reorder the IDs, arrange the bit inversion rate according to the encoding rules, draw the display and pass the known working conditions Analogize the curves and identify curves with similar shapes to parse the required CAN message.
Realized the required CAN message quickly, improved the recognition rate, and reduced test costs.
Smart Images

Figure CN115695590B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicle CAN signals, and in particular to a CAN signal analysis method, device and storage medium. Background Art
[0002] CAN is the abbreviation of Controller Area Network (CAN), which was developed by BOSCH, a German company famous for the research and development and production of automotive electronic products, and eventually became an international standard (ISO11898). In recent years, its high reliability and good error detection capabilities have been valued and widely used in automotive computer control systems and industrial environments with harsh ambient temperatures, strong electromagnetic radiation and high vibration.
[0003] The energy flow test of the whole vehicle requires the collection of multiple key physical quantities for testing, such as the drive motor torque, battery SOC, etc., which are usually collected by setting sensors and obtaining the required physical quantities by collecting CAN signals for analysis. However, this collection method does not classify and identify CAN signals, resulting in a long time to find the required CAN signals, high consumption costs, and a reduced recognition rate. Summary of the invention
[0004] In order to solve the problem of high cost and long period in the prior art for obtaining the physical quantities required in the whole vehicle energy flow test, the present invention provides a CAN signal parsing method, device and storage medium, which can improve the recognition rate and reduce the testing cost by quickly acquiring the required CAN messages.
[0005] The technical contents of the present invention are as follows:
[0006] A CAN signal analysis method comprises the following steps:
[0007] S1: Obtain a CAN message and extract an ID and a corresponding Data segment in the CAN message, and regroup the Data segment according to the ID;
[0008] S2: Calculate the bit inversion rate of each bit of data included in each Data segment under each ID;
[0009] S3: the IDs are re-arranged in descending order according to the sum of the bit inversion rates of each bit of data in each Data segment;
[0010] S4: according to the ID sequence described in step S3, the bit inversion rate of each Data segment in step S2 is segmented according to the segmentation principle, and several groups of data are reassembled and displayed in a graph;
[0011] S5: Arranging the bit inversion rate of step S2 according to the reordered ID sequence according to the coding rule;
[0012] S6: By comparing the known working condition curve with the drawing display curve of step S4, a curve with a similar shape is identified. If similarity is identified, the process goes to S7; otherwise, the process goes to S8;
[0013] S7: adjusting the length of the data reorganized into several groups in step S4, redrawing the display curve and comparing it with the known working condition curve, and if the two are consistent, the required CAN message is parsed;
[0014] S8: After mirroring the data in the Data segment in step S1, steps S1 to S7 are executed again.
[0015] Furthermore, when the Data segments are regrouped according to IDs, it includes:
[0016] S11: Convert the Data segment from 8-bit hexadecimal to 64-bit binary;
[0017] S12: Group multiple Data segments with the same ID into one group.
[0018] Furthermore, the bit inversion rate of each bit of data included in each Data segment under each ID is calculated, including:
[0019] S21: extract each bit of the 64-bit binary data in sequence to form a column of data, which is the original column data, and then sequentially shift each column of data upward by one bit to form a new column of data, which is the newly formed column data;
[0020] S22: Remove the tail of the original column data, cut off the head of the newly constructed column data, and make a one-to-one correspondence between the two column data values to compare whether the corresponding data values are equal;
[0021] S23: If the corresponding data values are equal, the bit inversion rate remains unchanged. If the corresponding data values are not equal, the bit inversion rate is increased by 1. Finally, the bit inversion rate of each bit of the 64-bit binary is obtained by summing up.
[0022] Further, the bit inversion rate of each Data segment in step S2 is segmented according to the segmentation principle according to the ID sequence described in step S3, and several groups of data are reassembled and displayed in a graph, including:
[0023] Data segmentation is performed at the point where the bit inversion rate of the preceding bit data is greater than twice the bit inversion rate of the following bit data;
[0024] And / or when a continuous 0 value appears in the bit inversion rate of the previous bit data, data segmentation is performed at the last 0 value.
[0025] Further, when the bit inversion rate of each Data segment in step S2 is segmented according to the segmentation principle according to the ID sequence described in step S3, and a plurality of groups of data are reassembled and displayed as a graph, the method further includes:
[0026] Convert the reassembled groups of data from binary to decimal.
[0027] Further, when the bit inversion rate of step S2 is arranged according to the coding rule according to the reordered ID sequence, it includes:
[0028] The encoding rule is an 8×8 matrix. According to the reordered ID sequence, the bit inversion rate of each bit of data in each Data segment corresponding to each ID is arranged into an 8×8 matrix from left to right and from top to bottom.
[0029] Further, adjusting the length of the data reorganized into a plurality of groups in step S4 and redrawing the display curve for comparison with the known working condition curve includes:
[0030] Check whether the bit inversion rate is 0. If so, readjust the data length.
[0031] Re-draw the displayed curve and compare it with the known working condition curve to calculate the corresponding accuracy value and offset value;
[0032] The new value is obtained by multiplying the CAN signal value by the accuracy value and the offset, and the display curve is redrawn for comparison with the known working condition curve.
[0033] Furthermore, when mirroring the data in the Data segment in step S1, the process includes:
[0034] The 8-bit hexadecimal data of the Data segment is mirrored left and right and then converted into a 64-bit binary data. Then, steps S1 to S7 are executed again.
[0035] The present invention provides a CAN signal analysis device, including:
[0036] A memory, wherein at least one instruction is stored in the memory;
[0037] A processor is used to load and execute the instructions to implement the operation of any of the CAN signal parsing methods described above.
[0038] The present invention also provides a computer-readable storage medium, wherein at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the operation of any of the above-mentioned CAN signal parsing methods.
[0039] The beneficial effects of the present invention include: by re-arranging the ID sequence and determining the starting bit and bit length of signal analysis through coding rules, when the signal is analyzed again to obtain the corresponding required physical quantity, the corresponding signal data can be identified more conveniently and quickly, the recognition rate can be improved, and the test cost can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flowchart of a CAN signal analysis method provided in Example 1 of the present invention.
[0041] Figure 2 A schematic diagram of the CAN message composition structure provided in Example 1 of the present invention.
[0042] Figure 3 This is a schematic diagram of an example of calculating the bit inversion rate of a certain binary bit provided in Example 1 of the present invention.
[0043] Figure 4 A schematic diagram of the structure of the reorganized data length provided in Example 1 of the present invention.
[0044] Figure 5 A schematic diagram of the Motorola format structure provided in Example 1 of the present invention.
[0045] Figure 6 This is a schematic diagram of the Intel format structure provided in Example 1 of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] Example 1
[0048] Combination Figure 1-6 As shown, this embodiment provides a CAN signal parsing method, comprising the following steps:
[0049] S1: Obtain a CAN message and extract an ID and a corresponding Data segment in the CAN message, and regroup the Data segment according to the ID;
[0050] S11: Convert the Data segment from 8-bit hexadecimal to 64-bit binary;
[0051] S12: Group multiple Data segments with the same ID into one group;
[0052] The CAN message data collected by the CAN acquisition module is read through the matlab software. The CAN message composition is as follows Figure 2 As shown, in this embodiment, the ID and Data parts of the CAN message are mainly extracted.
[0053] S2: Calculate the bit inversion rate of each bit of data included in each Data segment under each ID;
[0054] like Figure 3 As shown, each ID includes at least one Data segment, which is a 64-bit binary format. Each of the 64 bits is extracted and the bit inversion rate is calculated. The following is the calculation of the bit inversion rate of a binary bit:
[0055] S21: extract each bit of the 64-bit binary data in sequence to form a column of data, which is the original column data, and then sequentially shift each column of data upward by one bit to form a new column of data, which is the newly formed column data;
[0056] S22: Remove the tail of the original column data, cut off the head of the newly constructed column data, and make a one-to-one correspondence between the two column data values to compare whether the corresponding data values are equal;
[0057] S23: If the corresponding data values are equal, the bit inversion rate remains unchanged; if the corresponding data values are not equal, the bit inversion rate is increased by 1, and finally the bit inversion rate of each bit of the 64-bit binary is obtained by summing up;
[0058] S3: the IDs are re-arranged in descending order according to the sum of the bit inversion rates of each bit of data in each Data segment;
[0059] S4: according to the ID sequence described in step S3, the bit inversion rate of each Data segment in step S2 is segmented according to the segmentation principle, and several groups of data are reassembled and displayed in a graph;
[0060] Data segmentation is performed at the point where the bit inversion rate of the preceding bit data is greater than twice the bit inversion rate of the following bit data;
[0061] And / or when a continuous 0 value appears in the bit inversion rate of the previous bit data, data segmentation is performed at the last 0 value;
[0062] Convert the reorganized data from binary to decimal and then display them in a graph;
[0063] S5: Arranging the bit inversion rate of step S2 according to the reordered ID sequence according to the coding rule;
[0064] The encoding rule is an 8×8 matrix. According to the reordered ID sequence, the bit inversion rate of each bit of data in each Data segment corresponding to each ID is arranged into an 8×8 matrix from left to right and from top to bottom.
[0065] S6: By comparing the known working condition curve with the drawing display curve of step S4, a curve with a similar shape is identified. If similarity is identified, the process goes to S7; otherwise, the process goes to S8;
[0066] Check whether the bit inversion rate is 0. If so, readjust the data length.
[0067] Re-draw the displayed curve and compare it with the known working condition curve to calculate the corresponding accuracy value and offset value;
[0068] Get the new value by multiplying the CAN signal value by the accuracy value and the offset, and redraw the display curve to compare it with the known working condition curve;
[0069] The known operating condition curve needs to be tested on a test bench or drum under specific operating conditions, such as the NEDC cycle condition, to directly obtain curves such as vehicle speed, rotation speed, torque, etc., or to perform a fast charging test to obtain curves such as battery SOC, charging current, and battery temperature. The known operating condition curve is obtained according to the requirements, and compared with the plotted display curve to identify curves with similar shapes.
[0070] The plotting display curve displays more than one curve, including curves composed of multiple physical quantity signals;
[0071] Because the required physical quantity has positive and negative values, it is necessary to select whether the data type is signed or unsigned, and then determine the offset based on the initial value or the stable value of a certain section in the middle, and determine the accuracy value based on the difference between the maximum and minimum values;
[0072] The new data obtained by the above steps does not consider the case where the bit inversion rate is 0. Therefore, it is necessary to select whether to add the case where the bit inversion rate is 0 according to the value range of the variable, such as Figure 4 As shown, the length of the automatically combined new data does not take into account the case where the bit inversion rate is 0. When the case where the bit inversion rate is 0 needs to be taken into account, the length of the new data needs to be adjusted.
[0073] S7: adjusting the length of the data reorganized into several groups in step S4, redrawing the display curve and comparing it with the known working condition curve, and if the two are consistent, the required CAN message is parsed;
[0074] S8: After mirroring the data in the Data segment in step S1, re-execute steps S1 to S7;
[0075] Furthermore, when mirroring the data in the Data segment in step S1, the process includes:
[0076] The 8-bit hexadecimal data of the Data segment is mirrored left and right and then converted into a 64-bit binary data. Then, steps S1 to S7 are executed again.
[0077] When no curve with a similar shape can be identified, it means that the data format is not the Motorola format but the Intel format, that is, it is necessary to first mirror the 8-bit hexadecimal data of the Data segment left and right in step S1, and then convert it into 64-bit binary data, and then execute steps S1 to 7 to obtain the required analysis signal.
[0078] The difference in format determines the starting bit of the CAN signal and the big-endian and small-endian algorithms used when generating messages and calculating signal values. Figure 5 As shown in the figure, it is the Motorola format, and the signal starts with the high byte low bit; Figure 6 As shown, it is the Intel format, and the signal starts with the low bit of the low byte.
[0079] This embodiment uses OBD to connect the DB9 one-to-six CAN lines to the OBD port on the vehicle and the DEWESOFT nine-channel CAN acquisition module, and attempts to read and store them through the DEWESOFT software. If the CAN data cannot be read, it means that the OBD port has been encrypted, and it is necessary to read the control module corresponding to the required test physical quantity separately.
[0080] For the control module unit leads, it is necessary to find the CAN high and CAN low of each control module. You can make a preliminary judgment by the color of the twisted pair and the pin position, and finally confirm it by voltage test. The voltage range of CAN high is generally 3V±0.5V, and the voltage range of CAN low is generally 2V±0.5V. Through a DB9 female connector, one end is connected to the CAN high (7 pins of the DB9 female connector) and CAN low (2 pins of the DB9 female connector) of the control module, and the other end is connected to the DEWESOFT nine-channel CAN acquisition module to read and store CAN data.
[0081] This embodiment reorders the ID sequence and determines the starting bit and bit length of signal analysis through coding rules, so that when the signal is analyzed again to obtain the corresponding required physical quantity, the corresponding signal data can be identified more conveniently and quickly, the recognition rate is improved, and the testing cost is reduced.
[0082] Example 2
[0083] In combination with Example 1, this embodiment provides a CAN signal analysis device, including:
[0084] A memory, wherein at least one instruction is stored in the memory;
[0085] A processor is used to load and execute the instructions to implement the operation of the CAN signal parsing method described in any one of Embodiment 1.
[0086] Example 3
[0087] In combination with Example 1, this embodiment further provides a computer-readable storage medium, in which at least one instruction is stored. The instruction is loaded and executed by a processor to implement the operation of the CAN signal parsing method described in any one of Example 1.
[0088] The prior art does not perform targeted sorting of IDs, which results in a time-consuming disadvantage when searching for the required CAN signal, and does not classify and identify data types, namely signed and unsigned types, thereby reducing recognition efficiency.
[0089] The present invention intelligently sorts IDs by bit inversion rate, and then draws a display curve that is strongly associated with known working conditions, and can quickly identify the required CAN signal. Based on the 8×8 encoding rule, it can distinguish the data types of positive and negative physical quantities and analyze them separately, thereby improving the recognition rate of the required CAN signal.
[0090] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A CAN signal analysis method, characterized in that: The following steps are involved: S1: Obtain a CAN message and extract an ID and a corresponding Data segment in the CAN message, and regroup the Data segment according to the ID; S2: Calculate the bit inversion rate of each bit of data included in each Data segment under each ID; S3: the IDs are re-arranged in descending order according to the sum of the bit inversion rates of each bit of data in each Data segment; S4: according to the ID sequence described in step S3, the bit inversion rate of each Data segment in step S2 is segmented according to the segmentation principle, and several groups of data are reassembled and displayed in a graph; S5: Arranging the bit inversion rate of step S2 according to the reordered ID sequence according to the coding rule; S6: By comparing the known working condition curve with the drawing display curve of step S4, a curve with a similar shape is identified. If similarity is identified, the process goes to S7; otherwise, the process goes to S8; S7: adjusting the length of the data reorganized into several groups in step S4, redrawing the display curve and comparing it with the known working condition curve, and if the two are consistent, the required CAN message is parsed; S8: After mirroring the data in the Data segment in step S1, re-execute steps S1 to S7; The step S5 comprises: The encoding rule is an 8×8 matrix. According to the reordered ID sequence, the bit inversion rate of each bit of data in each Data segment corresponding to each ID is arranged into an 8×8 matrix from left to right and from top to bottom. The step S7 includes: Check whether the bit inversion rate is 0. If so, readjust the data length. Re-draw the displayed curve and compare it with the known working condition curve to calculate the corresponding accuracy value and offset value; The new value is obtained by multiplying the CAN signal value by the accuracy value and the offset, and the display curve is redrawn for comparison with the known working condition curve.
2. A CAN signal analysis method according to claim 1, characterized in that: The step S1 comprises: S11: Convert the Data segment from 8-bit hexadecimal to 64-bit binary; S12: Group multiple Data segments with the same ID into one group.
3. A CAN signal analysis method according to claim 2, characterized in that: The step S2 comprises: S21: extract each bit of the 64-bit binary data in sequence to form a column of data, which is the original column data, and then sequentially shift each column of data upward by one bit to form a new column of data, which is the newly formed column data; S22: Remove the tail of the original column data, cut off the head of the newly constructed column data, and make a one-to-one correspondence between the two column data values to compare whether the corresponding data values are equal; S23: If the corresponding data values are equal, the bit inversion rate remains unchanged. If the corresponding data values are not equal, the bit inversion rate is increased by 1. Finally, the bit inversion rate of each bit of the 64-bit binary is obtained by summing up.
4. A CAN signal analysis method according to claim 3, characterized in that: The step S4 comprises: Data segmentation is performed at the point where the bit inversion rate of the preceding bit data is greater than twice the bit inversion rate of the following bit data; And / or when a continuous 0 value appears in the bit inversion rate of the previous bit data, data segmentation is performed at the last 0 value.
5. A CAN signal analysis method according to claim 4, characterized in that: The step S4 further includes: Convert the reassembled groups of data from binary to decimal.
6. A CAN signal analysis method according to claim 1, characterized in that: The step S8 comprises: The 8-bit hexadecimal data of the Data segment is mirrored left and right and then converted into a 64-bit binary data. Then, steps S1 to S7 are executed again.
7. A CAN signal analysis device, characterized in that: Includes, including: A memory, wherein at least one instruction is stored in the memory; A processor is used to load and execute the instructions to implement the operation of the CAN signal parsing method described in any one of claims 1 to 6.
8. A computer-readable storage medium, wherein at least one instruction is stored in the storage medium, characterized in that: The instructions are loaded and executed by the processor to implement the operation of the CAN signal parsing method described in any one of claims 1 to 6.
Citation Information
Patent Citations
DBC file parsing and message analyzing method based on regular expression
CN108600192A
New energy automobile CAN bus analysis method
CN110162008A