CN115941523B - CAN message period consistency analysis method and device based on python - Google Patents

CAN message period consistency analysis method and device based on python Download PDF

Info

Publication number
CN115941523B
CN115941523B CN202211297185.8A CN202211297185A CN115941523B CN 115941523 B CN115941523 B CN 115941523B CN 202211297185 A CN202211297185 A CN 202211297185A CN 115941523 B CN115941523 B CN 115941523B
Authority
CN
China
Prior art keywords
message
period
analysis result
source
actual
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202211297185.8A
Other languages
Chinese (zh)
Other versions
CN115941523A (en
Inventor
古来
黄亮
严钦山
苏琳珂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Deep Blue Automotive Technology Co ltd
Original Assignee
Deep Blue Automotive Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Deep Blue Automotive Technology Co ltd filed Critical Deep Blue Automotive Technology Co ltd
Priority to CN202211297185.8A priority Critical patent/CN115941523B/en
Publication of CN115941523A publication Critical patent/CN115941523A/en
Application granted granted Critical
Publication of CN115941523B publication Critical patent/CN115941523B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The invention relates to a python-based CAN message period consistency analysis method, which comprises the following steps: and respectively analyzing the whole CAN communication protocol file and the whole CAN message data file acquired in a certain time period by using a python tool. And carrying out deviation analysis based on the actual period and the design period of the messages obtained by analysis, judging which messages have abnormal periods, and obtaining an analysis result of inconsistent periods of the messages.

Description

CAN message period consistency analysis method and device based on python
Technical Field
The invention relates to the field of CAN message processing, in particular to a python-based CAN message period consistency analysis method and device.
Background
With the continuous promotion of social development and people's living conditions, automobiles become one of indispensable travel tools. The requirements of users on the safety, comfort and entertainment of the automobile are improved, so that the functions of the automobile are increased, signals of functional interaction of each module in the CAN network are increased, and a certain challenge is brought to the load of the CAN network.
When a large deviation exists in the sending or forwarding period of the CAN message, real-time interaction delay and response deviation among CAN nodes CAN be caused, the use and normal running of vehicle functions are affected, and even safety accidents are caused. In the development test stage, communication test is carried out on the network, so that the problems of CAN message sending or forwarding delay, frame loss and the like are found in advance, and the problems are very necessary. Whether the actual period of sending or forwarding the CAN message is consistent with the design period is analyzed, and the key point of the message period consistency test and analysis is that. How to analyze the test result of the consistency of the message period in a large amount of message data rapidly and accurately is a very necessary subject to be explored.
The main flow of the test for the period consistency of the CAN message at the present stage is to collect CAN message data for a certain time first and then manually analyze the collected data. The manual analysis is mainly to judge whether the message sending or forwarding period is consistent with the design period according to defined message period delay or frame loss rules. However, the manual judgment mode is affected by human factors, and has low working efficiency, so that the problems of low accuracy of analysis results, waste of human resources and the like are caused. The CAN message data acquisition and analysis mode at the present stage is strongly related to the tool, so that the flexibility of data acquisition is limited.
CN108306785A provides a CAN message period detection method, which calculates the time interval between the current CAN message information and the previous CAN message information with the same CAN message ID, and calculates the average value of a plurality of calculated time intervals to output the CAN message period corresponding to the CAN message ID. Needless to say, the technical solution disclosed in the above patent document is an advantageous attempt in the technical field.
Disclosure of Invention
The invention provides a python-based CAN message period consistency analysis method and device, which CAN improve analysis efficiency and accuracy of CAN message period consistency.
The technical scheme of the invention is as follows:
the invention provides a python-based CAN message period consistency analysis method, which comprises the following steps:
analyzing the whole CAN communication protocol file and the whole CAN message data file acquired in a preset time period by using a python tool according to the logic corresponding relation between each CAN channel and the whole CAN network segment defined during the whole CAN message acquisition;
extracting the message ID, the design period and the sending source of each CAN message according to the whole vehicle CAN communication protocol file to form a design message period set and store the design message period set in a dictionary;
Extracting the message ID, the actual period and the sending source of each CAN message according to the whole vehicle CAN message data file to form an actual message period set and store the actual message period set in a dictionary;
traversing the actual message period set according to the message design period, and judging the abnormality of the actual message period of each message;
Analyzing a target message with abnormal message period and a non-gateway sending source to obtain a first type consistency analysis result only about the target message; performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof;
aiming at the target message with abnormal message period, generating an analysis result set with abnormal message period according to the first type of consistency analysis result and the second type of consistency analysis result to form an analysis report.
Preferably, the step of performing actual message period abnormality judgment on each message by traversing the actual message period set according to the message design period includes:
Traversing the actual message period set to extract the actual message period maximum value and the actual message period minimum value of each message, and traversing the designed message period set to extract the designed message period value of the message;
for each message:
If the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the maximum value of the designed message period value and the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the minimum value of the designed message period value, determining that the message period of the message is stable;
if the second ratio of the designed message period value is less than the third ratio of the actual message period maximum value less than the designed message period value or the first ratio of the actual message period minimum value less than the designed message period value, determining that the message period of the message is unstable;
If the maximum value of the actual message period is more than or equal to the third ratio of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
Preferably, the step of analyzing the target message with abnormal message period and non-gateway sending source to obtain the first type consistency analysis result only about the target message includes:
If the message period of the target message is unstable, a consistency analysis result of the message period instability of a controller which sends out the source message is obtained;
If the message period of the target message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of frame loss of a controller which sends out the source message is obtained;
And obtaining a first type of consistency analysis result only related to the target message according to the consistency analysis result.
Preferably, the step of performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof includes:
According to the ID of the message, determining that the message sending source is a source message corresponding to the target message of the gateway;
performing abnormal judgment on the actual message period of the source message;
if the message period of the source message is unstable, a consistency analysis result of the message period instability of a controller which sends the source message is obtained;
if the message period of the source message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of the frame loss is obtained, wherein the message period frame loss number comprises a controller sending the source message;
and obtaining a second type of consistency analysis result about the source message and the target message based on the consistency analysis result of the source message and the consistency analysis result of the target message.
Preferably, the method further comprises:
And aiming at each message with normal message period, respectively obtaining a consistent analysis result of the message period stability comprising each message, and generating an analysis result set with consistent message period according to the consistent analysis result of each message.
Preferably, the first type of consistency analysis result further comprises: the method comprises the steps of transmitting a target message on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a designed message period value of a whole vehicle CAN network;
The second type of consistency analysis result further comprises: the target message and the source message are respectively transmitted on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a design message period value of the whole vehicle CAN network.
The invention also provides a CAN message period consistency analysis device based on python, which comprises:
The data acquisition module is used for analyzing the whole CAN communication protocol file and the whole CAN message data file acquired in a preset time period by using the python tool according to the logic corresponding relation between each CAN channel defined during the whole CAN message acquisition and the whole CAN network segment;
The design message period set forming module is used for extracting the message ID, the design period and the sending source of each CAN message according to the whole vehicle CAN communication protocol file to form a design message period set which is stored in the dictionary;
the actual message period set forming module is used for extracting the message ID, the actual period and the sending source of each CAN message according to the whole vehicle CAN message data file to form an actual message period set which is stored in the dictionary;
The message anomaly judging module is used for traversing the actual message period set according to the message design period and judging the actual message period anomaly of each message;
The target message consistency analysis result generation module is used for analyzing the target message which is abnormal in message period and the sending source of which is a non-gateway, so as to obtain a first type consistency analysis result only related to the target message; performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof;
The message period abnormality analysis result set generation module is used for generating an analysis result set of the message period abnormality according to the first type of consistency analysis result and the second type of consistency analysis result aiming at the target message with the message period abnormality to form an analysis report.
Preferably, the message anomaly judging module includes:
the message period value extraction unit is used for extracting an actual message period maximum value and an actual message period minimum value of the messages from the actual message period set one by one for each message, and extracting a design message period value of the messages from the design message period set one by one for each message;
The message period abnormality judging unit is used for judging the message period abnormality of each message:
If the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the maximum value of the designed message period value and the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the minimum value of the designed message period value, determining that the message period of the message is stable;
if the second ratio of the designed message period value is less than the third ratio of the actual message period maximum value less than the designed message period value or the first ratio of the actual message period minimum value less than the designed message period value, determining that the message period of the message is unstable;
If the maximum value of the actual message period is more than or equal to the third ratio of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
Preferably, the target message consistency analysis result generation module includes:
the first analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of a controller which sends a source message if the message period of the target message is unstable;
The second analysis result generation unit is used for obtaining a consistency analysis result of the frame loss number of the message period and the occurrence number of the frame loss of the controller which sends the source message if the frame loss of the message period of the target message occurs;
and the first type consistency analysis result generation unit is used for obtaining a first type consistency analysis result only related to the target message according to the consistency analysis result.
Preferably, the target message consistency analysis result generation module further includes:
the source message identification unit is used for determining that the message sending source is the source message corresponding to the target message of the gateway according to the ID of the message;
The source message abnormality judging unit is used for judging abnormality of the actual message period of the source message;
The third analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of the controller which sends the source message if the message period of the source message is unstable;
a fourth analysis result generating unit, configured to obtain a consistency analysis result of the number of packet periods and the number of occurrences of the frame loss, where the consistency analysis result includes a controller sending the source packet, if the packet periods of the source packet are lost;
The second type consistency analysis result generation unit is used for obtaining second type consistency analysis results about the source message and the target message based on the consistency analysis results of the source message and the consistency analysis results of the target message.
The beneficial effects of the invention are as follows:
And the python tool is used for replacing human analysis, so that the accuracy and the efficiency of message data analysis are improved. Such as: manually analyzing the data for 1 hour, wherein the time is 2 hours; using this method for analysis, it took only 2 minutes to complete the analysis and output an analysis result report. Specifically: the method CAN be used for rapidly analyzing the consistency of the message period aiming at all blf files transmitted by the whole CAN network in a period of time; different CAN communication protocols exist at different stages or vehicle types, and the method is suitable for analyzing and obtaining corresponding message period consistency results according to the CAN communication protocols of different whole vehicles. And the CAN message data acquisition CAN be carried out by using an acquisition tool capable of generating blf file formats, so that the message period consistency analysis CAN be carried out. The invention has more flexibility for the use of CAN message data acquisition tools. The invention analyzes the frame loss in detail, and gives out the results of several times of frame loss, thereby facilitating further load analysis.
Drawings
FIG. 1 is a flow chart of a python-based CAN message cycle consistency analysis method according to an embodiment of the invention;
FIG. 2 is a detailed flowchart of a method for analyzing the period consistency of a CAN message based on python according to an embodiment of the invention;
FIG. 3 is a specification of the input object of step S1 in FIG. 2;
FIG. 4 is a detailed flowchart of the step S2 of FIG. 2 of generating a "design message period set";
FIG. 5 is a detailed flowchart of the steps S3 and S4 in FIG. 2 for generating the "actual message period set";
FIG. 6 is a detailed flowchart of step S5 in FIG. 2 for generating "stable set of message periods", "unstable set of message periods" and "set of message periods with dropped frames";
FIG. 7 is a detailed flowchart of step S6 in FIG. 2 for generating a "analysis result set for message cycle consistency";
FIG. 8 is a diagram showing analysis result report of the periodic consistency of CAN messages based on python;
fig. 9 is a flowchart of a python-based CAN packet cycle consistency analysis apparatus according to an embodiment of the present invention.
Detailed Description
Referring to fig. 1 and fig. 2, an embodiment of the present invention provides a method for analyzing the periodic consistency of a CAN message based on python, including:
Step S101 (corresponding to step S1 in fig. 2), analyzing the whole CAN communication protocol file and the whole CAN message data file acquired in the predetermined time period by using the python tool according to the logical correspondence between each CAN channel and the whole CAN network segment defined during the whole CAN message acquisition.
The message data acquisition tool CAN be a conventional tool, and only the corresponding relation between each CAN channel and each CAN network segment of the vehicle is defined in advance. As shown in fig. 3, CAN channel 0 of the tool corresponds to the BCAN segment of the vehicle, CAN channel 1 corresponds to the ICAN segment of the vehicle, CAN channel 3 of the tool corresponds to the PTCAN segment of the vehicle, CAN channel 4 corresponds to the ADASACAN segment of the vehicle, and CAN channel 5 of the tool corresponds to the ADASBCAN segment. Thus, the channel 1 of the tool collects all CAN message data files on the ICAN network segment of the vehicle, and other channels collect CAN message data files transmitted on the corresponding network segment. In this embodiment, the types of CAN message data files are blf files.
In this embodiment, the content input into the python tool is three input contents, specifically: one or more CAN message data files (blf files) transmitted in a certain time on the whole CAN network, the logical corresponding relation between a CAN channel defined during CAN data acquisition and a whole CAN network segment, and the communication protocol file of the whole CAN network.
Referring to fig. 3, step S101 is to analyze the required inputs. The invention supports a plurality of blf files as CAN message data sources, but the corresponding relation of CAN logic channels is consistent, otherwise, the analysis of the CAN message cycle consistency is needed to be carried out for a plurality of times.
Step S102 (corresponding to step S2 in FIG. 2), extracting the message ID, the design period and the sending source of each CAN message according to the whole CAN communication protocol file, forming a design message period set and storing the design message period set in a dictionary.
Referring to fig. 4, step S2 of fig. 2 is one of the preconditions for performing the message cycle consistency analysis. Information such as a periodic message can_id, a design message period_time and a message sending source sender is acquired from a communication protocol file of the whole vehicle CAN network and stored in a dictionary ("design message period set") in a python tool, so that the follow-up analysis and use are facilitated, for example: { "PTCAN _0x288" { "sender": "GW", "cycle_time": "44", "can_id": "0x288" }, … … }, i.e. the designed message with ID 0x288 sent by the gateway onto PTCAN network segment has a period of 44ms.
Step S103 (corresponding to step S3 and step S4 in FIG. 2), extracting the message ID, the actual period and the sending source of each CAN message according to the whole CAN message data file to form an actual message period set and storing the actual message period set in a dictionary.
Referring to fig. 5, steps S3 and S4 of fig. 2 are to process the collected blf files and obtain the time difference of each message, i.e. the actual sending or forwarding period of the message. The processing of blf files mainly uses the can library of python to read blf files, processes the read message data and stores the processed message data into a dictionary, such as: { "PTCAN _0x288": [ Δt1, Δt2, … … ], "PTCAN _0x287": [ Δt1, Δt2, … …, … … }. That is, the period of the packet with ID 0x288 on PTCAN segments is Δt1, Δt2, … …, and the period of the packet with ID 0x287 on PTCAN segments is Δt1, Δt2, and … ….
Step S104 (corresponding to step S5 in FIG. 2), traversing the actual message period set according to the message design period, and performing actual message period abnormality judgment on each message.
According to the message design period, traversing the actual message period set, and performing actual message period abnormality judgment on each message, wherein the step S104 comprises the following steps:
Traversing the actual message period set to extract the actual message period maximum value and the actual message period minimum value of each message, and traversing the designed message period set to extract the designed message period value of the message;
for each message:
If the first ratio (90%) of the designed message period value is less than or equal to the first ratio (110%) of the actual message period value is less than or equal to the second ratio (110%) of the designed message period value, and the first ratio of the designed message period value is less than or equal to the first ratio (110%) of the actual message period value is less than or equal to the second ratio (110%) of the designed message period value, determining that the message period of the message is stable;
if the second ratio (110%) of the designed message period value is less than the third ratio (200%) of the actual message period maximum value less than the designed message period value or the actual message period minimum value is less than the first ratio (90%) of the designed message period value, determining that the message period of the message is unstable;
if the maximum value of the actual message period is more than or equal to the third ratio (200%) of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
Specifically, referring to fig. 6, in this embodiment, according to a defined rule for determining consistency of message periods, an "actual message period set" is classified into a "stable message period set", a "unstable message period set" and a "frame loss period set", which are collectively referred to as an "actual message period analysis result set". The design message period is obtained from the "design message period set" in step S2. The classification criteria for these three classes of sets are as follows:
1. If the actual period of the message is within 10% of the deviation range of the design period (cycle_time) (i.e. 90% -110% of the design period), classifying the message into a "stable set of message periods", i.e. the actual period is normally sent, for example: [ "PTCAN _0x288", … … ];
2. If the maximum value (max (Δt)) of the actual period of the message is greater than 110% of the design period (cycle_time) and less than 200% of the design period or the minimum value (min (Δt)) of the actual period of the message is less than 90% of the design period (cycle_time), classifying the message into a "set of unstable periods of the message", that is, if there is an unstable period, for example: [ "PTCAN _0x287", … … ];
3. If the maximum value of the actual period of the message (i.e. max (Δt)) is greater than or equal to 200% of the design period (cycle_time), the number of dropped frames and the number of times of dropped frames in the actual period of the message need to be calculated in detail, and the message is classified into a "set of dropped frames in the message period", i.e. the condition that dropped frames exist in the actual period. Such as: { "PTCAN _0x280": {1:1, 2:5}, … … }, i.e.: PTCAN _0x280 occur 1 time when 1 frame is lost, 5 times when 2 frames are lost, and the like.
Step S105, analyzing a target message with abnormal message period and a non-gateway sending source to obtain a first type consistency analysis result only about the target message; and tracing analysis is carried out on the target message with abnormal message period and the sending source being the gateway, so as to obtain a second type consistency analysis result about the target message and the source message thereof.
Step S106, aiming at the target message with abnormal message period, generating an analysis result set with abnormal message period according to the first type of consistency analysis result and the second type of consistency analysis result to form an analysis report.
The step S105 and the step S106 correspond to the step S6 in fig. 2 in common.
In this embodiment, the step S105 of analyzing the target message with abnormal message period and non-gateway sending source to obtain the first type consistency analysis result only about the target message includes:
If the message period of the target message is unstable, a consistency analysis result of the message period instability of a controller which sends out the source message is obtained;
If the message period of the target message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of frame loss of a controller which sends out the source message is obtained;
And obtaining a first type of consistency analysis result only related to the target message according to the consistency analysis result.
The step S105 of performing tracing analysis on the target message with abnormal message period and the sending source being the gateway to obtain a second type consistency analysis result about the target message and the source message thereof includes:
According to the ID of the message, determining that the message sending source is a source message corresponding to the target message of the gateway;
performing abnormal judgment on the actual message period of the source message;
if the message period of the source message is unstable, a consistency analysis result of the message period instability of a controller which sends the source message is obtained;
if the message period of the source message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of the frame loss is obtained, wherein the message period frame loss number comprises a controller sending the source message;
and obtaining a second type of consistency analysis result about the source message and the target message based on the consistency analysis result of the source message and the consistency analysis result of the target message.
As can be seen from fig. 7, in this embodiment, the first type of consistency analysis result further includes: the method comprises the steps of transmitting a target message on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a designed message period value of a whole vehicle CAN network;
The second type of consistency analysis result further comprises: the target message and the source message are respectively transmitted on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a design message period value of the whole vehicle CAN network.
Specifically, referring to fig. 7, tracing is performed on a target message with an abnormal message period, where tracing refers to checking whether the message period of the source message of the target message is abnormal, and outputting a "analysis result set of message period consistency". In this embodiment, the sending nodes (i.e. the message sending sources) of the controller are mainly VCU, TBOX and GW, so that abnormal message cycle information of VCU and TBOX is directly stored in a "message cycle abnormal analysis result set" (i.e. a "first type consistency analysis result" is stored in a "message cycle abnormal analysis result set"), and a message forwarded by GW is traced and then stored in a "message cycle abnormal analysis result set" (i.e. a "second type consistency analysis result" is correspondingly stored in a "message cycle abnormal analysis result set"). The gateway forwards the message tracing, mainly finds the source message according to the "design message period set" output in the step S2, and in the "actual message period analysis result combination" output in the step S5, finds the actual condition of the source message, and finally stores the result into the "analysis result set of message period consistency", for example: the term "periodic instability" is used in the following general terms of [ (about CHCANFD ', `VCU', `0 x1b1', `10', `8.83`, 11.16 ', `periodic instability`, `/' ], [ `BCANs ', `GW', `0 x329', `10', `8` 76, 11.24 ', `periodic instability`, "v", "v", "v' GW ',' 0x1c2',' 10', 8.29, 11.82,' period instability ',' CHCANFD ',' ESP ',' 0x1c2', 9.01, 10.94,' period stability ',' … … ].
Referring to fig. 2 again, after the "analysis result set with abnormal message cycle" in step S106 is obtained, the EXCEL table shown in fig. 8 is obtained, and the analysis result set is output in the form of a report and displayed to the demanding personnel. Referring to fig. 8, the "analysis result set of the message cycle consistency" is converted into a test report for checking convenience, and the report displays the analysis result of the message cycle consistency in the form of Excel. The analysis results are mainly divided into three parts: the header, destination message and source message are detailed in fig. 8.
As shown in fig. 8, the data shown in this embodiment includes a packet period statistical result of the target packet and the source packet, a CAN network segment transmitted on the whole-vehicle CAN network, a packet transmission source, a packet ID, an actual packet period maximum value, an actual packet period minimum value, and a design packet period value.
Step S107, for each message with normal message period, respectively obtaining a consistent analysis result with stable message period containing each message, and generating a consistent analysis result set of the message period according to the consistent analysis result of each message.
The analysis process and the analysis result set principle of the obtained messages with the same message period are consistent with the analysis process and the generation process of the messages with abnormal message periods, which are not repeated in this embodiment.
As shown in fig. 9, the present invention further provides a python-based CAN packet period consistency analysis device, which includes:
the data acquisition module 201 is configured to analyze, using a python tool, a whole vehicle CAN communication protocol file and a whole vehicle CAN message data file acquired in a predetermined period of time according to a logical correspondence between each CAN channel defined during whole vehicle CAN message acquisition and a whole vehicle CAN network segment;
The design message period set forming module 202 is configured to extract a message ID, a design period and a transmission source of each CAN message according to the whole vehicle CAN communication protocol file, form a design message period set, and store the design message period set in a dictionary;
The actual message period set forming module 203 is configured to extract a message ID, an actual period and a sending source of each CAN message according to the CAN message data file of the whole vehicle, form an actual message period set, and store the actual message period set in a dictionary;
The message anomaly judging module 204 is configured to traverse the actual message period set according to the message design period, and perform actual message period anomaly judgment on each message;
The target message consistency analysis result generation module 205 is configured to analyze a target message with a non-gateway sending source and an abnormal message cycle, so as to obtain a first type of consistency analysis result only related to the target message; performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof;
The message cycle anomaly analysis result set generating module 206 is configured to generate, for a target message with a message cycle anomaly, an analysis result set with a message cycle anomaly according to the first type of consistency analysis result and the second type of consistency analysis result, and form an analysis report.
Preferably, the message anomaly judging module includes:
the message period value extraction unit is used for extracting an actual message period maximum value and an actual message period minimum value of the messages from the actual message period set one by one for each message, and extracting a design message period value of the messages from the design message period set one by one for each message;
The message period abnormality judging unit is used for judging the message period abnormality of each message:
If the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the maximum value of the designed message period value and the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the minimum value of the designed message period value, determining that the message period of the message is stable;
if the second ratio of the designed message period value is less than the third ratio of the actual message period maximum value less than the designed message period value or the first ratio of the actual message period minimum value less than the designed message period value, determining that the message period of the message is unstable;
If the maximum value of the actual message period is more than or equal to the third ratio of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
Preferably, the target message consistency analysis result generation module includes:
the first analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of a controller which sends a source message if the message period of the target message is unstable;
The second analysis result generation unit is used for obtaining a consistency analysis result of the frame loss number of the message period and the occurrence number of the frame loss of the controller which sends the source message if the frame loss of the message period of the target message occurs;
and the first type consistency analysis result generation unit is used for obtaining a first type consistency analysis result only related to the target message according to the consistency analysis result.
Preferably, the target message consistency analysis result generation module further includes:
the source message identification unit is used for determining that the message sending source is the source message corresponding to the target message of the gateway according to the ID of the message;
The source message abnormality judging unit is used for judging abnormality of the actual message period of the source message;
The third analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of the controller which sends the source message if the message period of the source message is unstable;
a fourth analysis result generating unit, configured to obtain a consistency analysis result of the number of packet periods and the number of occurrences of the frame loss, where the consistency analysis result includes a controller sending the source packet, if the packet periods of the source packet are lost;
The second type consistency analysis result generation unit is used for obtaining second type consistency analysis results about the source message and the target message based on the consistency analysis results of the source message and the consistency analysis results of the target message.
While the invention has been described in detail in connection with only a limited number of embodiments, it should be apparent that the invention is not limited to the precise embodiments set forth herein, but is well suited to the particular use contemplated. Further modifications, additions and substitutions will readily occur to those skilled in the art, and the invention is therefore not to be considered limited to the foregoing description without departing from the general concept as defined in the accompanying claims and the equivalents thereof.

Claims (6)

1. The python-based CAN message period consistency analysis method is characterized by comprising the following steps of:
Analyzing the whole CAN communication protocol file and the whole CAN message data file acquired by the message data acquisition tool in a preset time period by using a python tool according to the logic corresponding relation between each CAN channel and the whole CAN network segment defined during the whole CAN message acquisition; different CAN channels of the message data acquisition tool correspondingly acquire CAN message data on different CAN network segments;
extracting the message ID, the design period and the sending source of each CAN message according to the whole vehicle CAN communication protocol file to form a design message period set and store the design message period set in a dictionary;
Extracting the message ID, the actual period and the sending source of each CAN message according to the whole vehicle CAN message data file to form an actual message period set and store the actual message period set in a dictionary;
traversing the actual message period set according to the message design period, and judging the abnormality of the actual message period of each message;
Analyzing a target message with abnormal message period and a non-gateway sending source to obtain a first type consistency analysis result only about the target message; performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof;
Aiming at a target message with abnormal message period, generating an analysis result set with abnormal message period according to a first type of consistency analysis result and a second type of consistency analysis result to form an analysis report;
The method comprises the steps of analyzing a target message with abnormal message period and a non-gateway sending source, and obtaining a first type consistency analysis result only about the target message, wherein the first type consistency analysis result comprises the following steps:
If the message period of the target message is unstable, a consistency analysis result of the message period instability of a controller which sends out the source message is obtained;
If the message period of the target message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of frame loss of a controller which sends out the source message is obtained;
obtaining a first type consistency analysis result only about the target message according to the consistency analysis result;
the step of tracing analysis is carried out on the target message with abnormal message period and gateway as the sending source, and the second type consistency analysis result about the target message and the source message thereof is obtained comprises the following steps:
According to the ID of the message, determining that the message sending source is a source message corresponding to the target message of the gateway;
performing abnormal judgment on the actual message period of the source message;
if the message period of the source message is unstable, a consistency analysis result of the message period instability of a controller which sends the source message is obtained;
if the message period of the source message loses frames, a consistency analysis result of the message period frame loss number and the occurrence number of the frame loss is obtained, wherein the message period frame loss number comprises a controller sending the source message;
and obtaining a second type of consistency analysis result about the source message and the target message based on the consistency analysis result of the source message and the consistency analysis result of the target message.
2. The method for analyzing the consistency of the periods of the CAN messages based on python as set forth in claim 1, wherein the step of traversing the actual message period set according to the design period of the messages and judging the abnormality of the actual message period of each message comprises the steps of:
Traversing the actual message period set to extract the actual message period maximum value and the actual message period minimum value of each message, and traversing the designed message period set to extract the designed message period value of the message;
for each message:
If the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the maximum value of the designed message period value and the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the minimum value of the designed message period value, determining that the message period of the message is stable;
if the second ratio of the designed message period value is less than the third ratio of the actual message period maximum value less than the designed message period value or the first ratio of the actual message period minimum value less than the designed message period value, determining that the message period of the message is unstable;
If the maximum value of the actual message period is more than or equal to the third ratio of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
3. The python-based CAN message cycle consistency analysis method of claim 2, further comprising:
And aiming at each message with normal message period, respectively obtaining a consistent analysis result of the message period stability comprising each message, and generating an analysis result set with consistent message period according to the consistent analysis result of each message.
4. The method for analyzing the periodic consistency of the CAN messages based on python as set forth in claim 1, wherein the first type of consistency analysis result further comprises: the method comprises the steps of transmitting a target message on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a designed message period value of a whole vehicle CAN network;
The second type of consistency analysis result further comprises: the target message and the source message are respectively transmitted on a CAN network segment, a message transmitting source, a message ID, an actual message period maximum value, an actual message period minimum value and a design message period value of the whole vehicle CAN network.
5. A python-based CAN message period consistency analysis device, comprising:
The data acquisition module is used for analyzing the whole CAN communication protocol file and the whole CAN message data file acquired by the message data acquisition tool in a preset time period by using the python tool according to the logic corresponding relation between each CAN channel defined during the whole CAN message acquisition and the whole CAN network segment; different CAN channels of the message data acquisition tool correspondingly acquire CAN message data on different CAN network segments;
The design message period set forming module is used for extracting the message ID, the design period and the sending source of each CAN message according to the whole vehicle CAN communication protocol file to form a design message period set which is stored in the dictionary;
the actual message period set forming module is used for extracting the message ID, the actual period and the sending source of each CAN message according to the whole vehicle CAN message data file to form an actual message period set which is stored in the dictionary;
The message anomaly judging module is used for traversing the actual message period set according to the message design period and judging the actual message period anomaly of each message;
The target message consistency analysis result generation module is used for analyzing the target message which is abnormal in message period and the sending source of which is a non-gateway, so as to obtain a first type consistency analysis result only related to the target message; performing tracing analysis on a target message with abnormal message period and a gateway as a sending source to obtain a second type consistency analysis result about the target message and a source message thereof;
The message period abnormality analysis result set generation module is used for generating an analysis result set of the message period abnormality according to the first type of consistency analysis result and the second type of consistency analysis result aiming at the target message with the message period abnormality to form an analysis report;
The target message consistency analysis result generation module comprises:
the first analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of a controller which sends a source message if the message period of the target message is unstable;
The second analysis result generation unit is used for obtaining a consistency analysis result of the frame loss number of the message period and the occurrence number of the frame loss of the controller which sends the source message if the frame loss of the message period of the target message occurs;
The first type consistency analysis result generation unit is used for obtaining a first type consistency analysis result only related to the target message according to the consistency analysis result;
The target message consistency analysis result generation module further comprises:
the source message identification unit is used for determining that the message sending source is the source message corresponding to the target message of the gateway according to the ID of the message;
The source message abnormality judging unit is used for judging abnormality of the actual message period of the source message;
The third analysis result generation unit is used for obtaining a consistency analysis result of unstable message period of the controller which sends the source message if the message period of the source message is unstable;
a fourth analysis result generating unit, configured to obtain a consistency analysis result of the number of packet periods and the number of occurrences of the frame loss, where the consistency analysis result includes a controller sending the source packet, if the packet periods of the source packet are lost;
The second type consistency analysis result generation unit is used for obtaining second type consistency analysis results about the source message and the target message based on the consistency analysis results of the source message and the consistency analysis results of the target message.
6. The python-based CAN message cycle consistency analysis device of claim 5, wherein the message anomaly determination module comprises:
the message period value extraction unit is used for extracting an actual message period maximum value and an actual message period minimum value of the messages from the actual message period set one by one for each message, and extracting a design message period value of the messages from the design message period set one by one for each message;
The message period abnormality judging unit is used for judging the message period abnormality of each message:
If the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the maximum value of the designed message period value and the first ratio of the designed message period value is less than or equal to the second ratio of the actual message period value which is less than or equal to the minimum value of the designed message period value, determining that the message period of the message is stable;
if the second ratio of the designed message period value is less than the third ratio of the actual message period maximum value less than the designed message period value or the first ratio of the actual message period minimum value less than the designed message period value, determining that the message period of the message is unstable;
If the maximum value of the actual message period is more than or equal to the third ratio of the designed message period value, determining the message period frame loss of the message;
when the message period of the message is unstable or the frame is lost, the message period of the message is considered to be abnormal.
CN202211297185.8A 2022-10-21 2022-10-21 CAN message period consistency analysis method and device based on python Active CN115941523B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211297185.8A CN115941523B (en) 2022-10-21 2022-10-21 CAN message period consistency analysis method and device based on python

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211297185.8A CN115941523B (en) 2022-10-21 2022-10-21 CAN message period consistency analysis method and device based on python

Publications (2)

Publication Number Publication Date
CN115941523A CN115941523A (en) 2023-04-07
CN115941523B true CN115941523B (en) 2024-07-05

Family

ID=86553000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211297185.8A Active CN115941523B (en) 2022-10-21 2022-10-21 CAN message period consistency analysis method and device based on python

Country Status (1)

Country Link
CN (1) CN115941523B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113347058A (en) * 2021-05-20 2021-09-03 江铃汽车股份有限公司 Method and system for testing vehicle CAN network period consistency

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104852825A (en) * 2014-09-15 2015-08-19 北汽福田汽车股份有限公司 Bus communication test method and system
CN106330618A (en) * 2016-09-19 2017-01-11 中国第汽车股份有限公司 Gateway routing automatic test system and test method based on CAN/LIN/MOST hybrid buses
CN106534368B (en) * 2016-12-19 2019-09-10 山东省科学院自动化研究所 A kind of packet sending and receiving method and system of automobile CAN-bus gateway
CN109962858B (en) * 2017-12-25 2023-03-31 宇通客车股份有限公司 CAN bus data transmission method and control system
CN109960177A (en) * 2017-12-25 2019-07-02 郑州宇通客车股份有限公司 CAN bus data processing method and control system
CN109379356A (en) * 2018-10-16 2019-02-22 盛科网络(苏州)有限公司 The method and device of automatic capture cpu attack message
CN112448889B (en) * 2019-08-28 2022-04-19 北京新能源汽车股份有限公司 Gateway controller route configuration method, device, equipment and automobile
CN112543129B (en) * 2020-11-27 2022-06-21 北京经纬恒润科技股份有限公司 Queue depth confirmation method and system and message simulator
CN113691432B (en) * 2021-08-10 2023-06-13 一汽解放汽车有限公司 Method and device for monitoring automobile CAN network message, computer equipment and storage medium
CN115145210B (en) * 2022-09-02 2022-12-09 小米汽车科技有限公司 Method and device for controlling control signal of vehicle, medium and chip

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113347058A (en) * 2021-05-20 2021-09-03 江铃汽车股份有限公司 Method and system for testing vehicle CAN network period consistency

Also Published As

Publication number Publication date
CN115941523A (en) 2023-04-07

Similar Documents

Publication Publication Date Title
CN107656520B (en) CAN bus data analysis method and computer readable storage medium
CN115941523B (en) CAN message period consistency analysis method and device based on python
CN116527718A (en) Data acquisition method and system for industrial Internet of things gateway
CN112559488A (en) Escalator full life cycle data management method and system based on data center station
CN114401203A (en) Automatic driving test method and system based on CAN message analysis operation
CN110545283B (en) Bit-based J1939 variable data acquisition method
CN112256763A (en) Online monitoring system and equipment
CN117596282B (en) Sound console operation control system based on control of Internet of things
CN114697156B (en) Rocket bus data monitoring method, rocket bus data monitoring device, terminal equipment and medium
CN110213297B (en) Data analysis method and device and computer readable storage medium
CN117571354A (en) Organic waste gas capacity real-time monitoring system
CN109062801B (en) Automatic conversion system for software interface
CN117150001A (en) Log analysis method, device, equipment and storage medium
CN114363435B (en) Environment data monitoring and processing method
CN114817671A (en) Log analysis method and system for air conditioner Internet of things
CN115130794A (en) Data processing method, device, equipment and computer readable storage medium
CN110850847B (en) Method and device for monitoring faults of train-mounted equipment
CN117057786B (en) Intelligent operation and maintenance management method, system and storage medium for data center
CN114579550A (en) Data index determination method for vehicle leaving duration of network taxi appointment driver
CN114500387A (en) Mobile application traffic identification method and system based on machine learning
CN114430421A (en) Method and system for automatically generating alarm rules based on function sets of various vehicle types
CN115481880B (en) Major risk source identification method for highway construction
CN111814183B (en) Financial real-time wind control system and method based on network layer message analysis
CN117319440B (en) Data acquisition and analysis method and system based on Internet of vehicles
CN116466940B (en) Coal mine disaster characteristic data fusion processing method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 401133 room 208, 2 house, 39 Yonghe Road, Yu Zui Town, Jiangbei District, Chongqing

Applicant after: Deep Blue Automotive Technology Co.,Ltd.

Address before: 401133 room 208, 2 house, 39 Yonghe Road, Yu Zui Town, Jiangbei District, Chongqing

Applicant before: CHONGQING CHANGAN NEW ENERGY AUTOMOBILE TECHNOLOGY Co.,Ltd.

Country or region before: China

GR01 Patent grant
GR01 Patent grant