CAN signal analysis method based on cosine similarity

By calculating the similarity between the CAN signal and the reference signal based on cosine similarity, filtering out suspected signals with consistent change trends, solving the problem of inefficient CAN signal resolution in the prior art, and achieving efficient and accurate signal analysis.

CN120416366AActive Publication Date: 2025-08-01CHINA AUTOMOTIVE ENG RES INST +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510757835.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-08-01
Estimated Expiration
2045-06-09

AI Technical Summary

Technical Problem

In the prior art, it is difficult to efficiently and accurately screen and analyze automotive CAN signals by relying on manual identification, resulting in inefficient CAN signal resolution.

Method used

By calculating the similarity between the bus message data and the reference signal data, a suspected signal consistent with the change trend of the reference signal is selected, signals with inconsistent change trends are excluded, and the resolution efficiency is improved.

Benefits of technology

By calculating the similarity between the suspected signal and the reference signal, accurately positioning the target signal in the bus message data, improving the efficiency and accuracy of CAN signal resolution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120416366A_ABST
    Figure CN120416366A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of signal analysis, and discloses a CAN signal analysis method based on cosine similarity. Bus message data and reference signal data of a vehicle communication bus are obtained, and bus messages and reference signals corresponding to the multiple time nodes are determined. For each bus message, a suspected signal is determined. Determining signal values respectively corresponding to the suspected signal at the plurality of time nodes, and a reference signal value; and according to each suspected signal value and each reference signal value, judging whether the precision and offset between the suspected signal and the reference signal meet preset values or not. And if yes, calculating and determining a target signal in the bus message data according to the similarity. The similarity between the suspected signal and the reference signal can be accurately calculated through the cosine similarity, and the signal closest to the change rule of the reference signal is identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the technical field of signal parsing, and particularly to a CAN signal parsing method based on cosine similarity. Background Art

[0002] Currently, with the rapid development of new energy electric vehicles, the number of electronic control units (ECUs) inside the vehicle has increased exponentially, and the functional complexity has also been significantly improved. These ECUs need to work together through an in-vehicle communication network. Among them, the Controller Area Network (CAN), as the core communication protocol, undertakes most of the in-vehicle signal transmission tasks. Due to its high reliability, strong real-time performance, and easy access, CAN signals have become an important data source in the field of vehicle evaluation - they neither interfere with the normal communication and operation of the vehicle nor provide accurate data support for the evaluation work.

[0003] In the current technology, the method for screening and determining CAN signals from the communication data obtained from vehicles usually relies on manual identification to determine the data that may contain CAN signals, depending on manual 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 above problems existing in the prior art.

[0006] This specification adopts the following technical solutions: This specification provides a CAN signal parsing method based on cosine similarity, including: Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal; According to the bus message data and the reference signal data, determine the reference signals and each bus message corresponding to multiple time nodes within the preset time; For each time node, determine each bus message corresponding to this time node as the bus message sequence corresponding to this time node, and arrange the reference signals in the chronological order of the multiple time nodes to determine the reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals; For each bus message sequence, determine each bus message in this bus message sequence; For each bus message in the bus message sequence, determine a signal that meets the bit length corresponding to the target signal in the bus message as a suspected signal; According to each bus message sequence, determine the values corresponding to the suspected signals at the multiple time nodes as the respective suspected signal values; and according to the reference signal sequence, determine the respective reference signal values; According to the respective suspected signal values and the reference signal values, determine whether the accuracy and offset between the suspected signal and the reference signal meet a preset value; If so, calculate the similarity between the suspected signal and the reference signal according to the respective suspected signal values and the respective reference signal values, and determine the target signal in the bus message data according to the similarity; If not, continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset value.

[0007] According to the above technical means, by extracting bus message data and reference signal data within a period of time, for each suspected signal that meets the bit length of the target signal, according to the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal determined from the reference signal data at different time points, filter out the suspected signals with the same change trend as the reference signal, exclude the suspected signals with inconsistent change trends, reduce the computational complexity of subsequent similarity calculation, and improve the CAN signal parsing efficiency. Further, by calculating the similarity between the suspected signal and the reference signal, that is, calculating the similarity according to the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal at different time points, accurately determine the target signal in the bus message data.

[0008] Further, determining the respective reference signal values according to the reference signal sequence specifically includes: For each reference signal in the reference signal sequence, determine the original signal value corresponding to the reference signal according to the reference signal data; According to the original signal value, determine the physical value of the reference signal; Take the physical value as the reference signal value of the reference signal.

[0009] Further, determining whether the accuracy and offset between the suspected signal and the reference signal meet the preset value according to the respective suspected signal values and the respective reference signal values specifically includes: Determine four time nodes from the multiple time nodes; According to the four time nodes, determine the suspected signal values corresponding to the four time nodes from the respective suspected signal values; and determine the reference signal values corresponding to the four time nodes from the respective reference signal values; Calculate a first accuracy value, a second accuracy value, a first offset value, and a second offset value according to the suspected signal values corresponding to the four time nodes respectively and the reference signal values corresponding to the four time nodes respectively; Calculate the absolute value of the difference between the first accuracy value and the second accuracy value as a first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as a second absolute value; Determine whether both the first absolute value and the second absolute value are less than a preset value.

[0010] According to the above technical means, by selecting the suspected signal values and reference signal values at four time nodes, calculate whether the accuracy and offset between the suspected signal and the reference signal meet the preset requirements. This not only avoids directly using all suspected signal values and reference signal values, but also by restricting the number of selected time nodes, makes it pay more attention to the overall trend of the suspected signal rather than local anomalies, and can also preliminarily screen out the suspected signals whose change trends are consistent with the reference signal.

[0011] Further, the calculation expressions for the first accuracy value, the second accuracy value, the first offset value, and the second offset value are respectively:

[0012]

[0013]

[0014]

[0015] Wherein, are respectively the suspected signal values corresponding to the four time nodes respectively, are respectively the reference signal values corresponding to the four time nodes respectively, is the first accuracy value, is the second accuracy value, is the first offset value, is the second offset value.

[0016] Further, calculate the similarity between the suspected signal and the reference signal according to the respective suspected signal values and the respective reference signal values, specifically including: According to the time sequence of the multiple time nodes, determine a suspected signal value sequence according to the respective suspected signal values, and determine a reference signal value sequence according to the respective reference signal values; Calculate the cosine similarity according to the suspected signal value sequence and the reference signal value sequence; Use the calculated cosine similarity as the similarity between the suspected signal and the reference signal.

[0017] According to the above technical means, by calculating the cosine similarity, the change trend between the suspected signal and the reference signal is further measured, and the suspected signal closest to the change law of the reference signal is identified, which can more accurately implement the CAN signal parsing process and make the entire signal parsing process more efficient and fast.

[0018] Further, the calculation expression of the cosine similarity is:

[0019]

[0020]

[0021] where S is the cosine similarity, is the sequence of suspected signal values, is each suspected signal value, is the sequence of reference signal values, is each reference signal value.

[0022] Further, according to the similarity, determine the target signal in the bus message data, specifically including: When the cosine similarity meets the preset similarity, determine the message number of the bus message corresponding to the suspected signal and the starting bit number of the suspected signal, and determine the suspected signal as the target signal in the bus message data.

[0023] This specification provides a CAN signal parsing device based on cosine similarity, including: An acquisition module, configured to determine the target signal to be parsed, and acquire the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal; A first determination module, configured to determine the reference signal and each bus message corresponding to multiple time nodes within the preset time according to the bus message data and the reference signal data; A second determination module, configured to, for each time node, determine each bus message corresponding to the time node as the bus message sequence corresponding to the time node, and arrange the reference signals in the order of the time sequence of the multiple time nodes to determine the reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals; A third determination module, configured to, for each bus message sequence, determine each bus message in the bus message sequence; A fourth determination module, configured to, for each bus message in the bus message sequence, determine a signal that meets the bit length corresponding to the target signal in the bus message as a suspected signal; A fifth determination module, configured to determine, according to each bus message sequence, values corresponding to the suspected signal at the multiple time nodes as respective suspected signal values; and determine respective reference signal values according to the reference signal sequence; A judgment module, configured to judge whether the accuracy and offset between the suspected signal and the reference signal meet a preset value according to the respective suspected signal values and the respective reference signal values; if so, calculate the similarity between the suspected signal and the reference signal according to the respective suspected signal values and the respective reference signal values, and determine the target signal in the bus message data according to the similarity; if not, continue to judge whether the accuracy and offset between the next suspected signal and the reference signal meet the preset value.

[0024] This specification provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned CAN signal parsing method based on cosine similarity is implemented.

[0025] This specification provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, the CAN signal parsing method based on cosine similarity is implemented.

[0026] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects: By extracting bus message data and reference signal data within a period of time, for each suspected signal that meets the bit length of the target signal, according to the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal determined from the reference signal data at different time points, filter out the suspected signals with the same change trend as the reference signal, exclude the suspected signals with inconsistent change trends, reduce the calculation amount of subsequent similarity calculation, and improve the CAN signal parsing efficiency. Further, by calculating the similarity between the suspected signal and the reference signal, that is, calculating the similarity according to the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal at different time points, accurately determine the target signal in the bus message data. Description of the Drawings

[0027] The drawings described herein are used to provide a further understanding of this specification, and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation of this specification. In the drawings: Figure 1Schematic flowchart of a CAN signal parsing method based on cosine similarity provided by an embodiment of this specification; Figure 2 Flowchart of a signal parsing method provided by this specification; Figure 3 Schematic diagram of a CAN signal parsing device based on cosine similarity provided by this specification; Figure 4 Provided by this specification corresponding to Figure 1 Schematic structural diagram of an electronic device. Detailed implementation manners

[0028] 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 of this specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the scope of protection of this application.

[0029] The following will, with reference to the drawings, detail the technical solutions provided by each embodiment of this specification.

[0030] Figure 1 Schematic flowchart of a CAN signal parsing method based on cosine similarity provided by an embodiment of this specification, including the following steps: S100: Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal.

[0031] In the process of CAN signal parsing based on cosine similarity in this specification, it involves the processing of communication signal data. In the embodiments of this specification, the process of CAN signal parsing based on cosine similarity can be executed by a server. Of course, this specification does not limit which device implements the process of CAN signal parsing based on cosine similarity, and devices such as personal computers and mobile terminals can also be used for CAN signal parsing based on cosine similarity. For the convenience of description, the server will be used as the execution entity for explanation below.

[0032] In one or more embodiments of the present specification, since the vehicle communication bus includes multiple buses, bus messages representing different vehicle information can be transmitted on different buses. For example, if it is necessary to obtain the CAN signal related to the vehicle speed, the data acquisition module can be connected to the corresponding bus to obtain the bus message, and then analyze and determine the required CAN signal from the bus message. Therefore, in the present specification, the server can determine the target signal to be parsed (i.e., the above-mentioned required CAN signal, and all the following content is referred to as the target signal), and obtain the bus message data on the vehicle communication bus where the target signal is collected within a preset time and the reference signal data corresponding to the target signal. Among them, the reference signal data can be collected through a diagnostic instrument, a CAN analyzer or relevant sensors, which is not limited in the present specification. The subsequent steps will be exemplarily described taking the diagnostic instrument as an example.

[0033] Taking the diagnostic instrument as an example, connect the diagnostic instrument to the On-Board Diagnostics (OBD) interface of the vehicle. When requesting the target signal (such as the CAN signal related to the vehicle speed) through the diagnostic instrument, the diagnostic signal corresponding to the target signal will be encapsulated in the diagnostic response message and transmitted on the bus. And the diagnostic response message can be used as the message data containing the reference signal. Thus, the reference signal data corresponding to the target signal can be determined through the diagnostic response message. For example, the vehicle speed represented by the diagnostic signal. The obtained diagnostic signal can be converted into the physical value of the vehicle speed according to its original signal value, and this physical value can be used as the reference signal. And several bus messages will be transmitted on the bus at the same time, and each bus message can include several signals. Therefore, to determine and obtain the target signal that can represent the vehicle speed among these several signals, each signal that conforms to the characteristics of the target signal can be screened through the subsequent steps with the reference signal (the physical value of the vehicle speed). Among them, if no diagnostic response message is sent on the bus after connecting the diagnostic instrument, the diagnostic bus on the OBD interface can be connected to collect the diagnostic response message.

[0034] It is worth noting that during the data acquisition process, the vehicle can be made to trigger as many large-range and multiple changes of the signals in the obtained bus message data and diagnostic response message as possible. For example, when parsing the engine torque signal, it is necessary to operate the vehicle to start and stop the engine multiple times and make the engine torque reach the maximum. The bus message data and diagnostic response message with drastic changes in the collected data can more clearly show their characteristics and change trends, which is convenient for subsequent analysis.

[0035] S102: Determine the reference signal and each bus message corresponding to multiple time nodes within the preset time according to the bus message data and the reference signal data.

[0036] S104: For each time node, determine each bus message corresponding to the time node as the bus message sequence corresponding to the time node, and arrange each reference signal in the chronological order of the multiple time nodes to determine the reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals.

[0037] In one or more embodiments of the present specification, the server may determine the reference signals and each bus message respectively corresponding to multiple time nodes within a preset time according to the bus message data and the reference signal data. That is, taking the multiple time nodes as n time nodes as an example, they are denoted as t1, t2,... t n in chronological order. Within the preset time, each bus message collected at each time node is the bus message corresponding to the time node. Similarly, within the preset time, the reference signal collected at each time node is the reference signal corresponding to the time node.

[0038] After that, the server can then determine each bus message corresponding to each time node as the bus message sequence corresponding to the time node, that is, output and convert each bus message corresponding to t1, t2,... t n into binary form respectively, and then arrange each bus message corresponding to each time node to determine each bus message sequence. For example, arrange several bus messages corresponding to the t1 time node to obtain the bus message sequence corresponding to t1, where the number of bus messages in the bus message sequence corresponding to each time node is the same. And, according to the chronological order of multiple time points, each reference signal can also be arranged to obtain the reference signal sequence. Of course, since both the bus message data and the reference signal data are used to determine the bus message sequence and the reference signal sequence based on the same multiple time nodes, and since a bus message sequence and a reference signal are collected at each time node, the number of the bus message sequences is the same as the number of reference signals in the reference signal sequence.

[0039] S106: For each bus message sequence, determine each bus message in the bus message sequence.

[0040] S108: For each bus message in the bus message sequence, determine a signal that meets the bit length corresponding to the target signal from the bus message as a suspected signal.

[0041] 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. Among them, the length of each bus message can be several bit lengths, such as 64 bits. Taking a 64-bit bus message as an example, there may be a target signal in this 64-bit bus message. If the length of the target signal to be parsed is 8 bits, then in this 64-bit message, there are several 8-bit signals, and these 8-bit signals may be the target signals. Then these several 8-bit signals can be regarded as suspected signals of the suspected target signal.

[0042] Therefore, the server can determine, for each bus message in the bus message sequence, the suspected signals that meet the bit length corresponding to the target signal in the bus message.

[0043] S110: According to each bus message sequence, determine the values corresponding to the suspected signals at the multiple time nodes as the respective suspected signal values; and according to the reference signal sequence, determine the respective reference signal values.

[0044] In one or more embodiments of this specification, after the server determines a suspected signal that meets the bit length. It can determine the values corresponding to the suspected signal at multiple time points according to each bus message sequence as the respective suspected signal values. That is, since there are several bus messages in each bus message sequence, and there are several suspected signals in each bus message, then, taking the signal composed of the 1st to 8th bits in the first bus message (if the data field length is 64 bits) in the bus message sequence corresponding to the t1 time node as an example of the suspected signal, the value displayed in binary of the suspected signal in the bus message at the t1 time point is the value corresponding to the suspected signal at the t1 time point, which is a suspected signal value. Of course, the suspected signal value can be the value after converting binary to decimal. And the value corresponding to the suspected signal at the t2 time point is the value displayed in binary in the signal composed of the 1st to 8th bits in the first bus message (also 64 bits) in the bus message sequence corresponding to the t2 time node. Similarly, the values corresponding to the suspected signal at t3, t4,... t n The values corresponding to the remaining each time node respectively. Finally, the respective suspected signal values of the suspected signal can be determined. Of course, since each suspected signal value can correspond to a time node, therefore, the respective suspected signal values can be arranged in the order of time to form the characteristic matrix of the suspected signal . Respectively the suspected signal values corresponding to t1, t2,... t n corresponding.

[0045] The server can also determine the values corresponding to the reference signal at each time node according to the reference signal sequence as the respective reference signal values of the reference signal.

[0046] Specifically, for each reference signal in the reference signal sequence, the server can determine the original signal value corresponding to the reference signal according to the reference signal data. Then, based on the original signal value, the physical value of the reference signal can be determined. Finally, the physical value is used as the reference signal value of the reference signal.

[0047] The conversion method between the original signal value and the physical value is: physical value = k * original signal value + b. Where k is the preset precision and b is the preset offset. It should be noted that the preset precision and preset offset here are only used when calculating the physical value and have nothing to do with the precision and offset involved in the subsequent steps. Taking the reference signal in the diagnostic response message of vehicle speed as an example, the calculated physical value is the vehicle speed, t1, t2,... t n The reference signal values corresponding to each time node are t1, t2,... t n The vehicle speed at each time node.

[0048] Of course, since each reference signal value can correspond to a time node, therefore, the reference signal values can be arranged in chronological order to form the feature matrix of the reference signal. . They are t1, t2,... t n The corresponding reference signal values.

[0049] S112: According to the suspected signal values and the reference signal values, determine whether the precision and offset between the suspected signal and the reference signal meet the preset values. If so, execute step S114. If not, execute step S116.

[0050] 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 the preset values according to the suspected signal values and the reference signal values. If so, execute step S114. If not, execute step S116.

[0051] Specifically, the server can determine four time nodes from multiple time nodes. Then, according to these four time nodes, determine the suspected signal values corresponding to these four time nodes from the suspected signal values. And the server determines the reference signal values corresponding to these four time nodes from the reference signal values. For example, four time nodes t1, t2, t3, t4 can be determined, then the four determined suspected signal values are x1, x2, x3, x4, and the four determined reference signal values are y1, y2, y3, y4. Among them, the way to select time nodes can be random selection or according to a preset rule. The preset rule can be to select the first four time nodes or the last four time nodes, etc. There is no limitation in this specification and it can be set according to the actual situation.

[0052] After that, based on the suspected signal values corresponding to the four time nodes respectively and the reference signal values corresponding to the four time nodes respectively, the server calculates a first precision value, a second precision value, a first offset value, and a second offset value.

[0053] The calculation expressions for the first precision value, the second precision value, the first offset value, and the second offset value are respectively:

[0054]

[0055]

[0056]

[0057] Among them, are respectively the suspected signal values corresponding to the four time nodes respectively, are respectively the reference signal values corresponding to the four time nodes respectively, is the first precision value, is the second precision value, is the first offset value, is the second offset value.

[0058] 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.

[0059] Then, the server determines whether both the first absolute value and the second absolute value are less than a preset value. That is:

[0060]

[0061] Among them, is the preset value, is the preset value range, The smaller the value, the more similar the suspected signal and the reference signal are. According to experience The value can be taken between 0.05 and 0.9. If both the first absolute value and the second absolute value are less than the preset value, then step S114 is executed. Otherwise, step S116 is executed.

[0062] It should be noted that for calculating the first precision value, the second precision value, the first offset value, and the second offset value, the server can select the suspected signal values and reference signal values corresponding to multiple groups of 4 time nodes. The suspected signal values and reference signal values corresponding to the 4 time nodes in each group can all calculate the first precision value, the second precision value, the first offset value, and the second offset value, which are used as the first precision value, the second precision value, the first offset value, and the second offset value of this group. Finally, by comprehensively considering the first precision values, second precision values, first offset values, and second offset values of multiple groups, calculate the average value of these multiple first precision values as the final first precision value, the average value of these multiple second precision values as the final second precision value, the average value of these multiple first offset values as the final first offset value, and the average value of these multiple second offset values as the final second offset value. The server then calculates the absolute value of the difference between the final first precision value and the final second precision value based on these final first precision values, final second precision values, final first offset values, and final second offset values 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 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.

[0063] S114: Calculate the similarity between the suspected signal and the reference signal based on the respective suspected signal values and the respective reference signal values, and determine the target signal in the bus message data based on the similarity.

[0064] In one or more embodiments of this specification, the server calculates the similarity between the suspected signal and the reference signal based on the respective suspected signal values and the respective reference signal values. Then, the target signal in the bus message data can be determined based on this similarity.

[0065] Specifically, the server can determine the suspected signal value sequence according to the respective suspected signal values in the chronological order of multiple time nodes, that is and determine the reference signal value sequence according to the respective reference signal values, that is . Then, calculate the cosine similarity based on 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.

[0066] The calculation expression of the cosine similarity is:

[0067]

[0068]

[0069] where S is the cosine similarity, is a sequence of suspected signal values, is the value of the suspected signal at n time nodes, is a sequence of reference signal values, is the value of the reference signal at n time nodes.

[0070] 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. The preset similarity ranges from , if , it means that the cosine similarity meets the preset similarity, otherwise it does not. The closer S is to 1, the more similar the change trends are. When the cosine similarity meets the preset similarity, the server determines the message number and the starting bit number of the bus message corresponding to the suspected signal (i.e., the bus message where the suspected signal is located), and thus can determine the specific position of the suspected signal. And determine that the suspected signal is the target signal in the bus message data.

[0071] Of course, the server may finally determine multiple target signals from the bus message data. Then, one or more target signals with the highest cosine similarity can be selected according to the cosine similarity. These signals are fed back to the user, and the user selects according to the relevance of the signals as the finally parsed target signals.

[0072] If the cosine similarity does not meet the preset similarity, continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset value.

[0073] S116: Continue to determine whether the accuracy and offset between the next suspected signal and the reference signal meet the preset value.

[0074] In one or more embodiments of this specification, if the server determines that the accuracy and offset between the suspected signal and the reference signal do not meet the preset value, since there may be multiple suspected signals that meet the preset bit length in each bus message, the server can continue to determine whether the accuracy and offset between the next suspected signal that meets the preset bit length and the reference signal meet the preset value, and then continue with the CAN signal parsing.

[0075] Based on Figure 1A CAN signal parsing method based on cosine similarity is provided. By extracting bus message data and reference signal data within a period of time, for each suspected signal that meets the target signal bit length, according to the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal determined from the reference signal data at different time points, it avoids directly comparing the original signals in the bus message data point by point, thereby reducing the computational complexity. It screens out the suspected signals whose change trends are consistent with the reference signal and excludes the suspected signals with inconsistent change trends, reducing the computational amount of calculating the similarity subsequently and improving the CAN signal parsing efficiency. Further, by calculating the similarity between the suspected signal and the reference signal, that is, calculating the similarity through the suspected signal values of the suspected signal at different time points and the reference signal values of the reference signal at different time points, the target signal in the bus message data is accurately located. By focusing on the change trends of the suspected signal and the reference signal rather than the specific values of the suspected signal, the reliability of the similarity judgment between the suspected signal and the reference signal is improved. The cosine similarity can accurately calculate the similarity between the suspected signal and the reference signal and identify the signal that is closest to the change law of the reference signal. This method not only simplifies the comparison process of the suspected signals but also greatly improves the accuracy of signal parsing, making the entire signal parsing process more efficient and fast.

[0076] Figure 2 This is a flowchart of signal parsing provided in this specification. As Figure 2 shown, for a suspected signal, calculate k1, k2, b1, and b2 by selecting the suspected signal values and reference signal values corresponding to four time nodes, and select the suspected signal whose accuracy and offset between the suspected signal and the reference signal meet the preset values. If not satisfied, end the process and then perform this process for the next suspected signal. If satisfied, calculate the cosine similarity for this suspected signal. If the cosine similarity meets the preset similarity, determine the message number of the message where this suspected signal is located and the starting bit number of this suspected signal, and thus the specific position of this suspected signal can be determined. And determine that this suspected signal is the target signal in the bus message data, otherwise end the process and then perform this process for the next suspected signal.

[0077] The above is 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, as Figure 3 shown.

[0078] Figure 3 This is a schematic diagram of a CAN signal parsing device based on cosine similarity provided in this specification, specifically including: An acquisition module 300, configured to determine a target signal to be parsed, and acquire bus message data of a vehicle communication bus within a preset time and reference signal data corresponding to the target signal; A first determination module 302, configured to determine, according to the bus message data and the reference signal data, references signals and respective bus messages corresponding to multiple time nodes within the preset time; A second determination module 304, configured to, for each time node, determine respective bus messages corresponding to the time node as a bus message sequence corresponding to the time node, and arrange the reference signals in chronological order of the multiple time nodes to determine a reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals; A third determination module 306, configured to, for each bus message sequence, determine respective bus messages in the bus message sequence; A fourth determination module 308, configured to, for each bus message in the bus message sequence, determine a signal that conforms to a bit length corresponding to the target signal from the bus message as a suspected signal; A fifth determination module 310, configured to determine, according to the bus message sequences, values respectively corresponding to the suspected signals at the multiple time nodes as respective suspected signal values; and determine respective reference signal values according to the reference signal sequence; A judgment module 312, configured to judge whether precision and offset between the suspected signals and the reference signals meet a preset value according to the respective suspected signal values and the respective reference signal values; if so, calculate a similarity between the suspected signals and the reference signals according to the respective suspected signal values and the respective reference signal values, and determine a target signal in the bus message data according to the similarity; if not, continue to judge whether precision and offset between the next suspected signal and the reference signal meet the preset value.

[0079] Optionally, the fifth determination module 310 is further configured to, for each reference signal in the reference signal sequence, determine an original signal value corresponding to the reference signal according to the reference signal data, determine a physical value of the reference signal according to the original signal value, and use the physical value as the reference signal value of the reference signal.

[0080] Optionally, the determination module 312 is further configured to determine four time nodes from the multiple time nodes, determine the suspected signal values corresponding to the four time nodes respectively from the respective suspected signal values, and determine the reference signal values corresponding to the four time nodes respectively from the respective reference signal values, calculate a first accuracy value, a second accuracy value, a first offset value, and a second offset value according to the suspected signal values corresponding to the four time nodes and the reference signal values corresponding to the four time nodes, calculate the absolute value of the difference between the first accuracy value and the second accuracy value as a first absolute value, and calculate the absolute value of the difference between the first offset value and the second offset value as a second absolute value, and determine whether both the first absolute value and the second absolute value are less than a preset value.

[0081] Optionally, the determination module 312 is further configured to calculate the first accuracy value, the second accuracy value, the first offset value, and the second offset value respectively using the following calculation expressions:

[0082]

[0083]

[0084]

[0085] Wherein, are the suspected signal values corresponding to the four time nodes respectively, are the reference signal values corresponding to the four time nodes respectively, is the first accuracy value, is the second accuracy value, is the first offset value, is the second offset value.

[0086] Optionally, the determination module 312 is further configured to determine a suspected signal value sequence according to the respective suspected signal values in the chronological order of the multiple time nodes, calculate a cosine similarity according to 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.

[0087] Optionally, the determination module 312 is further configured to calculate the cosine similarity using the following calculation expression:

[0088]

[0089]

[0090] Wherein, S is the cosine similarity, is the sequence of suspected signal values, is each suspected signal value, is the sequence of reference signal values, is each reference signal value.

[0091] Optionally, the determination module 312 is further configured to determine the message number and the starting bit number of the bus message corresponding to the suspected signal when the cosine similarity meets a preset similarity, and determine that the suspected signal is the target signal in the bus message data.

[0092] This specification also provides a computer-readable storage medium, which stores a computer program that can be used to execute the above Figure 1 provided method for CAN signal parsing based on cosine similarity.

[0093] This specification also provides Figure 4 a schematic structural diagram of the electronic device shown in. As Figure 4 shown, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above Figure 1 described method for CAN signal parsing based on cosine similarity.

[0094] Of course, in addition to the software implementation, this specification does not exclude other implementation methods, such as logical devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, and can also be hardware or a logical device.

[0095] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements to method flows). However, with the development of technology, many method flow improvements today can be regarded as direct improvements to hardware circuit structures. Almost all designers obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented using a hardware entity module. 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 on their own to "integrate" a digital system onto a single PLD, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compilers used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL). There is not just one type of HDL, but many, 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, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones currently are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply performing a little logical programming on the method flow using the above-mentioned several hardware description languages and programming it into an integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.

[0096] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, and embedded microcontrollers to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or structures within the hardware component.

[0097] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0098] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0099] Those skilled in the art should understand that the embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.

[0100] This specification is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the specification. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.

[0101] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.

[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.

[0103] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.

[0104] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.

[0105] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media and can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, 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, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media, such as modulated data signals and carrier waves.

[0106] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0107] Those skilled in the art should understand that the embodiments of this specification can be provided as a method, system or computer program product. Therefore, this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this specification can take the form of a computer program product implemented 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.

[0108] This specification can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0109] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment.

[0110] The above description is only for the embodiments of this specification and is not intended to limit this specification. For those skilled in the art, various modifications and changes can be made to this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included within the scope of the claims of this specification.

Claims

1. A method for parsing CAN signals based on cosine similarity, characterized in that Including: Determine the target signal to be parsed, and obtain the bus message data of the vehicle communication bus within a preset time and the reference signal data corresponding to the target signal; According to the bus message data and the reference signal data, determine the reference signals and each bus message corresponding to multiple time nodes within the preset time; For each time node, determine each bus message corresponding to this time node as the bus message sequence corresponding to this time node, and arrange the reference signals in the chronological order of the multiple time nodes to determine the reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals; For each bus message sequence, determine each bus message in this bus message sequence; For each bus message in this bus message sequence, determine the signal that meets the bit length corresponding to the target signal from this bus message as the suspected signal; According to each bus message sequence, determine the values corresponding to the suspected signals at the multiple time nodes respectively as each suspected signal value; and according to the reference signal sequence, determine each reference signal value; According to each suspected signal value and the reference signal value, judge whether the precision and offset between the suspected signal and the reference signal meet the preset value; If so, calculate the similarity between the suspected signal and the reference signal according to each suspected signal value and each reference signal value, and determine the target signal in the bus message data according to the similarity; If not, continue to judge whether the precision and offset between the next suspected signal and the reference signal meet the preset value.

2. The CAN signal parsing method based on cosine similarity according to claim 1, characterized in that Determine each reference signal value according to the reference signal sequence, specifically including: For each reference signal in the reference signal sequence, determine the original signal value corresponding to this reference signal according to the reference signal data; Determine the physical value of this reference signal according to the original signal value; Take the physical value as the reference signal value of this reference signal.

3. The CAN signal parsing method based on cosine similarity according to claim 1, wherein, Judge whether the precision and offset between the suspected signal and the reference signal meet the preset value according to each suspected signal value and the reference signal value, specifically including: Determine four time nodes from the multiple time nodes; According to the four time nodes, determine the suspected signal values corresponding to the four time nodes respectively from each suspected signal value; and determine the reference signal values corresponding to the four time nodes respectively from each reference signal value; Calculate the first precision value, the second precision value, the first offset value and the second offset value according to the suspected signal values corresponding to the four time nodes respectively and the reference signal values corresponding to the four time nodes respectively; 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; Judge whether both the first absolute value and the second absolute value are less than the preset value.

4. The CAN signal parsing method based on cosine similarity according to claim 3, wherein The calculation expressions of the first precision value, the second precision value, the first offset value and the second offset value are respectively: Among them, are the suspected signal values corresponding to the four time nodes respectively, are the reference signal values corresponding to the four time nodes respectively, is the first precision value, is the second precision value, is the first offset value, is the second offset value.

5. The CAN signal parsing method based on cosine similarity according to claim 3, characterized in that, Calculate the similarity between the suspected signal and the reference signal according to the respective suspected signal values and the respective reference signal values, specifically including: Determine a suspected signal value sequence according to the respective suspected signal values and a reference signal value sequence according to the respective reference signal values in the chronological order of the multiple time nodes; Calculate the cosine similarity according to the suspected signal value sequence and the reference signal value sequence; Use the calculated cosine similarity as the similarity between the suspected signal and the reference signal.

6. The CAN signal parsing method based on cosine similarity according to claim 5, wherein The calculation expression of the cosine similarity is: where S is the cosine similarity, is the sequence of suspected signal values, is each suspected signal value, is the sequence of reference signal values, is each reference signal value.

7. The CAN signal parsing method based on cosine similarity according to claim 5, characterized in that, Determine the target signal in the bus message data according to the similarity, specifically including: When the cosine similarity meets the preset similarity, determine the message number of the bus message corresponding to the suspected signal and the starting bit number of the suspected signal, and determine that the suspected signal is the target signal in the bus message data.

8. A CAN signal parsing device based on cosine similarity, characterized in that Including: An acquisition module, configured to determine a target signal to be parsed, and acquire bus message data of a vehicle communication bus within a preset time and reference signal data corresponding to the target signal; A first determination module, configured to determine the reference signal and each bus message corresponding to multiple time nodes within the preset time according to the bus message data and the reference signal data; A second determination module, configured to, for each time node, determine each bus message corresponding to the time node as a bus message sequence corresponding to the time node, and arrange the reference signals in the chronological order of the multiple time nodes to determine a reference signal sequence, where the number of the bus message sequences is the same as the number of the reference signals; A third determination module, configured to, for each bus message sequence, determine each bus message in the bus message sequence; A fourth determination module, configured to, for each bus message in the bus message sequence, determine a signal that meets the bit length corresponding to the target signal in the bus message as a suspected signal; A fifth determination module, configured to determine the values respectively corresponding to the suspected signals at the multiple time nodes according to each bus message sequence as respective suspected signal values; and determine each reference signal value according to the reference signal sequence; A judgment module, configured to judge whether the accuracy and offset between the suspected signal and the reference signal meet a preset value according to the respective suspected signal values and the respective reference signal values; if so, calculate the similarity between the suspected signal and the reference signal according to the respective suspected signal values and the respective reference signal values, and determine the target signal in the bus message data according to the similarity; if not, continue to judge whether the accuracy and offset between the next suspected signal and the reference signal meet the preset value.

9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the above claims 1 to 7 is implemented.

10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the method described in any one of the above claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Fuzzy test method for vehicle-mounted CAN bus, terminal and computer equipment

    CN113872985A

  • Network security protection method and device based on controller area network bus

    CN116346443A

  • Vehicle-mounted controller fault analysis system and method

    CN117341606A

  • Automobile CAN bus message analysis method based on similarity matching

    CN118353982A

  • Image recognition and analysis method and system for CAN bus data in automobile field

    CN119832395A