A CAN signal analysis method based on cosine similarity
By using a cosine similarity-based method, the similarity between bus message data and reference signal data is calculated, and suspected signals that are consistent with the changing trend of the reference signal are screened out. This solves the problem of low CAN signal parsing efficiency in the existing technology and achieves efficient and accurate signal parsing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA AUTOMOTIVE ENG RES INST
- Filing Date
- 2025-06-09
- Publication Date
- 2026-07-14
AI Technical Summary
In existing technologies, relying on manual identification cannot efficiently and accurately filter and analyze automotive CAN signals, resulting in low CAN signal parsing efficiency.
By employing a cosine similarity-based method, the similarity between bus message data and reference signal data is calculated to filter out suspected signals with the same trend as the reference signal and eliminate signals with inconsistent trends, thereby improving the parsing efficiency.
By calculating the similarity between the suspected signal and the reference signal, the target signal in the bus message data can be accurately located, thus improving the efficiency and accuracy of CAN signal parsing.
Smart Images

Figure CN120416366B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of signal analysis technology, and in particular to a CAN signal analysis method based on cosine similarity. Background Technology
[0002] Currently, with the rapid development of new energy electric vehicles, the number of Electronic Control Units (ECUs) inside automobiles is growing exponentially, and their functional complexity is also significantly increasing. These ECUs need to work collaboratively through in-vehicle communication networks, with the Controller Area Network (CAN) serving as the core communication protocol, carrying most of the in-vehicle signal transmission tasks. Due to its high reliability, strong real-time performance, and ease of acquisition, CAN signals have become an important data source in the field of automotive testing—they do not interfere with the normal communication and operation of the vehicle, while providing accurate data support for testing.
[0003] In current technology, the method for screening and identifying CAN signals from communication data acquired from automobiles usually relies on manual identification of data that may contain CAN signals. This method depends on human experience and cannot efficiently and accurately identify and analyze the required CAN signals.
[0004] Therefore, this specification provides a CAN signal parsing method based on cosine similarity. Summary of the Invention
[0005] This specification provides a CAN signal parsing method based on cosine similarity to partially solve the aforementioned problems existing in the prior art.
[0006] The following technical solution is adopted in this specification:
[0007] This specification provides a CAN signal parsing method based on cosine similarity, including:
[0008] Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time period and the reference signal data corresponding to the target signal;
[0009] Based on the bus message data and the reference signal data, determine the reference signals and bus messages corresponding to multiple time nodes within the preset time period.
[0010] For each time node, the bus messages corresponding to that time node are determined as the bus message sequence corresponding to that time node, and the reference signals are arranged according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals;
[0011] For each bus message sequence, determine each bus message in that bus message sequence;
[0012] For each bus message in the bus message sequence, a signal with a bit length that matches the target signal is identified from the bus message as a suspected signal;
[0013] Based on each bus message sequence, the values of the suspected signals at the multiple time nodes are determined as the suspected signal values; and based on the reference signal sequence, the reference signal values are determined.
[0014] Based on the suspected signal values and the reference signal values, determine whether the accuracy and offset between the suspected signal and the reference signal meet preset values;
[0015] If so, then based on each suspected signal value and each reference signal value, the similarity between the suspected signal and the reference signal is calculated, and based on the similarity, the target signal in the bus message data is determined;
[0016] If not, then continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset values.
[0017] Based on the aforementioned technical methods, by extracting bus message data and reference signal data over a period of time, for each suspected signal that matches the target signal bit length, the suspected signal's value at different time points is compared with the reference signal value determined from the reference signal data at different time points. Suspected signals with the same trend as the reference signal are filtered out, while those with inconsistent trends are excluded. This reduces the computational load of subsequent similarity calculations and improves CAN signal parsing efficiency. Furthermore, by calculating the similarity between the suspected signal and the reference signal—that is, by comparing the suspected signal's value at different time points with the reference signal value at different time points—the target signal in the bus message data is accurately determined.
[0018] Furthermore, based on the reference signal sequence, the values of each reference signal are determined, specifically including:
[0019] For each reference signal in the reference signal sequence, the original value of the corresponding reference signal is determined based on the reference signal data.
[0020] Based on the original value of the signal, determine the physical value of the reference signal;
[0021] The physical value is used as the reference signal value for the reference signal.
[0022] Furthermore, based on the suspected signal values and the reference signal values, it is determined whether the accuracy and offset between the suspected signal and the reference signal meet preset values, specifically including:
[0023] From the plurality of time points, four time points are determined;
[0024] Based on the four time points, determine the suspected signal values corresponding to the four time points from the suspected signal values; and determine the reference signal values corresponding to the four time points from the reference signal values.
[0025] Based on the suspected signal values corresponding to the four time nodes and the reference signal values corresponding to the four time nodes, calculate the first precision value, the second precision value, the first offset value, and the second offset value.
[0026] Calculate the absolute value of the difference between the first precision value and the second precision value as the first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as the second absolute value;
[0027] Determine whether both the first absolute value and the second absolute value are less than a preset value.
[0028] Based on the above technical means, by selecting the suspected signal value and reference signal value at four time points, the accuracy and offset between the suspected signal and the reference signal are calculated to see if they meet the preset requirements. This avoids directly using all suspected signal values and reference signal values. By limiting the number of selected time points, it makes more attention to the overall trend of the suspected signal rather than local anomalies, and can also preliminarily screen out suspected signals that are consistent with the trend of the reference signal.
[0029] Furthermore, the calculation expressions for the first precision value, the second precision value, the first offset value, and the second offset value are respectively as follows:
[0030]
[0031]
[0032]
[0033]
[0034] in, These are the suspected signal values corresponding to the four time points, respectively. These are the reference signal values corresponding to the four time points, respectively. This is the first precision value. For the second precision value, The first offset value, This is the second offset value.
[0035] Furthermore, based on the suspected signal values and the reference signal values, the similarity between the suspected signal and the reference signal is calculated, specifically including:
[0036] Based on the chronological order of the multiple time points, a sequence of suspected signal values is determined according to each suspected signal value, and a sequence of reference signal values is determined according to each reference signal value.
[0037] Calculate the cosine similarity between the suspected signal value sequence and the reference signal value sequence;
[0038] The calculated cosine similarity is used as the similarity between the suspected signal and the reference signal.
[0039] Based on the above technical means, by calculating the cosine similarity, the changing trend between the suspected signal and the reference signal is further measured, and the suspected signal that is closest to the changing pattern of the reference signal is identified. This enables a more accurate CAN signal parsing process, making the entire signal parsing process more efficient and faster.
[0040] Furthermore, the expression for calculating the cosine similarity is:
[0041]
[0042]
[0043]
[0044] Where S is the cosine similarity. The suspected signal value sequence, For each of the suspected signal values, The reference signal value sequence, These are the values of the reference signals.
[0045] Furthermore, based on the similarity, the target signal in the bus message data is determined, specifically including:
[0046] If the cosine similarity satisfies the preset similarity, the message number of the bus message corresponding to the suspected signal and the starting number of bits of the suspected signal are determined, and the suspected signal is determined to be the target signal in the bus message data.
[0047] This specification provides a CAN signal parsing device based on cosine similarity, including:
[0048] The acquisition module is used to determine the target signal that needs to be parsed, and to acquire the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal.
[0049] The first determining module is used to determine, based on the bus message data and the reference signal data, the reference signals and bus messages corresponding to multiple time nodes within the preset time period.
[0050] The second determining module is used to determine each bus message corresponding to each time node as the bus message sequence corresponding to that time node, and to arrange each reference signal according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals;
[0051] The third determining module is used to determine each bus message in each bus message sequence;
[0052] The fourth determining module is used to determine, for each bus message in the bus message sequence, a signal with a bit length that matches the target signal as a suspected signal.
[0053] The fifth determining module is used to determine the values of the suspected signals at the multiple time nodes according to each bus message sequence, as each suspected signal value; and to determine each reference signal value according to the reference signal sequence.
[0054] The judgment module is used to determine whether the precision and offset between the suspected signal and the reference signal meet preset values based on the suspected signal values and the reference signal values; if yes, it calculates the similarity between the suspected signal and the reference signal based on the suspected signal values and the reference signal values, and determines the target signal in the bus message data based on the similarity; if no, it continues to determine whether the precision and offset between the next suspected signal and the reference signal meet preset values.
[0055] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described CAN signal parsing method based on cosine similarity.
[0056] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement a CAN signal parsing method based on cosine similarity.
[0057] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects:
[0058] By extracting bus message data and reference signal data over a period of time, for each suspected signal that matches the target signal bit length, the suspected signal's value at different time points is compared with the reference signal value determined from the reference signal data at different time points. Suspected signals with the same trend as the reference signal are filtered out, while those with inconsistent trends are excluded. This reduces the computational load of subsequent similarity calculations and improves CAN signal parsing efficiency. Furthermore, by calculating the similarity between the suspected signal and the reference signal—that is, by comparing the suspected signal's value at different time points with the reference signal's value at different time points—the target signal in the bus message data is accurately determined. Attached Figure Description
[0059] The accompanying drawings, which are included to provide a further understanding of this specification and form part of this specification, illustrate exemplary embodiments and are used to explain this specification, but do not constitute an undue limitation thereof. In the drawings:
[0060] Figure 1 A flowchart illustrating a CAN signal parsing method based on cosine similarity provided in the embodiments of this specification;
[0061] Figure 2 This specification provides a flowchart for signal analysis.
[0062] Figure 3 A schematic diagram of a CAN signal parsing device based on cosine similarity provided in this specification;
[0063] Figure 4 This specification provides a corresponding Figure 1 A schematic diagram of the structure of an electronic device. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.
[0065] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.
[0066] Figure 1 A flowchart illustrating a CAN signal parsing method based on cosine similarity provided in this specification includes the following steps:
[0067] S100: Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time period and the reference signal data corresponding to the target signal.
[0068] The process of CAN signal parsing based on cosine similarity described in this specification involves processing communication signal data. In the embodiments described herein, this process of CAN signal parsing based on cosine similarity can be performed by a server. Of course, this specification does not limit the type of device that performs this process of CAN signal parsing based on cosine similarity; devices such as personal computers and mobile terminals can also be used. For ease of description, the following description uses a server as the execution entity.
[0069] In one or more embodiments of this specification, since the vehicle communication bus includes multiple buses, different buses can transmit bus messages expressing different vehicle information. For example, if it is necessary to obtain CAN signals related to vehicle speed, a data acquisition module can be connected to the corresponding bus to obtain bus messages, and then the required CAN signal can be determined from the bus messages. Therefore, in this specification, the server can determine the target signal to be parsed (i.e., the required CAN signal mentioned above, hereinafter referred to as the target signal), and obtain the bus message data on the vehicle communication bus where the target signal is located and the reference signal data corresponding to the target signal within a preset time. The reference signal data can be acquired through a diagnostic instrument, a CAN analyzer, or related sensors, and is not limited in this specification. Subsequent steps are illustrated using a diagnostic instrument as an example.
[0070] Taking a diagnostic tool as an example, the diagnostic tool is connected to the vehicle's On-Board Diagnostics (OBD) interface. When the diagnostic tool requests a target signal (such as a CAN signal related to vehicle speed), the corresponding diagnostic signal is encapsulated in a diagnostic response message and transmitted on the bus. The diagnostic response message can be used as message data containing a reference signal. Therefore, the reference signal data corresponding to the target signal can be determined through the diagnostic response message. For example, if the diagnostic signal represents the vehicle speed, the acquired diagnostic signal can be converted into the physical value of the vehicle speed based on its original signal value. This physical value can then be used as the reference signal. Since several bus messages are transmitted simultaneously on the bus, each bus message can include several signals. Therefore, to determine and obtain the target signal representing the vehicle speed from these signals, each signal that meets the characteristics of the target signal can be filtered against the reference signal (the physical value of the vehicle speed) through subsequent steps. If no diagnostic response message is sent on the bus after connecting the diagnostic tool, the diagnostic bus on the OBD interface can be connected to collect the diagnostic response message.
[0071] It is worth noting that during the data acquisition process, the vehicle can be made to trigger the acquired bus message data and diagnostic response messages to change the signal over a wide range multiple times. For example, when analyzing the engine torque signal, it is necessary to operate the vehicle to start and stop the engine multiple times and make the transmitter torque reach its maximum. The bus message data and diagnostic response messages with drastic changes can more clearly show their characteristics and trends, which is convenient for subsequent analysis.
[0072] S102: Based on the bus message data and the reference signal data, determine the reference signals and bus messages corresponding to multiple time nodes within the preset time period.
[0073] S104: For each time node, determine the bus messages corresponding to that time node as the bus message sequence corresponding to that time node, and arrange the reference signals according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals.
[0074] In one or more embodiments of this specification, the server can determine the reference signal and each bus message corresponding to multiple time nodes within a preset time period based on bus message data and reference signal data. That is, taking n time nodes as an example, they are denoted as t1, t2, ... t in chronological order. n Within a preset time period, each bus message collected at each time node is considered the bus message corresponding to that time node. Similarly, within a preset time period, each reference signal collected at each time node is considered the reference signal corresponding to that time node.
[0075] Then, the server can determine the bus messages corresponding to each time point, which will be the bus message sequence for that time point, i.e., for t1, t2, ... t... n Each corresponding bus message is output and converted into binary form. Then, the bus messages corresponding to each time node are arranged to determine the bus message sequence. For example, arranging several bus messages corresponding to time node t1 yields the bus message sequence for t1. The number of bus messages in each time node's bus message sequence is the same. Furthermore, the reference signals can also be arranged according to the chronological order of multiple time points to obtain the reference signal sequence. Since both the bus message data and reference signal data are determined based on the same multiple time nodes, and since each time node is equivalent to acquiring one bus message sequence and one reference signal, the number of bus message sequences is the same as the number of reference signals in the reference signal sequence.
[0076] S106: For each bus message sequence, determine each bus message in that bus message sequence.
[0077] S108: For each bus message in the bus message sequence, determine a signal from the bus message that matches the bit length corresponding to the target signal as a suspected signal.
[0078] In one or more embodiments of this specification, for each bus message sequence, the server determines that there are multiple bus messages in the bus message sequence, where each bus message can be several bits long, such as 64 bits. Taking a 64-bit bus message as an example, this 64-bit bus message may contain a target signal. If the target signal to be parsed is 8 bits long, then in this 64-bit message, there are several 8-bit signals. These 8-bit signals may be the target signal, and these several 8-bit signals can be regarded as suspected signals of the suspected target signal.
[0079] Therefore, for each bus message in the bus message sequence, the server can determine the suspected signal in the bus message that matches the bit length corresponding to the target signal.
[0080] S110: Based on each bus message sequence, determine the values of the suspected signals corresponding to the multiple time nodes respectively, as each suspected signal value; and based on the reference signal sequence, determine each reference signal value.
[0081] In one or more embodiments of this specification, after the server determines a suspected signal that meets the bit length requirement, it can determine the values of the suspected signal at multiple time points based on each bus message sequence, which are then used as the suspected signal values. That is, since each bus message sequence contains several bus messages, and each bus message contains several suspected signals, taking the suspected signal as the signal composed of bits 1 to 8 in the first bus message (if the data field length is 64 bits) in the bus message sequence corresponding to time node t1, as an example, the binary display value of the suspected signal in the bus message at time node t1 is the value corresponding to time node t1, which is a suspected signal value. Of course, this suspected signal value can be the value after converting binary to decimal. The value corresponding to the suspected signal at time node t2 is the binary display value of the signal composed of bits 1 to 8 in the first bus message (also 64 bits) in the bus message sequence corresponding to time node t2. Similarly, the values of the suspected signal at t3, t4, ..., t1 can be calculated. nThe values corresponding to each of the remaining time points are then used to determine the individual suspected signal values. Since each suspected signal value corresponds to a time point, these values can be arranged chronologically to form the feature matrix of the suspected signal. . They are t1, t2, ..., t n The corresponding suspected signal value.
[0082] The server can also determine the value of the reference signal at each time node based on the reference signal sequence, and use it as the reference signal value.
[0083] Specifically, for each reference signal in the reference signal sequence, the server can determine the original value of the corresponding reference signal based on the reference signal data. Then, based on the original signal value, it can determine the physical value of the reference signal. Finally, the physical value is used as the reference signal value of that reference signal.
[0084] The conversion between the original signal value and the physical value is as follows: Physical value = k * original signal value + b. Here, k is the preset precision, and b is the preset offset. It's worth noting that the preset precision and offset are only used when calculating the physical value and are unrelated to the precision and offset involved in subsequent steps. Taking the reference signal in the vehicle speed diagnostic response message as an example, the calculated physical value is the vehicle speed, t1, t2, ... t n The reference signal values corresponding to each time point are t1, t2, ... t1. n The vehicle speed at each point in time.
[0085] Of course, since each reference signal value corresponds to a time node, the reference signal values can be arranged in chronological order to form the characteristic matrix of the reference signal. . They are t1, t2, ..., t n The corresponding reference signal value.
[0086] S112: Based on the suspected signal values and the reference signal values, determine whether the accuracy and offset between the suspected signal and the reference signal meet preset values. If yes, proceed to step S114. If no, proceed to step S116.
[0087] In one or more embodiments of this specification, the server can determine whether the precision and offset between the suspected signal and the reference signal meet preset values based on each suspected signal value and each reference signal value. If yes, step S114 is executed. If no, step S116 is executed.
[0088] Specifically, the server can determine four time nodes from multiple time nodes. Based on these four time nodes, it then determines the corresponding suspected signal values for each of the four time nodes from among the suspected signal values. Additionally, the server determines the corresponding reference signal values for each of the four time nodes from among the reference signal values. For example, if the four time nodes are t1, t2, t3, and t4, then the four suspected signal values are x1, x2, x3, and x4, and the four reference signal values are y1, y2, y3, and y4. The time nodes can be selected randomly or according to preset rules. These preset rules could include selecting the first four time nodes or the last four time nodes, etc. This specification does not impose any restrictions and can be set according to actual circumstances.
[0089] Then, the server calculates the first precision value, the second precision value, the first offset value, and the second offset value based on the suspected signal values corresponding to these four time points and the reference signal values corresponding to these four time points.
[0090] The calculation expressions for the first precision value, the second precision value, the first offset value, and the second offset value are as follows:
[0091]
[0092]
[0093]
[0094]
[0095] in, These are the suspected signal values corresponding to the four time points, respectively. These are the reference signal values corresponding to the four time points, respectively. This is the first precision value. For the second precision value, This is the first offset value. This is the second offset value.
[0096] Finally, the server can calculate the absolute value of the difference between the first precision value and the second precision value as the first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as the second absolute value.
[0097] Therefore, the server then determines whether both the first and second absolute values are less than a preset value. That is:
[0098]
[0099]
[0100] in, As a preset value, For the preset value range, The smaller the value, the more similar the suspected signal is to the reference signal, based on experience. The value can be between 0.05 and 0.9. If both the first absolute value and the second absolute value are less than the preset value, then proceed to step S114. Otherwise, proceed to step S116.
[0101] It is worth noting that, for calculating the first precision value, second precision value, first offset value, and second offset value, the server can select multiple sets of suspected signal values and reference signal values corresponding to four time nodes. For each set of suspected and reference signal values corresponding to four time nodes, a first precision value, second precision value, first offset value, and second offset value can be calculated, which are then used as the first precision value, second precision value, first offset value, and second offset value for that set. Finally, by combining the first precision values, second precision values, first offset values, and second offset values from multiple sets, the average of these multiple first precision values is calculated as the final first precision value, the average of these multiple second precision values is calculated as the final second precision value, the average of these multiple first offset values is calculated as the final first offset value, and the average of these multiple second offset values is calculated as the final second offset value. Based on these final first precision values, final second precision values, final first offset values, and final second offset values, the server then calculates the absolute value of the difference between the final first precision value and the final second precision value, which is used as the first absolute value, and calculates the absolute value of the difference between the final first offset value and the final second offset value, which is used as the second absolute value. The server then determines whether both the first absolute value and the second absolute value are less than the preset value.
[0102] S114: Calculate the similarity between the suspected signal and the reference signal based on the suspected signal value and the reference signal value, and determine the target signal in the bus message data based on the similarity.
[0103] In one or more embodiments of this specification, the server calculates the similarity between the suspected signal and the reference signal based on each suspected signal value and each reference signal value. Then, the target signal in the bus message data can be determined based on this similarity.
[0104] Specifically, the server can determine the sequence of suspected signal values based on the chronological order of multiple time points and the values of each suspected signal value. And based on each reference signal value, determine the reference signal value sequence, i.e. Then, based on the suspected signal value sequence and the reference signal value sequence, the cosine similarity is calculated. The calculated cosine similarity is used as the similarity between the suspected signal and the reference signal.
[0105] The expression for calculating cosine similarity is:
[0106]
[0107]
[0108]
[0109] Where S is the cosine similarity. This is a sequence of suspected signal values. The values of the suspected signal at n time points. For the reference signal value sequence, The reference signal values at n time points.
[0110] In one or more embodiments of this specification, after calculating the cosine similarity, the server can determine whether the cosine similarity meets the preset similarity. Preset similarity, range is ,if If S is close to 1, it means that the cosine similarity meets the preset similarity; otherwise, it does not. The closer S is to 1, the more similar the trend of change.
[0111] If the cosine similarity meets the preset similarity, the server determines the message number of the bus message corresponding to the suspected signal (i.e., the bus message containing the suspected signal) and the starting number of bits of the suspected signal, thereby determining the specific location of the suspected signal. It also determines that the suspected signal is the target signal in the bus message data.
[0112] Of course, the server may ultimately identify multiple target signals from the bus message data. In this case, it can select one or more target signals with the highest cosine similarity based on their cosine similarity. These signals are then fed back to the user, who can choose the final target signal based on the correlation between the signals.
[0113] If the cosine similarity does not meet the preset similarity, then continue to determine whether the precision and offset between the next suspected signal and the reference signal meet the preset values.
[0114] S116: Continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset values.
[0115] In one or more embodiments of this specification, if the server determines that the precision and offset between the suspected signal and the reference signal do not meet the preset value, since there may be multiple suspected signals with a preset bit length in each bus message, the server can continue to determine whether the precision and offset between the next suspected signal with a preset bit length and the reference signal meet the preset value, and then continue to perform CAN signal parsing.
[0116] based on Figure 1 This paper presents a CAN signal parsing method based on cosine similarity. By extracting bus message data and reference signal data over a period of time, for each suspected signal matching the target signal bit length, the method compares the suspected signal value at different time points with the reference signal value determined from the reference signal data at those same time points. This avoids direct point-by-point comparison of the original signal in the bus message data, reducing computational complexity. It filters out suspected signals with the same trend as the reference signal and excludes those with inconsistent trends, reducing the computational load of subsequent similarity calculations and improving CAN signal parsing efficiency. Furthermore, by calculating the similarity between the suspected signal and the reference signal—that is, by comparing the suspected signal value at different time points with the reference signal value at the same time points—the method accurately locates the target signal in the bus message data. By focusing on the changing trend of the suspected and reference signals, rather than the specific numerical value of the suspected signal, the reliability of the similarity judgment between the suspected and reference signals is improved. Cosine similarity can accurately calculate the similarity between the suspected and reference signals, identifying the signal with the closest changing pattern to the reference signal. This method not only simplifies the comparison process of suspected signals, but also greatly improves the accuracy of signal analysis, making the entire signal analysis process more efficient and faster.
[0117] Figure 2 This is a flowchart illustrating signal analysis provided in this specification. Figure 2 As shown, for a suspected signal, k1, k2, b1, and b2 are calculated by selecting the suspected signal values corresponding to four time points and comparing them with the reference signal values. Suspected signals whose accuracy and offset between the suspected signal and the reference signal meet preset values are selected. If not, the process ends, and the same process is repeated for the next suspected signal. If the conditions are met, the cosine similarity is calculated for the suspected signal. If the cosine similarity meets the preset similarity, the message number of the message containing the suspected signal and the starting number of bits of the suspected signal are determined, thus determining the specific location of the suspected signal. The suspected signal is then identified as the target signal in the bus message data; otherwise, the process ends, and the same process is repeated for the next suspected signal.
[0118] The above describes a CAN signal parsing method based on cosine similarity, provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding CAN signal parsing device based on cosine similarity, such as... Figure 3 As shown.
[0119] Figure 3 This specification provides a schematic diagram of a CAN signal parsing device based on cosine similarity, which specifically includes:
[0120] The acquisition module 300 is used to determine the target signal to be parsed, and to acquire the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal.
[0121] The first determining module 302 is used to determine, based on the bus message data and the reference signal data, the reference signals and bus messages corresponding to multiple time nodes within the preset time period.
[0122] The second determining module 304 is used to determine each bus message corresponding to each time node as the bus message sequence corresponding to that time node, and to arrange each reference signal according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals;
[0123] The third determining module 306 is used to determine each bus message in each bus message sequence;
[0124] The fourth determining module 308 is used to determine, for each bus message in the bus message sequence, a signal with a bit length that matches the target signal as a suspected signal.
[0125] The fifth determining module 310 is used to determine the values of the suspected signals at the multiple time nodes according to each bus message sequence, as each suspected signal value; and to determine each reference signal value according to the reference signal sequence.
[0126] The judgment module 312 is used to determine whether the precision and offset between the suspected signal and the reference signal meet a preset value based on the suspected signal value and the reference signal value; if yes, it calculates the similarity between the suspected signal and the reference signal based on the suspected signal value and the reference signal value, and determines the target signal in the bus message data based on the similarity; if no, it continues to determine whether the precision and offset between the next suspected signal and the reference signal meet the preset value.
[0127] Optionally, the fifth determining module 310 is further configured to, for each reference signal in the reference signal sequence, determine the original signal value corresponding to the reference signal based on the reference signal data, determine the physical value of the reference signal based on the original signal value, and use the physical value as the reference signal value of the reference signal.
[0128] Optionally, the judgment module 312 is further configured to determine four time nodes from the plurality of time nodes, determine the suspected signal values corresponding to the four time nodes from the suspected signal values based on the four time nodes, and determine the reference signal values corresponding to the four time nodes from the reference signal values, calculate a first precision value, a second precision value, a first offset value, and a second offset value based on the suspected signal values and the reference signal values corresponding to the four time nodes, calculate the absolute value of the difference between the first precision value and the second precision value as the first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as the second absolute value, and determine whether the first absolute value and the second absolute value are both less than a preset value.
[0129] Optionally, the judgment module 312 is further configured to calculate the first precision value, the second precision value, the first offset value, and the second offset value, respectively using the following calculation expressions:
[0130]
[0131]
[0132]
[0133]
[0134] in, These are the suspected signal values corresponding to the four time points, respectively. These are the reference signal values corresponding to the four time points, respectively. This is the first precision value. For the second precision value, The first offset value, This is the second offset value.
[0135] Optionally, the judgment module 312 is further configured to determine a sequence of suspected signal values according to the chronological order of the multiple time nodes and based on the suspected signal values, calculate a cosine similarity between the suspected signal value sequence and the reference signal value sequence, and use the calculated cosine similarity as the similarity between the suspected signal and the reference signal.
[0136] Optionally, the judgment module 312 is further configured to calculate the cosine similarity using the following calculation expression:
[0137]
[0138]
[0139]
[0140] Where S is the cosine similarity. The suspected signal value sequence, For each of the suspected signal values, The reference signal value sequence, These are the values of the reference signals.
[0141] Optionally, the judgment module 312 is further configured to, when the cosine similarity satisfies a preset similarity, determine the message number of the bus message corresponding to the suspected signal and the starting number of the suspected signal, and determine that the suspected signal is the target signal in the bus message data.
[0142] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 A CAN signal parsing method based on cosine similarity is provided.
[0143] This instruction manual also provides Figure 4 The diagram shows a schematic structural representation of the electronic device. Figure 4 As shown, at the hardware level, this electronic device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above. Figure 1 The aforementioned CAN signal parsing method based on cosine similarity.
[0144] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0145] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0146] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0147] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0148] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.
[0149] Those skilled in the art will understand that embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0150] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0151] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0152] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0153] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0154] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0155] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0156] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0157] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0158] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0159] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0160] The above description is merely an embodiment of this specification and is not intended to limit this specification. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.
Claims
1. A CAN signal parsing method based on cosine similarity, characterized in that, include: Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time period and the reference signal data corresponding to the target signal; Based on the bus message data and the reference signal data, determine the reference signals and bus messages corresponding to multiple time nodes within the preset time period. For each time node, the bus messages corresponding to that time node are determined as the bus message sequence corresponding to that time node, and the reference signals are arranged according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals; For each bus message sequence, determine each bus message in that bus message sequence; For each bus message in the bus message sequence, a signal with a bit length that matches the target signal is identified from the bus message as a suspected signal; Based on each bus message sequence, the values of the suspected signals at the multiple time nodes are determined as the suspected signal values; and based on the reference signal sequence, the reference signal values are determined. Based on the suspected signal values and the reference signal values, determine whether the accuracy and offset between the suspected signal and the reference signal meet preset values; If so, then based on each suspected signal value and each reference signal value, the similarity between the suspected signal and the reference signal is calculated, and based on the similarity, the target signal in the bus message data is determined; If not, then continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset values.
2. The CAN signal parsing method based on cosine similarity as described in claim 1, characterized in that, Determining each reference signal value based on the reference signal sequence specifically includes: For each reference signal in the reference signal sequence, the original value of the corresponding reference signal is determined based on the reference signal data. Based on the original value of the signal, determine the physical value of the reference signal; The physical value is used as the reference signal value for the reference signal.
3. The CAN signal parsing method based on cosine similarity as described in claim 1, characterized in that, Based on the suspected signal values and the reference signal values, it is determined whether the accuracy and offset between the suspected signal and the reference signal meet preset values, specifically including: From the plurality of time points, four time points are determined; Based on the four time points, determine the suspected signal values corresponding to the four time points from the suspected signal values; and determine the reference signal values corresponding to the four time points from the reference signal values. Based on the suspected signal values corresponding to the four time nodes and the reference signal values corresponding to the four time nodes, calculate the first precision value, the second precision value, the first offset value, and the second offset value. Calculate the absolute value of the difference between the first precision value and the second precision value as the first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as the second absolute value; Determine whether both the first absolute value and the second absolute value are less than a preset value.
4. The CAN signal parsing method based on cosine similarity as described in claim 3, characterized in that, The calculation expressions for the first precision value, the second precision value, the first offset value, and the second offset value are respectively: in, These are the suspected signal values corresponding to the four time points, respectively. These are the reference signal values corresponding to the four time points, respectively. This is the first precision value. For the second precision value, The first offset value, This is the second offset value.
5. The CAN signal parsing method based on cosine similarity as described in claim 3, characterized in that, Based on the suspected signal values and the reference signal values, the similarity between the suspected signal and the reference signal is calculated, specifically including: Based on the chronological order of the multiple time points, a sequence of suspected signal values is determined according to each suspected signal value, and a sequence of reference signal values is determined according to each reference signal value. Calculate the cosine similarity between the suspected signal value sequence and the reference signal value sequence; The calculated cosine similarity is used as the similarity between the suspected signal and the reference signal.
6. The CAN signal parsing method based on cosine similarity as described in claim 5, characterized in that, The expression for calculating the cosine similarity is: Where S is the cosine similarity. The suspected signal value sequence, For each of the suspected signal values, The reference signal value sequence, These are the values of the reference signals.
7. The CAN signal parsing method based on cosine similarity as described in claim 5, characterized in that, Determining the target signal in the bus message data based on the similarity score specifically includes: If the cosine similarity satisfies the preset similarity, the message number of the bus message corresponding to the suspected signal and the starting number of bits of the suspected signal are determined, and the suspected signal is determined to be the target signal in the bus message data.
8. A CAN signal parsing device based on cosine similarity, characterized in that, include: The acquisition module is used to determine the target signal that needs to be parsed, and to acquire the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal. The first determining module is used to determine, based on the bus message data and the reference signal data, the reference signals and bus messages corresponding to multiple time nodes within the preset time period. The second determining module is used to determine each bus message corresponding to each time node as the bus message sequence corresponding to that time node, and to arrange each reference signal according to the time sequence of the multiple time nodes to determine the reference signal sequence, wherein the number of bus message sequences is the same as the number of reference signals; The third determining module is used to determine each bus message in each bus message sequence; The fourth determining module is used to determine, for each bus message in the bus message sequence, a signal with a bit length that matches the target signal as a suspected signal. The fifth determining module is used to determine the values of the suspected signals at the multiple time nodes according to each bus message sequence, as each suspected signal value; and to determine each reference signal value according to the reference signal sequence. The judgment module is used to determine whether the precision and offset between the suspected signal and the reference signal meet preset values based on the suspected signal values and the reference signal values; if yes, it calculates the similarity between the suspected signal and the reference signal based on the suspected signal values and the reference signal values, and determines the target signal in the bus message data based on the similarity; if no, it continues to determine whether the precision and offset between the next suspected signal and the reference signal meet preset values.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method described in any one of claims 1 to 7.