Data analysis method and device, medium and vehicle
By optimizing the data analysis process, the timestamp termination position and detection message name are determined for CANFD protocol data, and the data length code position is adaptively determined, which solves the problems of high data analysis complexity and poor compatibility in the prior art, and achieves efficient and accurate data analysis.
Patent Information
- Application Number
- CN202411568925.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-05
AI Technical Summary
When analyzing CANFD protocol data, the prior art faces the problems of high data analysis complexity, inaccurate information extraction and poor compatibility, which is difficult to meet the efficient data transmission needs of modern automotive electronic systems.
By optimizing the data analysis process, the time stamp is terminated for the packet to be parsed whose data state is in the received state, and the message has a name, adaptively determines the position of the data length code, and then accurately reads the target data.
Improve the efficiency and accuracy of data parsing, avoid target data reading errors caused by determining the data length code position in a fixed way, and enhance compatibility with multiple data frame formats.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data communication technology, and in particular to a data analysis method, device, medium and vehicle. Background Art
[0002] With the development of automotive electronic technology, the Controller Area Network (CAN) protocol is widely used for data transmission between various controllers in the car. However, the traditional CAN protocol has limitations in data transmission rate and data load, and it is difficult to meet the efficient data transmission requirements of modern automotive electronic systems. For this reason, the CANFD (CAN with Flexible Data-Rate) protocol came into being, providing a higher data transmission rate and a larger data frame size.
[0003] However, in practical applications, since the data format and transmission mechanism of the CANFD protocol are more complex than those of traditional CAN, the difficulty of parsing protocol data is becoming increasingly higher. Therefore, how to efficiently and accurately parse the CANFD protocol data has become an urgent problem to be solved. Summary of the invention
[0004] The present application provides a data analysis method, device, medium and vehicle, which improve the efficiency of data analysis by optimizing the data analysis process.
[0005] A first aspect of an embodiment of the present application provides a data analysis method, the method comprising: For a message to be parsed whose data state is a receiving state, determining an end position of a timestamp in the message to be parsed; Detecting whether a message name exists in the message to be parsed, and obtaining a first detection result; the first detection result is used to indicate that the message name exists in the message to be parsed, or that the message name does not exist in the message to be parsed; Based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, determine the position of the data length code in the message to be parsed, and read the data length code; Based on the position of the data length code and the data length code, the target data in the message to be parsed is read.
[0006] Optionally, determining a position of a data length code in the message to be parsed based on the end position of the timestamp, the data state, the ID of the message to be parsed, and the first detection result includes: In a case where the first detection result indicates that a message name exists in the message to be parsed, determining the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data state, the length of the ID, the length of the message name, and the first fixed length; When the first detection result indicates that there is no message name in the message to be parsed, the position of the data length code is determined based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data status, the length of the ID and the second fixed length.
[0007] Optionally, the method further comprises: Replace all spaces in the message to be parsed with target characters to obtain a standard message; In the case where the standard message satisfies a first preset format, it is determined that the data state of the message to be parsed is a receiving state; wherein the first preset format includes the target character and a first identifier indicating the receiving state.
[0008] Optionally, determining the end position of the timestamp in the message to be parsed includes: When the standard message satisfies a second preset format, the end position of the timestamp in the message to be parsed is determined based on the position of the first target character in the second preset format; wherein the second preset format includes adjacent identifiers of the target character and the timestamp.
[0009] Optionally, the method further comprises: In the case where the standard message satisfies a third preset format, it is determined that a message name exists in the message to be parsed, and the length of the message name is determined; wherein the third preset format includes the target character and a second identifier representing the message name.
[0010] Optionally, based on the position of the data length code and the data length code, reading the target data in the message to be parsed includes: Based on the data length code, determining the interval length between the data length code and the target data; Determining the starting position of the target data based on the position of the data length code and the interval length; Based on the start position of the target data and the data length code, the target data is read.
[0011] Optionally, the method further comprises: Convert the target data into standard data; Based on the description information of the standard data and the target data, a parsing result of the message to be parsed is generated; the description information includes one or more of a timestamp, a data state, an ID, a message name and a data length code of the message to be parsed; The parsing result is output.
[0012] Based on the same inventive concept, a second aspect of an embodiment of the present application provides a data analysis device, the device comprising: A time parsing module, for determining, for a message to be parsed whose data state is a receiving state, an end position of a timestamp in the message to be parsed; A message name parsing module, used to detect whether a message name exists in the message to be parsed, and obtain a first detection result; the first detection result is used to indicate that the message name exists in the message to be parsed, or that the message name does not exist in the message to be parsed; A data length code parsing module, configured to determine the position of the data length code in the message to be parsed based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, and read the data length code; The target data parsing module is used to read the target data in the message to be parsed based on the position of the data length code and the data length code.
[0013] Based on the same inventive concept, the third aspect of an embodiment of the present application provides a storage medium, in which machine executable instructions are stored. When the machine executable instructions are executed by a processor, the data parsing method proposed in the first aspect of the present application is implemented.
[0014] Based on the same inventive concept, the fourth aspect of an embodiment of the present application provides a vehicle, including a processor and a memory; the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the data parsing method proposed in the first aspect of the present application.
[0015] Compared with the prior art, this application has the following advantages: The embodiment of the present application provides a data parsing method, for a message to be parsed whose data status is a receiving status, determining the end position of the timestamp in the message to be parsed; detecting whether there is a message name in the message to be parsed to obtain a first detection result; the first detection result is used to characterize the existence of the message name in the message to be parsed, or the absence of the message name in the message to be parsed; based on the end position of the timestamp, the data status, the ID of the message to be parsed and the first detection result, determining the position of the data length code in the message to be parsed, and reading the data length code; based on the position of the data length code and the data length code, reading the target data in the message to be parsed. Thus, for a message to be parsed whose data status is a receiving status, by detecting whether there is a message name in the message to be parsed, the position of the data length code is adaptively determined, and then the target data is accurately read, avoiding the problem of determining the position of the data length code in a fixed manner in the prior art, resulting in errors in reading the target data, so as to improve the efficiency and accuracy of data parsing. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0017] Figure 1 is a flow chart of a data parsing method in one embodiment of the present application; Figure 2 is a flow chart of a data parsing method in one embodiment of the present application; Figure 3 It is a functional module diagram of a data analysis device in one embodiment of the present application; Figure 4 It is a structural schematic diagram of a vehicle in one embodiment of the present application. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0019] With the development of automotive electronic technology, the Controller Area Network (CAN) protocol is widely used for data transmission between various controllers in the car. However, the traditional CAN protocol has limitations in data transmission rate and data load, and it is difficult to meet the efficient data transmission requirements of modern automotive electronic systems. For this reason, the CANFD (CAN with Flexible Data-Rate) protocol came into being, providing a higher data transmission rate and a larger data frame size.
[0020] Existing technologies usually face the following problems when parsing CANFD data: 1. High complexity of data parsing: Since the data frame format of the CAN FD protocol is more complex than that of the traditional CAN protocol, existing algorithms often require more computing resources and time when parsing data, resulting in low parsing efficiency.
[0021] 2. Information extraction is not accurate enough: Existing parsing algorithms are prone to data loss or incorrect parsing when faced with high-frequency data streams, affecting the reliability of the system.
[0022] 3. Poor compatibility: Existing parsing algorithms are usually optimized for parsing specific data frame formats and lack compatibility with data in multiple formats, which easily leads to parsing failures.
[0023] In view of this, the present application proposes a data parsing method. On the one hand, by detecting the data state of the message to be parsed, the message data in the receiving state is screened out for parsing, avoiding meaningless parsing of the known data in the sending state, and improving the efficiency of data parsing. On the other hand, by detecting whether there is a message name in the message to be parsed, the position of the data length code is adaptively determined, and then the target data is accurately read, avoiding the problem of determining the position of the data length code in a fixed manner in the prior art, resulting in errors in reading the target data, and improving the accuracy of data parsing. In addition, by adaptively determining the position of the target data according to the specific value of the data length code, the compatibility with the data frame format is enhanced, and it can be applied to a variety of application demand scenarios.
[0024] Please refer to Figure 1 , Figure 1 1 is a flow chart of a data analysis method proposed in one embodiment of the present application. Figure 1 As shown, the method comprises the following steps: S101: For a message to be parsed whose data status is a receiving status, determine an end position of a timestamp in the message to be parsed.
[0025] In this implementation, the data status of the message includes two types: receiving status (Rx) and sending status (Tx). If the data status of a message is receiving status, it means that the message is received by the current node from somewhere else. If the data status of a message is sending status, it means that the message is sent by the current node to somewhere else. For messages in the sending status, because the current node, as the sender, already knows the content of the data to be sent, there is no need to parse the sent message. If the current node parses the sent message again, it will cause unnecessary processing overhead and waste of resources. This redundant processing will not only reduce the efficiency of the processing system, but may also introduce additional errors and complexity.
[0026] In this regard, when parsing a message, this embodiment first detects whether the data state of the message is a receiving state. If so, the subsequent parsing process continues. If not, the message is skipped and the data state detection of the next message is performed. Thus, the messages to be parsed in the receiving state are screened out for subsequent parsing to improve the overall data parsing efficiency. That is, in a batch of messages, there may be multiple messages to be parsed in the receiving state.
[0027] Furthermore, the timestamp in the message to be parsed indicates the reception time (or transmission time) of the message, and the timestamp is located at the very beginning of the message. It should be noted that different timestamps may occupy different numbers of bytes, resulting in different end positions of the timestamps, which in turn affects the actual position of subsequent target data, especially when the time span is large. For example, a timestamp within 100 milliseconds can be stored in 4 bytes, but a timestamp of 1 minute requires 8 bytes to store.
[0028] S102: Detect whether the message name exists in the message to be parsed, and obtain a first detection result.
[0029] The first detection result is used to indicate that the message name exists in the message to be parsed, or that the message name does not exist in the message to be parsed.
[0030] In this implementation, the message name defines the purpose and content of each message in the network protocol. In a DBC file (a file format used to define the CAN bus communication protocol), the message name is used to identify different messages that contain communication data between different components in the vehicle system. For example, a message named LOCK_STATUS may contain the lock status information of the door, a message named "Light Control" may contain instructions to control the vehicle's lighting system, and another message named "Engine Status" may contain real-time data of the engine. These names help system designers and maintainers understand and debug communications in vehicle networks.
[0031] When the message to be parsed has a message name or does not have a message name, the number of bytes occupied is different, which will affect the actual position of the subsequent target data. In addition, when the message to be parsed has a message name, the number of bytes occupied by different message names is also different.
[0032] In specific implementation, the target name of the message to be parsed this time may be imported, and based on the target name, a message name query may be performed on the above-mentioned multiple received messages to be parsed to determine whether the message name exists in the messages to be parsed.
[0033] S103: Based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, determine the position of the data length code in the message to be parsed, and read the data length code.
[0034] The ID of the message to be parsed refers to the identifier of the message, which is used to identify the type of message in the network. The Data Length Code (DLC) indicates the length of the valid data in the data packet, and is intended to control the size and format of data transmission. It helps the receiving end identify and process the data by specifying the length of the data packet, thereby ensuring the integrity and accuracy of the data. For example, if the data length code is 0x08, it means that the data segment contains 8 bytes of data, and if the data length code is 0x0A, it means that the data segment contains 10 bytes of data.
[0035] In this implementation, after determining the end position of the timestamp, the position of the data length code can be calculated based on the data status and the number of bytes occupied by the ID of the message to be parsed, as well as the existence of the message name in the message to be parsed, and then the data length code can be read to understand the size of the target data contained in the current message to be parsed.
[0036] Furthermore, different first detection results correspond to different data reading methods. For example, when the first detection result indicates that there is a message name in the message to be parsed, the position of the data length code is determined according to the actual length of the message name, and then the position of the target data is determined; when the first detection result indicates that there is no message name in the message to be parsed, the position of the data length code is determined based on a fixed byte length. Then, for different situations (the message name exists and the message name does not exist), corresponding rules are used to determine the actual position of the subsequent target data and read the target data.
[0037] S104: Read target data in the message to be parsed based on the position of the data length code and the data length code.
[0038] In this implementation, the target data in the message to be parsed is stored after the data length code, and there is often an interval of fixed byte length between the data length code and the target data. Therefore, after determining the position of the data length code, the position of the target data can be calculated based on the position of the data length code and the fixed interval length, and then the target data can be read.
[0039] The interval length between the data length code and the target data is affected by the value of the data length code itself, that is, different data length codes may correspond to different interval lengths. For example, when the data length code is 0x08, the interval length between the data length code and the target data may be 2, and when the data length code is 0x0A, the interval length between the data length code and the target data may be 5.
[0040] On the one hand, this embodiment detects the data state of the message to be parsed, selects the message data in the receiving state for parsing, avoids meaningless parsing of the known data in the sending state, and improves the efficiency of data parsing. On the other hand, by detecting whether there is a message name in the message to be parsed, the position of the data length code is adaptively determined, and then the target data is accurately read, avoiding the problem of determining the position of the data length code in a fixed manner in the prior art, resulting in errors in reading the target data, and improving the accuracy of data parsing. In addition, by adaptively determining the position of the target data according to the specific value of the data length code, the compatibility with the data frame format is enhanced, and it can be applied to a variety of application demand scenarios.
[0041] The following takes the analysis of CANFD protocol data as an example to illustrate the practical application process of the above method. Figure 2 , the process mainly includes: S201: Determine the target CANFD ID and target CANFD Message Name of the data packet to be parsed, and perform a data format check.
[0042] In this implementation, CANFD ID refers to the identifier of the standard frame in the CANFD network protocol, and CANFD MessageName refers to the message name in the CANFD network protocol. A data packet may contain one or more CANFD IDs, and a CANFD ID may contain multiple message data, and the CANFD Message Names of these message data are not the same.
[0043] In specific implementation, the user can import the CANFD protocol data and the target CANFD ID and target CANFD Message Name to be parsed this time into this parsing algorithm to parse the data. Among them, the target CANFD MessageName is a non-mandatory input information. That is, for the message data whose ID to be parsed this time is the target CANFD ID, the target CANFD Message Name may exist in the message data, or it may not exist.
[0044] Furthermore, the format of the imported CANFD protocol data is checked. If the imported data packet is in ASC format (ASCII, used to store data in ASCII code), the subsequent step S202 is executed. If it is not in ASC format, the process exits and reports a format error to inform the upper-layer application that the corresponding parsing work cannot be completed.
[0045] S202: extract the Nth row of data as the message to be parsed, and detect its data status.
[0046] In this embodiment, a data line can be regarded as a message to be parsed, and can be extracted one by one for parsing. For example, when N=1, it means that the original data in the CANFD protocol data of the first line is extracted for subsequent parsing. After the parsing of the first line of data is completed, N is set to 2, and the original data in the CANFD protocol data of the second line is extracted for parsing. This cycle is repeated until all the data lines in the data packet are parsed.
[0047] During the parsing process, the data status of the message to be parsed must first be detected to filter out the messages to be parsed in the receiving state for subsequent parsing. Specifically, the data status detection process mainly includes: S202-1: Replace all spaces in the message to be parsed with target characters to obtain a standard message.
[0048] In this implementation, first, all spaces in the message to be parsed are replaced with target characters. The target characters are special characters other than letters and numbers, such as "!". The purpose of replacing spaces with target characters is to facilitate more efficient parsing of each field in subsequent parsing, and to avoid spaces in data rows interfering with the parsing work.
[0049] It should be noted that, in the case where there are multiple consecutive spaces, the multiple consecutive spaces are replaced with a target character to obtain a standard message and perform subsequent parsing to reduce the detection amount.
[0050] S202-2: When the standard message satisfies the first preset format, determine that the data state of the message to be parsed is a receiving state.
[0051] The first preset format includes a target character and a first identifier indicating a receiving state.
[0052] In this embodiment, the first preset format is a parsing condition pre-constructed based on the target character and the first identifier indicating the receiving state. For example, "special character + Rx + special character" is used as the parsing condition, where Rx is the first identifier, indicating that the data state of the message to be parsed is the receiving state.
[0053] Based on the first preset format, a query is performed in the message to be parsed. If it is found that the message to be parsed meets the format condition, the data state of the message to be parsed is determined to be a receiving state, and the subsequent step S203 is performed. If it is detected that the format condition is not met, the data state of the message to be parsed is determined to be a sending state, and N is increased by 1 to parse the next data row.
[0054] S203: Parse the timestamp of the message to be parsed, and determine the end position of the timestamp.
[0055] In this implementation, the timestamp indicates the time when the message to be parsed is received, and is located at the very beginning of the message to be parsed. Specifically, the timestamp detection process mainly includes: When the standard message meets the second preset format, the end position of the timestamp in the message to be parsed is determined based on the position of the first target character in the second preset format, wherein the second preset format includes adjacent identifiers of the target character and the timestamp.
[0056] In this implementation manner, the adjacent identifiers of the timestamp include: an identifier indicating the type of network protocol to which the message to be parsed belongs, an identifier indicating the CANFD ID, and a first identifier indicating a receiving state.
[0057] The second preset format is a parsing condition pre-constructed based on adjacent identifiers of the target character and the timestamp. For example, a special character + "canfd" + special character + target CANFD ID + Rx + special character is used as a parsing condition, where canfd indicates the type of network protocol to which the message to be parsed belongs.
[0058] Based on the second preset format, a query is performed in the message to be parsed. If the message to be parsed meets the format condition, it is determined that the data line is of canfd type, the ID is the target CANFD ID, and the data state is the receiving state of the message to be parsed, which means that the part before the first special character is the timestamp of the message to be parsed. Therefore, based on the position of the first target character in the second preset format, the byte length and end position of the timestamp in the message to be parsed can be determined, so as to parse and obtain the receiving time of the message to be parsed.
[0059] S204: Detect whether the message name exists in the message to be parsed, and obtain a first detection result.
[0060] In this implementation manner, the message name detection process mainly includes: when the standard message meets the third preset format, determining that the message name exists in the message to be parsed, and determining the length of the message name.
[0061] The third preset format includes the target character and a second identifier representing the message name.
[0062] In this embodiment, the third preset format is a parsing condition pre-constructed based on the target character and the second identifier representing the message name. For example, "special character + "LOCK_STATUS" + special character" is used as the parsing condition, where LOCK_STATUS is the second identifier, indicating the message name of the message to be parsed.
[0063] A query is performed in the message to be parsed based on the third preset format. If the message to be parsed is found to meet the format condition, it is determined that the message to be parsed has a message name; if the message to be parsed is found not to meet the format condition, it is determined that the message to be parsed does not have a message name. Finally, a first detection result is obtained, and the first detection result is used to indicate that the message to be parsed has a message name, or does not have a message name in the message to be parsed.
[0064] S205: Based on the first detection result, determine the position of the data length code in the message to be parsed.
[0065] According to the above analysis, when the message to be parsed has a message name or does not have a message name, the number of bytes occupied is different, which will affect the actual position of the subsequent target data. Therefore, it is necessary to design corresponding data reading rules for different situations to correctly read the target data.
[0066] Specifically, the process includes: S205-1: When the first detection result indicates that there is a message name in the message to be parsed, determine the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data status, the length of the ID, the length of the message name and the first fixed length.
[0067] In this implementation, the first fixed length refers to the fixed interval length between the message name and the data length code, for example, 2 bytes. When the first detection result indicates that the message name exists in the message to be parsed, the position of the data length code (DLC) in the message to be parsed can be calculated from the end position of the timestamp + the length of the network protocol type + the length of the data state + the length of the ID + the length of the message name + the first fixed length, and the data length code can be read.
[0068] The length of the network protocol type is fixed, for example, the length of the canfd type is 2 bytes. The length of the data state is also fixed, for example, the length of the receive state Rx is 2 bytes. The length of the ID and the length of the message name can be determined when the target CANFD ID and target CANFD Message Name are entered at the beginning.
[0069] S205-2: When the first detection result indicates that the message name does not exist in the message to be parsed, determine the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data status, the length of the ID and the second fixed length.
[0070] In this implementation, when the first detection result indicates that the message name does not exist in the message to be parsed, starting from the end position of the timestamp + the length of the network protocol type + the length of the data status + the length of the ID + the second fixed length, the position of the data length code (DLC) in the message to be parsed can be calculated and the data length code can be read.
[0071] Among them, the second fixed length is 4 bytes, which means that the message name of the message to be parsed occupies 2 bytes by default, and the fixed interval length between the message name and the data length code is 2 bytes.
[0072] This embodiment adopts corresponding rules to determine the position of the data length code according to different situations (the presence of the message name and the absence of the message name), so as to facilitate the subsequent accurate reading of the target data.
[0073] In addition, for the read data length code information, it is also necessary to detect the data length code information according to the relevant rules of the CANFD protocol to determine whether the data length code complies with the CANFD protocol rules so as to verify the format and content of the data length code.
[0074] Specifically, the CANFD protocol stipulates that the maximum value of DLC is 64 bytes. Therefore, it is necessary to first detect whether the value of the data length code is within the allowed value range (0 to 64). If it is, it complies with the CANFD protocol rules. If not, it means that the data is invalid and there is no need for subsequent parsing. The next data row can be parsed directly. Secondly, according to the value of the data length code, verify whether the actual number of bytes in the data field is consistent with that specified by the data length code. In particular, for cases exceeding 8 bytes, it is necessary to convert and verify according to the encoding rules of the CANFD protocol to determine whether the data in the data field conforms to the expected format and content.
[0075] S206: Based on the position of the data length code and the data length code, read the target data in the message to be parsed.
[0076] In this implementation, the interval lengths (referring to the interval length between the data length code and the target data) corresponding to different data length codes may be different, which will affect the actual position of the target data. Therefore, it is necessary to find the position of the target data according to the actual situation of the current data length code. Specifically, the process mainly includes: Based on the data length code, determine the interval length between the data length code and the target data; based on the position of the data length code and the interval length, determine the starting position of the target data; based on the starting position of the target data and the data length code, read the target data.
[0077] In this implementation, when DLC=0x08, that is, the data length code indicates that the length of the target data is 8 bytes, the interval length between the data length code and the target data is 2 bytes. At this time, starting from the position of the data length code + the length of the data length code + 2, the starting position of the target data in the message to be parsed can be calculated, and 8 bytes can be read from the starting position to obtain the complete target data. Among them, the length of the data length code is fixed and occupies 4 bytes.
[0078] When DLC=0x09 or DLC=0x0A or DLC=0x0B or DLC=0x0C or DLC=0x0D or DCL=0x0E or DLC=0x0F, that is, the data length code indicates that the length of the target data is 9, 10, 11, 12, 13, 14 or 15 bytes, the interval length between the data length code and the target data is 5 bytes. At this time, starting from the position of the data length code + the length of the data length code + 5, the starting position of the target data in the message to be parsed can be calculated, and 9, 10, 11, 12, 13, 14 or 15 bytes can be read from the starting position to obtain the complete target data.
[0079] This embodiment adaptively determines the position of the target data according to the specific value of the data length code, is compatible with different CANFD data frame formats, has good versatility, and is suitable for a variety of application demand scenarios.
[0080] S207: Summarize the target data and the description information related to the target data, obtain the parsing result and output it.
[0081] In this embodiment, the description information includes one or more of the timestamp, data status, ID, message name and data length code of the message to be parsed. When summarizing the parsing results corresponding to the message to be parsed, the target data is first formatted to obtain standard data, and then the parsing results of the message to be parsed are generated and output based on the standard data and the description information of the target data.
[0082] Specifically, the extracted target data in text format needs to be converted into an array format for temporary storage. At the same time, the standard data in the array format is summarized with the message receiving time, data status, message name, ID, data length code and other information obtained by parsing the above steps S201-S206 to generate a parsing result corresponding to the message to be parsed, so as to facilitate data calls by the upper-level application.
[0083] S208: extract the N+1th row of data for parsing until all data parsing is completed.
[0084] In this implementation, the parsed data row information and the position of the currently executed data row can be used to determine whether there are any data rows that have not been parsed. If there are any data rows that have not been parsed, N is increased by 1 to continue parsing the data of the next data row. If all data rows are parsed and there are no problems with the parsing process, the end information is fed back, indicating that the CANFD protocol data is parsed successfully, and the upper-layer application is informed that the relevant parsing work has been successfully completed.
[0085] This embodiment can improve the speed of data parsing by optimizing the data parsing process, and is suitable for application scenarios of high-frequency data transmission. In addition, it has good versatility, is compatible with different CANFD data frame formats, and can meet various application requirements. In addition, by introducing an error detection and correction mechanism (replacing spaces in data lines with target characters for corresponding detection and using CANFD protocol rules to verify data length codes), the possibility of data loss and erroneous parsing is greatly reduced, and the reliability of data parsing is improved.
[0086] Please refer to Figure 3 Based on the same inventive concept, the second aspect of the embodiment of the present application provides a data analysis device, the data analysis device 300 includes: The time parsing module 301 is used to determine the end position of the timestamp in the message to be parsed for the message to be parsed whose data state is the receiving state; The message name resolution module 302 is used to detect whether the message name exists in the message to be resolved, and obtain a first detection result; the first detection result is used to indicate that the message name exists in the message to be resolved, or that the message name does not exist in the message to be resolved; The data length code parsing module 303 is used to determine the position of the data length code in the message to be parsed based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, and read the data length code; The target data parsing module 304 is used to read the target data in the message to be parsed based on the position of the data length code and the data length code.
[0087] Optionally, the data length code parsing module 303 includes: A first parsing submodule, configured to determine the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data state, the length of the ID, the length of the message name, and the first fixed length when the first detection result indicates that the message to be parsed has a message name; The second parsing submodule is used to determine the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data status, the length of the ID and the second fixed length when the first detection result indicates that the message name does not exist in the message to be parsed.
[0088] Optionally, the above device further includes: The replacement module is used to replace all spaces in the message to be parsed with target characters to obtain a standard message; The state detection module is used to determine that the data state of the message to be parsed is a receiving state when the standard message meets a first preset format; wherein the first preset format includes a target character and a first identifier indicating the receiving state.
[0089] Optionally, the time parsing module 301 includes: The timestamp detection submodule is used to determine the end position of the timestamp in the message to be parsed based on the position of the first target character in the second preset format when the standard message meets the second preset format; wherein the second preset format includes adjacent identifiers of the target character and the timestamp.
[0090] Optionally, the above device further includes: The message name detection module is used to determine whether a message name exists in the message to be parsed and the length of the message name when the standard message meets a third preset format; wherein the third preset format includes a target character and a second identifier representing the message name.
[0091] Optionally, the target data parsing module 304 includes: An interval determination submodule, used for determining the interval length between the data length code and the target data based on the data length code; A start determination submodule, used to determine the start position of the target data based on the position and interval length of the data length code; The reading submodule is used to read the target data based on the starting position and data length code of the target data.
[0092] Optionally, the above device further includes: A format conversion module is used to convert the target data into a standard data format; A result generation module, used to generate a parsing result of the message to be parsed based on the description information of the standard data and the target data; the description information includes one or more of the timestamp, data status, ID, message name and data length code of the message to be parsed; The result output module is used to output the parsing results.
[0093] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0094] On the third aspect, based on the same inventive concept, an embodiment of the present application provides a storage medium, in which machine executable instructions are stored. When the machine executable instructions are executed by a processor, the data parsing method proposed in the first aspect of the present application is implemented.
[0095] It should be noted that the specific implementation of the storage medium of the embodiment of the present application refers to the specific implementation of the data analysis method proposed in the first aspect of the embodiment of the present application, and will not be repeated here.
[0096] In the fourth aspect, based on the same inventive concept, refer to Figure 4 An embodiment of the present application provides a vehicle 400, including a processor 401 and a memory 402; the memory 402 stores machine executable instructions that can be executed by the processor 401, and the processor 401 is used to execute the machine executable instructions to implement the data parsing method proposed in the first aspect of the present application.
[0097] It should be noted that the specific implementation of the vehicle 400 in the embodiment of the present application refers to the specific implementation of the data analysis method proposed in the first aspect of the embodiment of the present application, and will not be repeated here.
[0098] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0099] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt 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.
[0100] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0101] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0102] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0103] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0104] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0105] The above is a detailed introduction to a data analysis method, device, medium and vehicle provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data analysis method, characterized in that: The method comprises: For a message to be parsed whose data state is a receiving state, determining an end position of a timestamp in the message to be parsed; Detecting whether a message name exists in the message to be parsed, and obtaining a first detection result; the first detection result is used to indicate that the message name exists in the message to be parsed, or that the message name does not exist in the message to be parsed; Based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, determine the position of the data length code in the message to be parsed, and read the data length code; Based on the position of the data length code and the data length code, the target data in the message to be parsed is read.
2. The method according to claim 1, characterized in that Determining a position of a data length code in the message to be parsed based on the end position of the timestamp, the data state, the ID of the message to be parsed, and the first detection result, includes: In a case where the first detection result indicates that a message name exists in the message to be parsed, determining the position of the data length code based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data state, the length of the ID, the length of the message name, and the first fixed length; When the first detection result indicates that there is no message name in the message to be parsed, the position of the data length code is determined based on the end position of the timestamp, the length of the network protocol type to which the message to be parsed belongs, the length of the data status, the length of the ID and the second fixed length.
3. The method according to claim 2, characterized in that The method further comprises: Replace all spaces in the message to be parsed with target characters to obtain a standard message; In the case where the standard message satisfies a first preset format, it is determined that the data state of the message to be parsed is a receiving state; wherein the first preset format includes the target character and a first identifier indicating the receiving state.
4. The method according to claim 3, characterized in that Determining the end position of the timestamp in the message to be parsed includes: When the standard message satisfies a second preset format, the end position of the timestamp in the message to be parsed is determined based on the position of the first target character in the second preset format; wherein the second preset format includes adjacent identifiers of the target character and the timestamp.
5. The method according to claim 3, characterized in that: The method further comprises: In the case where the standard message satisfies a third preset format, it is determined that a message name exists in the message to be parsed, and the length of the message name is determined; wherein the third preset format includes the target character and a second identifier representing the message name.
6. The method according to claim 1, characterized in that Based on the position of the data length code and the data length code, reading the target data in the message to be parsed includes: Based on the data length code, determining the interval length between the data length code and the target data; Determining the starting position of the target data based on the position of the data length code and the interval length; Based on the start position of the target data and the data length code, the target data is read.
7. The method according to claim 1, characterized in that The method further comprises: Convert the target data into standard data; Based on the description information of the standard data and the target data, a parsing result of the message to be parsed is generated; the description information includes one or more of a timestamp, a data state, an ID, a message name and a data length code of the message to be parsed; The parsing result is output.
8. A data analysis device, characterized in that: The device comprises: A time parsing module, for determining, for a message to be parsed whose data state is a receiving state, an end position of a timestamp in the message to be parsed; A message name parsing module, used to detect whether a message name exists in the message to be parsed, and obtain a first detection result; the first detection result is used to indicate that the message name exists in the message to be parsed, or that the message name does not exist in the message to be parsed; A data length code parsing module, configured to determine the position of the data length code in the message to be parsed based on the end position of the timestamp, the data state, the ID of the message to be parsed and the first detection result, and read the data length code; The target data parsing module is used to read the target data in the message to be parsed based on the position of the data length code and the data length code.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data analysis method according to any one of claims 1 to 7 is implemented.
10. A vehicle, characterized in that: It comprises a processor and a memory; the memory stores machine executable instructions that can be executed by the processor, and the processor is used to execute the machine executable instructions to implement the data parsing method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Message analysis method and device, equipment and storage medium
CN113905106A
Message extraction method and device for log file, equipment, medium and program product
CN114661686A
Method and device for analyzing CAN message data, vehicle and storage medium
CN115657521A
Message detection method and device
CN116232757A
User-defined message analysis method and device, storage medium and vehicle
CN116582605A