CAN bus data analysis method, device, equipment, medium and product
By performing binary processing and slicing of CAN messages, a comparison signal set is generated, which solves the problems of low accuracy and low processing efficiency of CAN bus data analysis, and realizes efficient and accurate CAN bus data analysis.
Patent Information
- Application Number
- CN202510410516.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-07-08
AI Technical Summary
In the prior art, the analysis accuracy of CAN bus data analysis methods is limited and cannot process large-scale data in real time, resulting in low processing efficiency.
By performing binary processing on CAN messages, the reference signal and comparison signal set are extracted, the signal coefficients and offsets are calculated, and the inclusion term filtering is performed. The comparison signal is processed using preset length slicing to generate a comparison signal set, and the CAN bus data is finally parsed.
It improves the accuracy of CAN bus data analysis, realizes real-time processing of large-scale data, reduces the amount of data processing, and improves processing efficiency.
Smart Images

Figure CN120281829A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of CAN bus data, and particularly to a CAN bus data parsing method, apparatus, device, medium, and product. Background Art
[0002] As an important communication protocol in modern automotive electronic systems, the CAN bus carries complex and diverse sensor and actuator data. In modern vehicles, various electronic control units, as well as sensors and actuators, communicate data through the CAN bus, including engine control, in-vehicle entertainment systems, airbags, anti-lock braking systems, etc. The CAN bus enables these modules to communicate with each other efficiently, thus coordinating the operating state and functions of the entire vehicle. Therefore, the demand for analyzing CAN bus data by automobile manufacturers and related industries is increasing day by day. However, due to the complexity and diversity of CAN bus data in modern automobiles. It involves data from various sensors and actuators, such as engine speed, vehicle speed, throttle position, wheel speed, brake state, etc., resulting in the following problems in the current traditional CAN bus data parsing methods: the parsing accuracy is limited, and large-scale data cannot be processed in real time, resulting in low processing efficiency. Summary of the Invention
[0003] The purpose of this application is to provide a CAN bus data parsing method, apparatus, device, medium, and product, which can process large-scale data in real time and improve the accuracy of the parsing results.
[0004] To achieve the above objective, this application provides the following solutions: In a first aspect, this application provides a CAN bus data parsing method, including: processing the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message.
[0005] Performing binary processing on the message data of each CAN message to obtain the binary message data of each CAN message.
[0006] Extracting the binary message data of each CAN message to obtain a reference signal and a set of comparison signals.
[0007] Calculating the coefficients and offsets of each signal in the normal signal set, and performing an inclusion term filtering operation on the normal signal set to obtain a broadcast signal, completing the parsing of the CAN bus data to be parsed; the normal signal set is obtained based on the similarity between each comparison signal in the comparison signal set and the reference signal.
[0008] Among them, extracting the set of comparison signals from the binary message data of each CAN message specifically includes: processing the binary message data of each CAN message to obtain the initial comparison signal raw data corresponding to each CAN message.
[0009] For any CAN message, if the original data of the initial comparison signal corresponding to the CAN message is different from the binary message data corresponding to the CAN message, the original data of the initial comparison signal corresponding to the CAN message is sliced according to multiple preset judgment lengths respectively, and a slice set corresponding to the CAN message under each preset judgment length is obtained.
[0010] For the a-th element in the slice set corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, it is determined that the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length; if they are the same, it is determined that the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length is empty.
[0011] A comparison signal set is obtained based on the timestamps of each CAN message and the respective element comparison signals corresponding to each CAN message under each preset judgment length.
[0012] In a second aspect, the present application provides a CAN bus data parsing device, including: a CAN message parsing module for processing the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message.
[0013] A binary processing module for performing binary processing on the message data of each CAN message to obtain the binary message data of each CAN message.
[0014] A signal extraction module for extracting the binary message data of each CAN message to obtain a reference signal and a comparison signal set.
[0015] A CAN bus data parsing module for calculating the coefficients and offsets of each signal in the normal signal set and performing an inclusion item filtering operation on the normal signal set to obtain a broadcast signal, completing the parsing of the CAN bus data to be parsed; the normal signal set is obtained according to the similarity between each comparison signal in the comparison signal set and the reference signal.
[0016] Among them, the signal extraction module includes: a processing unit for processing the binary message data of each CAN message to obtain the original data of the initial comparison signal corresponding to each CAN message.
[0017] A slicing unit, for any CAN message, if the original data of the initial comparison signal corresponding to the CAN message is different from the binary message data corresponding to the CAN message, then slice the original data of the initial comparison signal corresponding to the CAN message according to multiple preset judgment lengths respectively, to obtain a slice set corresponding to the CAN message at each preset judgment length.
[0018] An element comparison signal determination unit, for the a-th element in the slice set corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, then determine the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length as the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length; if they are the same, then determine that the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length is empty.
[0019] A comparison signal set determination unit, for obtaining a comparison signal set based on the timestamps of each CAN message and each element comparison signal corresponding to each CAN message under each preset judgment length.
[0020] In a third aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the CAN bus data parsing method described in any one of the above.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the CAN bus data parsing method described in any one of the above.
[0022] In a fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the CAN bus data parsing method described in any one of the above.
[0023] According to the specific embodiments provided by the present application, the present application has the following technical effects: The present application provides a CAN bus data parsing method, device, equipment, medium and product. By performing binary processing on the message data, fine-grained data processing can be achieved, which can improve the accuracy of the parsing result. When extracting the comparison signals, through the steps: if the original data of the initial comparison signal corresponding to the CAN message is different from the binary message data corresponding to the CAN message, then slice the original data of the initial comparison signal corresponding to the CAN message according to multiple preset judgment lengths respectively to obtain a slice set corresponding to the CAN message under each preset judgment length, and the step: for the a-th element in the slice set corresponding to the i-th CAN message under any one preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, then determine that the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length, if they are the same, then determine that the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length is empty, and only process the signals with different comparison results, reducing the amount of data processed and achieving the effect of real-time processing of large-scale data. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0025] Figure 1 It is a general flowchart of a CAN bus data parsing method provided by an embodiment of the present application.
[0026] Figure 2 It is a specific flowchart of a CAN bus data parsing method provided by an embodiment of the present application.
[0027] Figure 3 It is a reference signal generation flowchart provided by an embodiment of the present application.
[0028] Figure 4 It is a comparison signal generation flowchart provided by an embodiment of the present application.
[0029] Figure 5 It is a data comparison flowchart provided by an embodiment of the present application.
[0030] Figure 6Schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0031] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0032] To make the above objects, features, and advantages of the present application more obvious and understandable, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0033] In an exemplary embodiment, as Figure 1 shown, a method for parsing CAN bus data is provided. The general steps include CAN data reading, parameter setting, obtaining a reference signal, loading a comparison signal, disassembling the comparison signal into messages, obtaining a comparison signal set, data time alignment, signal analysis, inclusion item filtering, and extracting a broadcast signal. The overall logic is as Figure 2 shown, and the specific steps include step 201 to step 204.
[0034] Step 201: Process the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message. The CAN bus data to be parsed includes all CAN messages within a collection period. The timestamps between the CAN messages are different. The Can IDs of the CAN messages are the same.
[0035] Step 202: Perform binary processing on the message data of each CAN message to obtain the binary message data of each CAN message.
[0036] Step 203: Extract the binary message data of each CAN message to obtain a reference signal and a comparison signal set.
[0037] Step 204: Calculate the coefficients and offsets of the signals in the normal signal set, and perform an inclusion item filtering operation on the normal signal set to obtain a broadcast signal, thereby completing the parsing of the CAN bus data to be parsed. The normal signal set is obtained based on the similarity between each comparison signal in the comparison signal set and the reference signal.
[0038] Among them, as Figure 4As shown, the binary message data of each CAN message is extracted to obtain a comparison signal set, which generally includes: The first step: Load the original comparison signal data. This step involves loading all diagnostic and broadcast messages into memory and classifying them according to the Can ID in the message for subsequent analysis and data retrieval. The second step: Determine whether the original data has changed. After obtaining the original message set, the system determines one by one whether the values of these data have changed during the entire acquisition cycle. For the data that has not changed, the system directly discards it; while for the data that has changed, the system retains it to obtain a comparison signal data set for further analysis and processing. The third step: Perform comparison data bit grouping slicing and signal data set slicing on the comparison signal data set. The fourth step: Determine again whether the data has changed, discard the data that has not changed, and retain the data that has changed to generate the original comparison signal data. The fifth step: Process the generated original comparison signal data to generate a comparison signal. Extracting the binary message data of each CAN message to obtain a comparison signal set specifically includes steps 203.11 to 203.14.
[0039] Step 203.11: Process the binary message data of each CAN message to obtain the initial original comparison signal data corresponding to each CAN message. Specifically: Process the binary message data of each CAN message according to a preset offset, a preset coefficient, a preset data format, and a preset data type to obtain the initial original comparison signal data corresponding to each CAN message. Specifically: First, extract the binary message data of the CAN message according to the preset data format (the preset data format is divided into two types: Motorola and Intel), then convert the extracted signal into a decimal data conversion method according to the preset data type (the preset data type is divided into two types: signed bit and unsigned bit), and finally, according to the formula the initial original comparison signal data corresponding to the CAN message = preset coefficient × binary message data of the CAN message + preset offset, obtain the initial original comparison signal data corresponding to the CAN message.
[0040] Step 203.12: For any CAN message, if the initial original comparison signal data corresponding to the CAN message is different from the binary message data corresponding to the CAN message, slice the initial original comparison signal data corresponding to the CAN message according to multiple preset judgment lengths respectively to obtain a slice set corresponding to the CAN message under each preset judgment length. (The steps of slicing processing can be processed in parallel).
[0041] Step 203.13: For the a-th element in the slice set corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, then determine that the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length; if they are the same, then determine that the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length is empty. 1 ≤ i ≤ I, where I represents the total number of CAN messages in a collection period, and 1 ≤ a ≤ A, where A represents the total number of elements in the slice set corresponding to the i-th CAN message under the preset judgment length.
[0042] Step 203.14: Obtain a comparison signal set based on the timestamps of each CAN message and the respective element comparison signals corresponding to each CAN message under each preset judgment length.
[0043] The slicing process in Step 203.12 is specifically binary bit slicing. Binary bit slicing is adopted in the slicing process, specifically: slice the binary bits of all messages according to the value of the split data bits set by the parameter (preset judgment length), and split them into small signals. This fine-grained slicing enables obtaining a more detailed and specific data basis. The slicing method is exemplified by a standard frame message. The original message is: "370E 29230E 01EE 02". After converting the above message into binary format, the result is as follows. "0011011100001110001010010010001100001110000000011110111000000010". This binary data has a total length of 64 bits. At this time, splitting according to the value of the split data bits set by the parameter as 16, multiple signal segments can be obtained, in the form of the data structure tree of the original CAN message. As shown in Table 1, these split signal segments are represented by underlines.
[0044] Table 1 Binary Bit Slicing Result Table
[0045]
[0046] As shown in Table 1, for an 8-bit hexadecimal message data, when it is converted to binary, the total length is 64 bits. If it is split bit by bit, these bits can be split into 49 signals with a length of 16 bits. The process of splitting CAN FD data is similar to that of standard frame data. The maximum length of a CAN FD message is 64-bit hexadecimal data. According to the splitting method in the standard frame, these data can be sliced into 497 sub-signals.
[0047] Implementing the above steps can achieve real-time and fast processing and high-precision analysis of massive data.
[0048] The process from step 203.12 to step 203.14 is called the process of splitting all data. In step 203.12, only the original comparison signal data corresponding to the CAN messages where the original comparison signal data of the initial comparison signal and the binary message data are different is processed. In step 203.13, only the different elements are retained, and a logical method of gradual deletion is adopted. During the process of splitting all data, in response to the problems of complexity and long operation cycle, a method of gradual deletion is adopted, and parallel computing is used to achieve fast processing. Through gradual deletion, all data is refined into a more critical subset, thereby reducing the complexity of processing and the operation duration. At the same time, the method of parallel computing enables multiple subtasks to be processed in parallel, improving the processing efficiency, shortening the data processing cycle, and achieving the goal of fast processing. Optimizing the processing of splitting all CAN message data by using the method of gradual deletion realizes the fast processing of large-scale data.
[0049] In another exemplary embodiment of the present application, step 203.14 specifically includes step 203.141 and step 203.142.
[0050] Step 203.141: For any preset judgment length, obtain the comparison signal corresponding to the a-th element under the preset judgment length according to the time stamps of each CAN message, the a-th element comparison signal corresponding to each CAN message under the preset judgment length, and the preset length.
[0051] Step 203.142: Determine that the comparison signals corresponding to all elements under all preset judgment lengths are the comparison signal set.
[0052] In another exemplary embodiment of the present application, step 201 has two specific methods.
[0053] The first method: Read through a CAN message file in.asc format.
[0054] a) Select a file.
[0055] The user selects a CAN message file in.asc format in the software interface. This file usually contains all the message data on the CAN bus and records all CAN communications of the vehicle during a specific period.
[0056] b) File parsing.
[0057] The software reads and parses the.asc file. The.asc file is a text - format file. Each line records a CAN message, which usually contains the following information: timestamp, CAN ID, data length code (DLC), and data bytes. During the parsing process, the software converts the data of each line into an internal data structure for subsequent processing.
[0058] c) Data loading.
[0059] The parsed data is loaded into the memory of the software, forming a dataset of CAN messages. This dataset contains all the detailed information of CAN messages, including timestamp, CAN ID, message data, and data bytes, etc.
[0060] The second method: directly read the vehicle messages through a CAN analyzer device and the vehicle OBD interface.
[0061] a) Connect the device.
[0062] Use a CAN analyzer device (such as brands like Vector, Peak - System, etc.) to connect to the vehicle's CAN bus through the OBD - II interface. The OBD - II interface is usually located under the dashboard on the driver's side and provides a standardized interface for accessing the vehicle's CAN bus.
[0063] b) Device configuration.
[0064] Configure parameters such as CAN channels and baud rate on the CAN analyzer device to ensure that the device can correctly receive and parse CAN messages. The baud rate is usually set according to the vehicle's CAN bus standard (such as 500 kbps or 250 kbps).
[0065] c) Real - time data acquisition.
[0066] The CAN analyzer device starts to acquire CAN bus message data in real - time. The device will transmit the received message data to the connected computer or embedded system in real - time.
[0067] d) Data reception and parsing.
[0068] The software on the computer or embedded system receives the message data from the CAN analyzer device. The software parses these data in real - time to retrieve information such as timestamp, CAN ID, message data, and data bytes.
[0069] e) Data storage.
[0070] The parsed data can be stored in memory in real - time or can be saved as an.asc file or other formats for subsequent re - reading and analysis.
[0071] In another exemplary embodiment of the present application, before step 203, it further includes: parameter setting. Set the preset extraction data length, preset offset, preset coefficient, preset data format, preset data type, and multiple preset judgment lengths.
[0072] The purpose of this step is to ensure that the required signals can be accurately retrieved from the CAN message and provide a basis for subsequent signal comparison and analysis. The following are the detailed operation steps.
[0073] 1) Obtain reference signal parameters, including three ways.
[0074] The first way: Obtain from the manufacturer or technical documents: Obtain the initial information of the CAN signal, including key data such as CAN ID, signal format, coefficient, offset, etc., from the technical documents or relevant materials provided by the vehicle manufacturer.
[0075] The second way: Obtain real-time data through a diagnostic instrument: Use a diagnostic instrument device to perform real-time diagnosis on the vehicle and obtain the index data such as CAN ID, signal format, coefficient, offset, etc. of the current diagnostic signal.
[0076] The third way: Read and parse to obtain from the CAN message: Through the CAN message data read in the first step, retrieve the CAN ID and intercept the data within a certain time period. Subsequently, plot the message data within this time period into a signal operation curve. Verify through the operation curve and the actual state of the vehicle to ensure the accuracy and consistency of the signal data.
[0077] 2) Set the parameters of the reference signal and set the values of the following four parameters.
[0078] The first one: Retrieval data length: This parameter item includes the settings of CAN ID, signal position, and length parameters.
[0079] The second one: Coefficient and offset: Used to convert the original CAN data into actual physical quantities.
[0080] The third one: Data format: Set the data format of the reference signal, such as Motorola / Intel, etc.
[0081] The fourth one: Data type: Signed / unsigned.
[0082] 3) Set the parameters of the comparison signal.
[0083] Set the split data bits (preset judgment length): The data bit split is a process of converting the data in the message into binary data and then splitting it according to the specified number of bits (split data bits) (for example, if the split data bits are set to 8, it means splitting the message into a fixed length of 8 bits). Through this splitting method, a large message can be split into several small signals, which is convenient for subsequent signal processing and analysis.
[0084] In another exemplary embodiment of the present application, as Figure 3 shown, extract the binary message data of each CAN message to obtain a reference signal, specifically including steps 203.21 to 203.24.
[0085] Step 203.21: Extract the binary message data of each CAN message according to the preset extraction data length to obtain the extracted message data of each CAN message.
[0086] Step 203.22: Process the extracted message data of each CAN message according to the preset offset, preset coefficient, preset data format, and preset data type to obtain the processed reference message data corresponding to each CAN message. Specifically: First, extract the extracted message data of the CAN message according to the preset data format (the preset data format is divided into two types: Motorola and Intel), then convert the extracted signal into a decimal data conversion method according to the preset data type (the preset data type is divided into two types: signed bit and unsigned bit), and finally, according to the formula: the processed reference message data corresponding to the CAN message = preset coefficient × the extracted message data of the CAN message + preset offset, obtain the processed reference message data corresponding to the CAN message.
[0087] Step 203.23: Draw a curve graph with the timestamp of each CAN message as the abscissa and the processed reference message data corresponding to each CAN message as the ordinate to obtain the original reference signal data.
[0088] Step 203.24: Determine the reference signal according to the message length of the original reference signal data and the preset length. The preset length is a dynamic length value automatically calculated by the system, and this value is equal to the total message duration in milliseconds divided by 100 (for example, if the total message duration is 20 seconds, then this length value is (20 × 1000) / 100).
[0089] In another exemplary embodiment of the present application, step 203.24 specifically includes steps 203.241 to 203.243.
[0090] Step 203.241: If the message length of the original reference signal data is equal to the preset length, then determine the original reference signal data in hexadecimal form as the reference signal.
[0091] Step 203.242: If the message length of the original reference signal data is less than the preset length, perform interpolation processing on the original reference signal data so that the message length of the interpolated original reference signal data is equal to the preset length, and determine the interpolated original reference signal data in hexadecimal form as the reference signal.
[0092] Step 203.243: If the message length of the original reference signal data is greater than the preset length, perform decimation processing on the original reference signal data so that the message length of the decimated original reference signal data is equal to the preset length, and determine the decimated original reference signal data in hexadecimal form as the reference signal.
[0093] In another exemplary embodiment of the present application, step 203.141 specifically includes step 203.1411 and step 203.1412.
[0094] Step 203.1411: Using the time stamp of each CAN message as the abscissa and the a-th element comparison signal corresponding to each CAN message under the preset judgment length as the ordinate, draw a curve graph to obtain the original comparison signal data corresponding to the a-th element under the preset judgment length.
[0095] Step 203.1412: Determine the comparison signal corresponding to the a-th element under the preset judgment length according to the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length and the preset length. Specifically, after obtaining the comparison signal raw data in the previous step, the system processes these comparison signals one by one using the dynamic length value (preset length) calculated during the reference signal generation process. When the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length is less than the preset length, perform interpolation processing on the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length so that the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length after interpolation processing is equal to the preset length, and then determine the comparison signal raw data corresponding to the a-th element under the preset judgment length in hexadecimal form after interpolation processing as the comparison signal corresponding to the a-th element under the preset judgment length. When the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length is greater than the preset length, perform decimation processing on the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length so that the message length of the comparison signal raw data corresponding to the a-th element under the preset judgment length after decimation processing is equal to the preset length, and then determine the comparison signal raw data corresponding to the a-th element under the preset judgment length in hexadecimal form after decimation processing as the comparison signal corresponding to the a-th element under the preset judgment length. If they are equal, determine the comparison signal raw data corresponding to the a-th element under the preset judgment length in hexadecimal form as the comparison signal corresponding to the a-th element under the preset judgment length.
[0096] In another exemplary embodiment of the present application, as Figure 5 shown, before step 204, there are also step 20441 and step 20442.
[0097] Step 20441: For any comparison signal in the comparison signal set, calculate the similarity between the first signal and the second signal corresponding to the comparison signal; the first signal is the reference signal within the target time period; the second signal corresponding to the comparison signal is the comparison signal within the target time period; the target time period is the time period when the comparison signal overlaps with the reference signal.
[0098] Step 20442: Determine that the second signals corresponding to all comparison signals with similarity values greater than the set similarity threshold form a normal signal set. Specifically, for any comparison signal, if the similarity between the first signal and the second signal corresponding to the comparison signal is greater than the set similarity threshold, the second signal corresponding to the comparison signal is a normal signal, and if it is not greater, the second signal corresponding to the comparison signal is an interference signal.
[0099] In another exemplary embodiment of the present application, as Figure 5 shown, before step 20441, it further includes: performing a timestamp alignment operation on the comparison signal and the reference signal, and if not aligned, processing it using a timestamp alignment algorithm to obtain the second signal corresponding to the comparison signal and the first signal. The specific steps are as follows: First, determine whether the first value of the comparison signal is consistent with the first value of the reference signal in terms of time. If not, use the time when the last event occurred as the start time; then determine whether the end times are consistent. If not, use the time when the earliest event ended as the end time. Then, extract the comparison signal and the reference signal during the period between the start time and the end time.
[0100] In another exemplary embodiment of the present application, step 204 specifically includes step 2041 and step 2042.
[0101] Step 2041: Calculate the coefficients and offsets of each signal in the normal signal set according to the coefficients and offsets of the first signal.
[0102] Step 2042: Delete all target signals in the normal signal set to obtain a broadcast signal, thereby completing the parsing of the CAN bus data to be parsed; the target signals are signals with non - longest message lengths in all the same signal sets; the same signal sets include signals with the same decimal form in the normal signal set.
[0103] In another exemplary embodiment of the present application, step 20441 and step 2041 are specifically as follows: Use the second signal corresponding to the comparison signal and the first signal respectively to perform comparative analysis using the Pearson correlation coefficient calculation algorithm, data normalization algorithm, and linear regression coefficient calculation, so as to obtain the numerical values of similarity, coefficient, and offset parameters. The above - mentioned analysis methods are as follows.
[0104] Calculate the Pearson correlation coefficient to obtain the similarity: The Pearson correlation coefficient r can be calculated by the formula where, X i and Y i respectively represent the processed reference message data corresponding to the i - th CAN message in the first signal and the element corresponding to the i - th timestamp in the second signal corresponding to the comparison signal, and respectively represent the means of the first signal and the second signal corresponding to the comparison signal, and n is the total timestamp of the signal.
[0105] First, perform data normalization: For the second signal corresponding to the comparison signal, the normalized data y standardized can be calculated by the formula where, y represents the second signal corresponding to the comparison signal before normalization, and σ yis the standard deviation of the second signal corresponding to the comparison signal.
[0106] Then, calculate the linear regression coefficient: The general form of the linear regression model is y1 = Kx + B, where y1 represents the dependent variable, x represents the independent variable, K is the coefficient, and B is the offset. In this algorithm, the calculation of the coefficient K and the offset B is based on the standardized data, and the specific formulas are: and where, σ x is the standard deviation of the first signal.
[0107] The implementation code of the above algorithm in the system is as follows:
[0108]
[0109] After step 203.24 and step 203.1412, it also includes: linearly transforming the reference signal and the comparison signal into the range of [0, 1] through the data linear normalization algorithm.
[0110] This application converts the message data into a binary format, and splits the data into multiple comparison signal data sources according to parameters such as bit length, type, coefficient, offset, and sign bit. By utilizing the similarity principle of homologous signals, with the reference signal as the benchmark, calculate the similarity between the comparison signal and the reference signal. By setting a similarity threshold, quickly screen out the comparison signals that meet the conditions, and achieve intelligent comprehensive analysis and comparison of data in different parts. For example, taking the engine speed data as the reference signal, the speed signals of the four wheels can be obtained simultaneously because they form similar images through the principle of image comparison.
[0111] This application also has the following technical effects: 1. By means of the original CAN message data structure tree, the purpose of data traceability and repeatable calculation is achieved, which helps to ensure the accuracy and integrity of data processing. Using the original data structure tree to organize the storage format ensures that the subset data is processed while retaining the integrity of the parent-level data, thus achieving the purpose of data repeatable calculation and traceability.
[0112] 2. Using the graphical method to compare and process the CAN message signals improves the intelligence level of data processing and provides engineers with more intuitive and vivid data analysis means.
[0113] 3. Utilize full-scale splitting of data and gradually delete according to the data change amount to achieve rapid processing of large-scale data and avoid the problem of long operation cycles.
[0114] 4. Adopt parallel computing technology to decompose the data processing task into multiple subtasks and process them in parallel to improve the processing efficiency.
[0115] The present application also provides an application scenario, which applies the above-mentioned CAN bus data parsing method. Specifically: The CAN bus data parsing method provided in this embodiment can be applied in the following aspects.
[0116] 1. Fault diagnosis: CAN bus data parsing is widely used in the automotive industry for fault diagnosis. By analyzing the data transmitted on the CAN bus, the communication between various vehicle subsystems can be monitored, helping to identify sensor faults, actuator anomalies, or problems with the electronic control unit. Through parsing, real-time data of different vehicle components can be obtained, including parameters such as vehicle speed, engine speed, throttle position, wheel speed, etc., thereby assisting in diagnosing problems and locating the fault points.
[0117] 2. Performance optimization: With the help of CAN bus data parsing, the performance parameters of various vehicle components can be monitored and recorded, and optimized. By parsing, the data sent by the engine control unit can be obtained, such as air flow, engine load, throttle input, etc., thereby assisting in adjusting the performance parameters of the engine, improving fuel economy, driving responsiveness, and power output.
[0118] 3. Customized functions: Many customized functions of automobiles are realized by using CAN bus data parsing. By parsing CAN signals, data of modules such as the instrument panel, on-board computer, chassis control, and autonomous driving system can be obtained, thereby enabling vehicle modification to meet personalized needs, including customizing the instrument panel display, personalized on-board computer functions, tuning the vehicle suspension system, and even modifying the vehicle power system parameters.
[0119] 4. Debugging and reverse engineering: Automobile modification manufacturers and automotive electronic system suppliers need to deeply study the communication protocols between various automotive modules, and then carry out debugging and reverse engineering. By parsing CAN signals, the internal communication methods of automotive electronic systems can be understood, software and hardware debugging and optimization can be carried out, and even customized automotive electronic control systems can be developed, providing technical support for the innovation and development of automotive electronic systems.
[0120] 5. The present application will provide more technology-intensive data support for automotive engineers and technicians, helping them to more deeply understand and analyze CAN bus communication data, and effectively supporting key tasks such as vehicle diagnosis, network optimization, and performance debugging.
[0121] Based on the same inventive concept, the embodiment of the present application also provides a CAN bus data parsing device for implementing the above-mentioned CAN bus data parsing method. The implementation solutions provided by this device to solve problems are similar to those described in the above method. Therefore, the specific limitations in one or more embodiments of the CAN bus data parsing device provided below can refer to the limitations on the CAN bus data parsing method in the above text, and will not be repeated here.
[0122] In an exemplary embodiment, a CAN bus data parsing device is provided, including: a CAN message parsing module, configured to process the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message; the CAN bus data to be parsed includes all CAN messages within a collection period, and the timestamps of each CAN message are different.
[0123] A binary processing module, configured to perform binary processing on the message data of each CAN message to obtain the binary message data of each CAN message.
[0124] A signal extraction module, configured to extract the binary message data of each CAN message to obtain a reference signal and a set of comparison signals.
[0125] A CAN bus data parsing module, configured to calculate the coefficients and offsets of each signal in the normal signal set, and perform an inclusion item filtering operation on the normal signal set to obtain a broadcast signal, thereby completing the parsing of the CAN bus data to be parsed; the normal signal set is obtained according to the similarity between each comparison signal in the comparison signal set and the reference signal.
[0126] Among them, the signal extraction module includes: a processing unit, configured to process the binary message data of each CAN message to obtain the initial comparison signal raw data corresponding to each CAN message.
[0127] A slicing unit, for any CAN message, if the initial comparison signal raw data corresponding to the CAN message is different from the binary message data corresponding to the CAN message, then slice the initial comparison signal raw data corresponding to the CAN message according to multiple preset judgment lengths respectively to obtain a set of slices corresponding to the CAN message under each preset judgment length.
[0128] An element comparison signal determination unit, for the a-th element in the slice set corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, then determine the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length as the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length, if they are the same, then determine the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length as empty; 1 ≤ i ≤ I, I represents the total number of CAN messages within a collection period, 1 ≤ a ≤ A, A represents the total number of elements in the slice set corresponding to the i-th CAN message under the preset judgment length.
[0129] A comparison signal set determining unit, configured to obtain a comparison signal set based on the timestamps of each CAN message and each element comparison signal corresponding to each CAN message under each preset judgment length.
[0130] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal, and its internal structure diagram may be as Figure 6 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store CAN bus data parsing data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a CAN bus data parsing method.
[0131] Those skilled in the art can understand that Figure 6 the structure shown in
[0132] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements. In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the above method embodiments are implemented.
[0133] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the above method embodiments are implemented.
[0134] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0135] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0136] The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0137] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0138] In this text, specific examples are used to elaborate on the principles and implementation modes of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; at the same time, for those of ordinary skill in the art, according to the idea of this application, there will be changes in the specific implementation modes and application scopes. To sum up, the content of this specification should not be construed as a limitation to this application.
Claims
1. A method for parsing CAN bus data, characterized in that, The described CAN bus data parsing method includes: Processing the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message; Performing binary processing on the message data of each CAN message to obtain the binary message data of each CAN message; Extracting the binary message data of each CAN message to obtain a reference signal and a set of comparison signals; Calculating the coefficients and offsets of each signal in the normal signal set, and performing an inclusion item filtering operation on the normal signal set to obtain a broadcast signal, completing the parsing of the CAN bus data to be parsed; the normal signal set is obtained according to the similarity between each comparison signal in the comparison signal set and the reference signal; Among them, extracting the set of comparison signals from the binary message data of each CAN message specifically includes: Processing the binary message data of each CAN message to obtain the initial comparison signal raw data corresponding to each CAN message; For any CAN message, if the initial comparison signal raw data corresponding to the CAN message is different from the binary message data corresponding to the CAN message, then slice the initial comparison signal raw data corresponding to the CAN message according to multiple preset judgment lengths respectively to obtain a set of slices corresponding to the CAN message at each preset judgment length; For the a-th element in the set of slices corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the set of slices corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the set of slices corresponding to the (i - 1)-th CAN message under the preset judgment length, then determine the a-th element in the set of slices corresponding to the i-th CAN message under the preset judgment length as the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length, if they are the same, then determine the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length as empty; Obtaining a set of comparison signals based on the timestamps of each CAN message and the comparison signals of each element corresponding to each CAN message under each preset judgment length; 2. The CAN bus data parsing method according to claim 1, characterized in that Extracting the reference signal from the binary message data of each CAN message, specifically: Extracting the extracted message data of each CAN message according to the preset extraction data length; Processing the extracted message data of each CAN message according to the preset offset, preset coefficient, preset data format, and preset data type to obtain the processed reference message data corresponding to each CAN message; Drawing a curve graph with the timestamp of each CAN message as the abscissa and the processed reference message data corresponding to each CAN message as the ordinate to obtain the reference signal raw data; Determining the reference signal according to the message length of the reference signal raw data and the preset length; 3. The CAN bus data parsing method according to claim 1, wherein Obtaining a set of comparison signals based on the timestamps of each CAN message and the comparison signals of each element corresponding to each CAN message under each preset judgment length, specifically including: For any preset judgment length, the comparison signal corresponding to the a-th element under the preset judgment length is obtained according to the timestamps of each CAN message, the a-th element comparison signal corresponding to each CAN message under the preset judgment length, and a preset length. Determine that the comparison signals corresponding to all elements under all preset judgment lengths are the comparison signal set.
4. The CAN bus data parsing method according to claim 1, characterized in that Before calculating the coefficients and offsets of each signal in the normal signal set and performing an inclusion filtering operation on the normal signal set to obtain a broadcast signal and completing the parsing of the CAN bus data to be parsed, it also includes: For any comparison signal in the comparison signal set, calculate the similarity between the first signal and the second signal corresponding to the comparison signal; the first signal is a reference signal within a target time period; the second signal corresponding to the comparison signal is the comparison signal within the target time period; the target time period is the time period when the comparison signal overlaps with the reference signal. Determine that the second signals corresponding to all comparison signals with similarity values greater than the set similarity threshold form a normal signal set.
5. The CAN bus data parsing method according to claim 4, wherein, Calculate the coefficients and offsets of each signal in the normal signal set and perform an inclusion filtering operation on the normal signal set to obtain a broadcast signal, specifically including: Calculate the coefficients and offsets of each signal in the normal signal set according to the coefficients and offsets of the first signal. Delete all target signals in the normal signal set to obtain a broadcast signal; the target signal is a signal with a non-longest message length among all messages in the same signal set; the same signal set includes signals with the same decimal form in the normal signal set.
6. The CAN bus data parsing method according to claim 2, characterized in that Determine the reference signal according to the message length of the reference signal original data and a preset length, specifically including: If the message length of the reference signal original data is equal to the preset length, determine the hexadecimal form of the reference signal original data as the reference signal. If the message length of the reference signal original data is less than the preset length, perform interpolation processing on the reference signal original data so that the message length of the interpolated reference signal original data is equal to the preset length, and determine the hexadecimal form of the interpolated reference signal original data as the reference signal. If the message length of the reference signal original data is greater than the preset length, perform decimation processing on the reference signal original data so that the message length of the decimated reference signal original data is equal to the preset length, and determine the hexadecimal form of the decimated reference signal original data as the reference signal.
7. A CAN bus data parsing device, characterized in that The CAN bus data parsing device includes: A CAN message parsing module, used to process the CAN bus data to be parsed to obtain the timestamp and message data of each CAN message. A binary processing module, used to perform binary processing on the message data of each CAN message to obtain the binary message data of each CAN message. A signal extraction module, used to extract the binary message data of each CAN message to obtain a reference signal and a comparison signal set. The CAN bus data parsing module is used to calculate the coefficients and offsets of each signal in the normal signal set, perform an inclusion item filtering operation on the normal signal set to obtain broadcast signals, and complete the parsing of the CAN bus data to be parsed; the normal signal set is obtained based on the similarity between each comparison signal in the comparison signal set and the reference signal. Among them, the signal extraction module includes: A processing unit for processing the binary message data of each CAN message to obtain the initial comparison signal raw data corresponding to each CAN message. A slicing unit for, for any CAN message, if the initial comparison signal raw data corresponding to the CAN message is different from the binary message data corresponding to the CAN message, respectively slicing the initial comparison signal raw data corresponding to the CAN message according to multiple preset judgment lengths to obtain a slice set corresponding to the CAN message under each preset judgment length. An element comparison signal determination unit for, for the a-th element in the slice set corresponding to the i-th CAN message under any preset judgment length, if the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length is different from the a-th element in the slice set corresponding to the (i - 1)-th CAN message under the preset judgment length, determining the a-th element in the slice set corresponding to the i-th CAN message under the preset judgment length as the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length, and if they are the same, determining that the a-th element comparison signal corresponding to the i-th CAN message under the preset judgment length is empty. A comparison signal set determination unit for obtaining a comparison signal set based on the timestamps of each CAN message and each element comparison signal corresponding to each CAN message under each preset judgment length.
8. A computer device, comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the computer program to implement the CAN bus data parsing method according to any one of claims 1 - 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the CAN bus data parsing method according to any one of claims 1 - 6.
10. A computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the CAN bus data parsing method according to any one of claims 1 - 6.