CAN protocol analysis method, system, device and medium

By generating unpacking identifiers and building configuration tables, the problem of parsing and encapsulating CAN protocol signals in vehicles is solved, communication efficiency and signal debugging efficiency are improved, and unified processing of CAN signal protocols is achieved.

CN118677970APending Publication Date: 2024-09-20HOZON NEW ENERGY AUTOMOBILE CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410836531.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

The coexistence of CAN high-speed bus and low-speed bus signals in vehicles results in different message protocol formats, making it difficult to achieve efficient parsing and encapsulation, affecting communication efficiency and response delays.

Method used

Generate the unpacking identifier by obtaining the identity number value of the CAN protocol and the first byte value of the transmitted data stream, split the data stream into several data segments, build parsing rules based on the byte length of the stored bytes, and parse the field values. Convert and verify configurations, and generate multiple configuration tables to uniformly process CAN signal protocol data.

Benefits of technology

It achieves unified analysis and encapsulation of all CAN signal protocol data, avoids the workload and cost of custom development, and improves the speed of vehicle-machine handshake work and the efficiency of vehicle signal debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118677970A
    Figure CN118677970A
Patent Text Reader

Abstract

A CAN protocol analysis method, system, device and medium, the method comprising: acquiring an identity number value of a CAN protocol and a first byte value of a transmitted data stream to generate an unpacking identifier, and splitting the acquired data stream based on the unpacking identifier to generate a data segment and a first configuration table; building a field analysis rule based on the byte length of the storage bytes, analyzing the fields stored in the plurality of data segments based on the analysis rule, obtaining values corresponding to byte bits of the corresponding fields in the plurality of data segments, and generating a second configuration table; performing conversion configuration on the value of the field, and obtaining the configuration type of the value; performing verification configuration processing based on the configuration type of the value of the field; and outputting the value of the field after the configuration verification. According to the method, the configuration table information is uniformly constructed, so that the CAN protocol data analysis and packaging processing are unified, the efficient receiving and transmitting of different CAN protocol data of different vehicle ends are facilitated, and the quick handshake speed and the verification efficiency of signal instructions are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of CAN message communication, and in particular relates to a CAN protocol parsing method, system, device and medium. Background Art

[0002] At present, the general CAN high-speed bus on vehicles has a rate of 500kb / s, which is mainly used for control units with high real-time requirements, such as engines, automatic transmissions, anti-lock braking systems (ABS) / traction control systems (TCS), airbags, electronically controlled suspensions, cruise control, power steering, motor control, battery control, etc. The low-speed bus, with a rate of 100kb / s, is mainly used for body control, such as the collection and feedback of signals such as lighting control, wiper washing, electric seats, door locks and anti-theft, electric windows, horns, rearview mirrors, climate control, warning signals, and instrument displays. High-speed bus signals and low-speed bus signals coexist on the vehicle, and the message protocol formats are defined differently. The reception and transmission of each signal protocol, as well as communication with various electronic control units (ECUs), require parsing CAN signal messages and packaging them according to the protocol definition format. The workload of parsing and encapsulating CAN signal messages is huge, and it is difficult to achieve unified parsing and encapsulation for different services, resulting in difficulty in efficient operation of parsing and encapsulation, and difficulty in efficiently achieving handshake work with the vehicle computer and debugging and verification of vehicle signals, affecting communication efficiency and response delay. Summary of the invention

[0003] The present invention provides a CAN protocol parsing method, which includes: obtaining an identity identification number value of a CAN protocol and a first byte value of a transmitted data stream to generate an unpacking identifier, splitting the acquired vehicle-side CAN protocol data stream based on the unpacking identifier to generate a plurality of data segments and a first configuration table; constructing a field parsing rule based on the byte length of the stored bytes, parsing the fields stored in the plurality of data segments based on the parsing rule, and obtaining values ​​corresponding to byte bits of corresponding fields in the plurality of data segments, and generating a second configuration table; converting and configuring values ​​corresponding to byte bits of the fields, and obtaining a configuration type corresponding to the value of the byte bits; performing a verification configuration process based on the configuration type of the field value; and outputting the value of the field after verification configuration.

[0004] As an optional implementation, obtaining the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking identifier includes: obtaining the identity identification number value of the CAN protocol; obtaining the first byte format and first byte value of the message in the transmitted data stream, as well as the data length, data status, and data frame type of the first byte to generate an unpacking identifier.

[0005] As an optional implementation, the acquired vehicle-side CAN protocol data stream is split based on the unpacking identifier to generate several data segments, including: splitting the message in the vehicle-side CAN protocol data stream according to the first byte format to generate a frame start, arbitration segment, control segment, data segment, cyclic redundancy check segment, confirmation character segment and frame end; splitting the message based on the data length, data status, and data frame type split in the message to generate several data segments.

[0006] As an optional implementation, splitting the message based on the data length, data status, and data frame type to generate several data segments and a first configuration table also includes: filling the CAN instruction name to be parsed into the first configuration table according to predetermined rules; and splitting the acquired vehicle-side CAN protocol data stream based on the first configuration table.

[0007] As an optional implementation, constructing a parsing rule for a field based on the byte length of the stored byte includes: when the byte of the data segment is a single byte, constructing the starting position and byte length of the single byte value; when the byte of the data segment is multi-byte, constructing the starting position of the multi-byte value and the byte length of the corresponding byte in sequence.

[0008] As an optional implementation, sequentially constructing the starting position of a two-byte value and the length of the corresponding byte includes: sequentially constructing the starting position of the first byte, the byte length occupied by the first byte, the starting position of the second byte, and the byte length occupied by the second byte in the order of the two bytes.

[0009] As an optional implementation, constructing the parsing rules of the field also includes: configuring the message instructions into the second configuration table according to the parsing rules of the CAN instruction name; and parsing and processing the acquired vehicle-side CAN protocol data stream based on the second configuration table.

[0010] As an optional implementation, converting and configuring the values ​​corresponding to the byte bits of the field includes: converting and configuring the values ​​corresponding to the byte bits of the field to a minimum value, a maximum value, amplification factor, an offset, and an initial value, configuring the value type corresponding to the byte bits of the field, and verifying and configuring the configuration type of the field value.

[0011] As an optional implementation, converting and configuring the values ​​corresponding to the byte bits of the field also includes: configuring the message instructions into a third configuration table according to the conversion configuration rules of the CAN instruction name; and performing conversion configuration and verification configuration processing on the acquired vehicle-side CAN protocol data stream based on the third configuration table.

[0012] As an optional implementation, the first configuration table, the second configuration table, and the third configuration table are associated based on the CAN instruction name.

[0013] The present invention also provides a CAN protocol parsing system, which includes: a splitting unit, used to obtain the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking identifier, and split the acquired vehicle-side CAN protocol data stream based on the unpacking identifier to generate a plurality of data segments; a parsing unit, used to construct a field parsing rule based on the byte length of the stored bytes, parse the fields stored in the plurality of data segments based on the parsing rule, and obtain the values ​​corresponding to the byte bits of the corresponding fields in the plurality of data segments; a configuration verification unit, used to convert and configure the values ​​corresponding to the byte bits of the field, and obtain the configuration type corresponding to the value of the byte bit; perform configuration verification processing based on the configuration type of the field value; and an output unit, used to output the value of the field after the configuration verification.

[0014] The present invention also provides an electronic device, which includes: a memory for storing non-temporary computer-readable instructions; and a processor for running the computer-readable instructions, so that when the computer-readable instructions are executed by the processor, the above-mentioned CAN protocol parsing method is implemented.

[0015] The present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the above-mentioned CAN protocol parsing method.

[0016] Compared with the prior art, the present invention has obvious advantages and beneficial effects. By means of the above technical solution, the present invention has at least one of the following advantages and beneficial effects:

[0017] 1. A CAN protocol parsing method provided by the present invention comprises: obtaining the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking identifier, splitting the acquired vehicle-side CAN protocol data stream based on the unpacking identifier to generate several data segments and a first configuration table; constructing a field parsing rule based on the byte length of the stored byte, parsing the fields stored in several data segments based on the parsing rule, and obtaining the values ​​corresponding to the byte bits of the corresponding fields in several data segments, and generating a second configuration table; converting and configuring the values ​​corresponding to the byte bits of the fields, and obtaining the configuration type corresponding to the value of the byte bits; performing a verification configuration process based on the configuration type of the field value; and outputting the value of the field after verification configuration. The CAN protocol parsing method of the present invention constructs multiple configuration tables and uniformly constructs the configuration table information. By only modifying the configuration information of the configuration table, it is possible to realize the parsing and encapsulation of all CAN signal protocol data and the sending and receiving of messages, thereby avoiding the workload and cost of customized development based on the protocol, and improving the speed of the handshake work of the vehicle computer and the verification efficiency of the signal instructions during the vehicle signal debugging work.

[0018] 2. The present invention also provides a CAN protocol parsing system, which includes: a splitting unit, which is used to obtain the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking mark, and split the acquired vehicle-side CAN protocol data stream based on the unpacking mark to generate several data segments and a first configuration table; a parsing unit, which is used to construct a field parsing rule based on the byte length of the stored bytes, parse the fields stored in several data segments based on the parsing rule, and obtain the values ​​corresponding to the byte bits of the corresponding fields in several data segments, and generate a second configuration table; a configuration verification unit, which is used to convert and configure the values ​​corresponding to the byte bits of the fields, and obtain the configuration type corresponding to the value of the byte bits; perform configuration verification based on the configuration type of the field value; and an output unit, which is used to output the value of the field after verification configuration. The CAN protocol parsing system of the present invention constructs multiple configuration tables and uniformly constructs configuration table information. By only modifying the configuration information of the configuration table, it can realize the parsing and encapsulation of all CAN signal protocol data, the sending and receiving of messages, avoids the workload and cost of customized development based on the protocol, and improves the speed of the handshake work of the vehicle computer and the verification efficiency of the signal instruction during the vehicle signal debugging work.

[0019] 3. The present invention also provides an electronic device, which includes: a memory for storing non-temporary computer-readable instructions; and a processor for running computer-readable instructions, so that the computer-readable instructions are executed by the processor to implement the above-mentioned CAN protocol parsing method. The electronic device of the present invention constructs multiple configuration tables during operation, and uniformly constructs the configuration table information. By only modifying the configuration information of the configuration table, it can realize the parsing and encapsulation of all CAN signal protocol data and the sending and receiving of messages, avoiding the workload and cost of customized development based on the protocol, and improving the speed of the handshake work of the vehicle computer and the verification efficiency of the signal instructions during the vehicle signal debugging work.

[0020] 4. The present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the CAN protocol parsing method described above. The computer-readable storage medium of the present invention constructs multiple configuration tables and uniformly constructs configuration table information during operation. By only modifying the configuration information of the configuration table, the parsing and encapsulation of all CAN signal protocol data and the sending and receiving of messages can be realized, thereby avoiding the workload and cost of customized development based on the protocol, and improving the handshake speed of the vehicle computer and the verification efficiency of signal instructions during vehicle signal debugging.

[0021] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following specifically cites a preferred embodiment and describes it in detail with the accompanying drawings as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a flow chart of a CAN protocol parsing method according to an embodiment of the present invention;

[0023] Figure 2 It is a data structure diagram of a CAN message of a CAN protocol parsing method according to an embodiment of the present invention;

[0024] Figure 3 It is a data structure diagram of a CAN message of another CAN protocol parsing method according to an embodiment of the present invention;

[0025] Figure 4 It is a structured configuration format of a first configuration table of a CAN protocol parsing method according to an embodiment of the present invention;

[0026] Figure 5 It is a structured configuration format of a second configuration table of a CAN protocol parsing method according to an embodiment of the present invention;

[0027] Figure 6 It is a flowchart of another CAN protocol parsing method according to an embodiment of the present invention;

[0028] Figure 7 It is a structural diagram of a CAN protocol analysis system according to an embodiment of the present invention;

[0029] Figure 8 It is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the specific implementation methods, structures, features and effects proposed according to the present invention are described in detail below in conjunction with the accompanying drawings and preferred embodiments.

[0031] The present invention provides a CAN protocol parsing method, such as Figure 1 As shown, the CAN protocol parsing method includes:

[0032] S1, obtaining the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate a depacketization identifier, and splitting the obtained vehicle-side CAN protocol data stream based on the depacketization identifier to generate a plurality of data segments and a first configuration table;

[0033] It should be noted that after receiving the vehicle-side data, the received vehicle-side data stream is split and processed. Generally, the format of the first byte of the message data in the vehicle-side data stream is fixed, such as Figure 2 As shown in the figure, because the CAN / CANFD protocol data format is fixed and the byte length is fixed, only the data segment and business logic definitions are different, and the definition of the data segment is defined through a unique configuration file expression format. Figure 3 As shown in the figure, the unique configuration file expression format is uniformly defined, including the definition of data segment and business logic, and the unique configuration file expression format is defined by the definition of data segment. Figure 3 The method is defined so that the business logic can be uniformly parsed or encapsulated. For example, when parsing or encapsulating, it is not limited to identifying the data length contained in the first byte or other bytes of the message data, whether the data status is wrong, whether it is a remote frame, and whether it is an extended frame, and the above identification is used as the identification content. The first byte value of each signal value of the general CAN (not limited to CAN / CANFD protocol) bus is generally fixed to a certain value, and each CAN / CANFD protocol has a unique ID identification. Therefore, the first byte value and the CAN / CANFD identity identification number (ID) value are used as unpacking identification. When the data stream is split, the unpacking identification is generated based on one of the above identification contents such as data length or multiple contents such as data length and data status, and the first byte value of the message for the splitting of the data stream. For example, a first configuration table can be set, and the CAN / CANFD instructions to be parsed and their CAN / CANFD instruction names are filled in the first configuration table according to the sequence number, the first byte, and the CAN / CANFD ID. The order of the serial number, the first byte, and the CAN / CANFD ID included in the same CAN / CANFD command name in the first configuration table can be unified, or they can correspond to each other without being unified, and can be set according to actual needs. For example, the first configuration table is not limited to the following configuration file format: command name = serial number, first byte, CAN / CANFD ID. The first configuration table is used as the main table for parsing the corresponding commands for each command name, and the parsing tool splits the data stream based on the configuration of this first configuration table.

[0034] S2, constructing a field parsing rule based on the byte length of the stored bytes, parsing the fields stored in several data segments based on the parsing rule, obtaining the values ​​corresponding to the byte bits of the corresponding fields in the several data segments, and generating a second configuration table.

[0035] It should be noted that after the data stream of the message is split, the message data is decomposed into various data segments of fixed size. Then the data content of each data segment is parsed. For example, in CAN / CANFD, data information is stored in bytes. When the value of the stored byte is less than one byte, the parsing rule of the field can be expressed as: EPS1_SteeringAngleValid = 8, 1, which means that the value of the start bit of this field is 8, the length of the value is 1, and the value of this field only contains 0 and 1. When the value of the stored byte is greater than one byte length, a multi-byte configuration format is required, such as "EPS1_TorsionBarTorque=0,8;13,3". In this case, the multi-byte configuration format indicates that the 0th bit of the first byte is the starting bit, the value of the first byte occupies 8 bytes, the starting bit of the second byte is 13 (obtained by the number of bits of the starting byte 8 plus the starting position of the second byte 5), the second byte field occupies 3 bits, and the field "EPS1_TorsionBarTorque" uses a total of 13 bytes to store the value of this field. When the value of the stored byte is equal to one byte, it can be processed according to the previously default field parsing rules, or it can be processed according to the parsing rules of the field whose stored byte value is less than one byte. When parsing this value, the value can be accurately parsed from the byte bit according to this configuration.

[0036] For example, a second configuration table can be set, and the CAN / CANFD instructions to be parsed and their CAN / CANFD instruction names can be filled in the second configuration table according to the attribute name, starting position and length of the CAN / CANFD instructions. Similarly, the above-mentioned CAN / CANFD instruction names can be unified in the order of the attribute name, starting position and length of the CAN / CANFD instructions, or they can correspond to each other without being unified, and are set according to actual needs. For example, the second configuration table is not limited to the following configuration file format: instruction attribute name = starting position, length, such as the starting position when a single byte, the length is such as: EPS1_SteeringAngleValid = 8,1, starting position when multiple bytes, length; starting position, length such as: EPS1_TorsionBarTorque = 0,8; 13,3. The second configuration table is used as a secondary table of the instruction parsing main table corresponding to each instruction name, and the parsing tool parses the data stream based on the configuration content of the first configuration table and the second configuration table.

[0037] In addition, when the message-based data stream is encapsulated and merged, the data stream may also be encapsulated and merged with reference to the configuration contents of the first configuration table and the second configuration table, which will not be described in detail here.

[0038] S3, convert and configure the value corresponding to the byte bit of the field, and obtain the configuration type corresponding to the value of the byte bit; perform verification configuration processing based on the configuration type of the field value.

[0039] It should be noted that the data stream of the message is divided into various data segments, and the values ​​corresponding to the byte positions of each field need to be converted to the protocol dictionary value, such as converting the above values ​​based on the CAN / CANFD protocol dictionary. For example, after the number of the above value is parsed and extracted from the byte positions of the field, when the value is less than the number of bits in a byte, the range of the value needs to be considered and the type conversion of the value needs to be performed. If the value is greater than one byte, the specific situation of the endianness of the byte sequence needs to be considered, so the value conversion has a more complex configuration logic and configuration rules; in addition, the value needs to be verified by the check code, or the loop count processing. For example, the minimum and maximum values ​​of a series of values ​​are configured for value domain verification; the offset is used in the scenario of storing values ​​in multiple bytes to realize the offset merging processing of multi-byte values ​​to solve the problem of the endianness of the byte sequence during network processing; the initial value can be used for the default value setting of the message packet processing, and the default value of some fields can also be used for verification processing. When the value of the above message is converted and verified, the default conversion configuration and verification configuration of the CAN / CANFD protocol can be used, or the conversion configuration and verification configuration can be defined in the form of a third configuration table. For example, a third configuration table can be set, based on the attribute name of the CAN / CANFD instruction of the CAN / CANFD instruction, the configuration type (such as 0: value conversion, 1: checksum [check code processing], 2: msg_counter [loop count 0 to 15]), minimum value, maximum value, amplification factor, offset, initial value, the above minimum value, maximum value, amplification factor, offset, initial value can be set according to actual conditions, and will not be repeated here.

[0040] S4, output the value of the field after verification configuration.

[0041] It should be noted that after the data stream of the message is split into the values ​​of the fields parsed into various data segments and the values ​​of each field of the data stream marked with the data status are output, specifically to the vehicle end where the handshake connection is successful.

[0042] In the present invention, as an optional implementation, obtaining the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking identifier includes: obtaining the identity identification number value of the CAN protocol; obtaining the first byte format and first byte value of the message in the transmitted data stream, as well as the data length, data status, and data frame type of the first byte to generate an unpacking identifier.

[0043] It should be noted that if Figure 2 and Figure 3 As shown, in the message data of CAN / CANFD, there are seven components: frame start, arbitration segment, control segment, data segment, cyclic redundancy check (CRC) segment, confirmation character (ACK) segment and frame end. The resource file segment (res) is set in the control file of the control segment to indicate the reserved bit of the FD frame. The bit rate switch BRS (Bit Rate Switch), the BRS flag is used in the CANFD message, and is used to switch the data field transmission rate in the CANFD message. ESI (Error State Indicator): error state flag, this flag is only used in the CANFD message, and is used to indicate the error state of the node (such as error active or error passive). Stuffing bit count in the cyclic redundancy check (CRC) segment: Stuff Count (length is 4, 3-bit Gray code representation + 1 parity check bit), Stuff Count consists of 4 bits, of which bit0~2 is the result of Gray code calculation, and parity check Parity represents the result of parity check. The present invention mainly generates a depacketization mark by obtaining the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream in the data segment. Specifically, the identity identification number value of the CAN protocol will be obtained; the first byte format and first byte value of the message in the transmitted data stream, as well as the data length, data status, and data frame type of the message will be obtained to generate an unpacking identifier, unify different business logic definitions, and realize that the uniformly defined business logic can uniformly and accurately parse and process the message data in the data stream.

[0044] In the present invention, as an optional implementation, the acquired vehicle-side CAN protocol data stream is split based on the unpacking identifier to generate a number of data segments, including: splitting the message in the vehicle-side CAN protocol data stream according to the first byte format to generate a frame start, arbitration segment, control segment, data segment, cyclic redundancy check (CRC) segment, confirmation character (ACK) segment and frame end; splitting the message based on the data length, data status, and data frame type split in the message to generate a number of data segments and a first configuration table.

[0045] It should be noted that the identification content in the unpacking identifier is not limited to the data length, data status, and data frame type of the split data. The data splitting in the message can be first split based on the first byte format and the first byte value of the message in the unpacking identifier, and the split data segments can also be split based on the data length, data status, and data frame type included in the unpacking identifier. For example, in this embodiment, the splitting is based on the first byte format and the first byte value of the message, and the split data is filled into the first configuration table, such as the first configuration table records as follows:

[0046] #Serial number + first semester + ID

[0047] EPS_Fr02 0B2=0x01,0x68,0xB2

[0048] EPS_Fr01 0B1=0x02,0x68,0xB1

[0049] VCU Fr0E 108=0x03,0x68,0x108

[0050] VCU_Fr05_0E3=0x04,0x68,0xE3

[0051] IDB_Fr09_121=0x05,0x68,0x121

[0052] IDB Fr06 12B=0x06,0x68,0x12B

[0053] IDB_Fr01 0E5=0x07,0x68,0xE5

[0054] ADCS_Fr11 08F APA1=0x08,0x6D,0x8F

[0055] ADCS Fr02 08E=0x09,0x6A,0x8E

[0056] HCFDINSPVATB=0x0A,0x6D,0x388

[0057] Among them, EPS_Fr02 0B2 represents the wire-controlled steering instruction EPS and the component name code Fr02, as well as the control field 0B2 in the control file, such as 0x01, 0x68, and 0xB2, which respectively represent the serial number + the first section + the ID value.

[0058] In the present invention, as an optional implementation, splitting and processing the data length, data status, and data frame type in the message to generate a number of data segments also includes: filling the CAN instruction name to be parsed into the first configuration table according to a predetermined rule; and splitting and processing the acquired vehicle-side CAN protocol data stream based on the first configuration table.

[0059] It should be noted that the data split in the message also needs to be split and processed according to data length, data status, data frame type, and classified, so as to write the above-mentioned split data into the first configuration table according to the configuration requirements. The specific process refers to the above description and will not be repeated here.

[0060] In the present invention, as an optional implementation, the parsing rules for constructing a field based on the byte length of the stored byte include: when the byte of the data segment is a single byte, constructing the starting position and byte length of the single byte value; when the byte of the data segment is multi-byte, constructing the starting position of the multi-byte value and the byte length of the corresponding byte in sequence.

[0061] It should be noted that the bytes of the data segment are multi-byte, including two, three or more bytes. When the starting position of the value of the multi-byte data segment field and the byte length of the corresponding field are sequentially constructed, the construction is carried out in a front-to-back order according to the starting position and byte length of the value of the field corresponding to each byte data of the data segment.

[0062] In the present invention, as an optional implementation, sequentially constructing the starting position of a two-byte value and the length of the corresponding byte includes: sequentially constructing the starting position of the first byte, the byte length occupied by the first byte, the starting position of the second byte, and the byte length occupied by the second byte in the order of the two bytes.

[0063] It should be noted that, for example, when the bytes of the data segment are multi-byte, the starting position of the value of the multi-byte data segment field and the length of the corresponding field can also be constructed according to the following rules. When the bytes of the data segment are multi-byte, if the multi-byte data segment is two segments, the starting position of the value of the multi-byte data segment field and the byte bit length of the corresponding field are constructed in sequence, including the 0th starting bit of the first byte, the 0th starting bit length of the first byte, the starting bit of the second byte, and the second byte starting bit length. If the multi-byte data segment is three segments, the starting position of the value of the multi-byte data segment field and the byte bit length of the corresponding field are constructed in sequence, including the 0th starting bit of the first byte, the 0th starting bit length of the first byte, the starting bit of the second byte, the second byte starting bit length, the starting bit of the third byte, and the third byte starting bit length. If the multi-byte data segment is four segments, then the same can be applied. Among them, the starting bit of the second byte is equal to the number of bits of the 0th starting bit of the first byte plus the number of positions of the starting bit of the second byte; the starting bit of the third byte is equal to the number of bits of the starting bit of the second byte plus the number of positions of the starting bit of the third byte; the starting bit of the fourth byte is equal to the number of bits of the starting bit of the third byte plus the number of positions of the starting bit of the third byte. For other multi-byte data segments, the same is true and will not be repeated here.

[0064] In the present invention, as an optional implementation, constructing the parsing rules of the field also includes: configuring the message instructions into the second configuration table according to the parsing rules of the CAN instruction name; and parsing and processing the acquired vehicle-side CAN protocol data stream based on the second configuration table.

[0065] It should be noted that the second configuration table can parse and configure message instructions, such as according to the CAN / CANFD instruction name. The CAN / CANFD instruction name includes the CAN / CANFD instruction attribute name, the corresponding starting position and the corresponding length. For example, in the case of a single byte: starting position, length such as: EPS1_SteeringAngleValid=8,1. In the case of two bytes: starting position, length; starting position, length. For example: EPS1_TorsionBarTorque=0,8;13,3. For example, the configured second configuration table is recorded, such as taking the wire control steering instruction 1EPS Fr01 0B1 record as an example, as follows:

[0066] [EPS Fr01 0B1]

[0067] EPS1_steering Angle valid=8,1

[0068] EPS1_Steer Angle spd valid=9,1

[0069] EPS1_HSTW Calibrated=10,1

[0070] EPS1_Warning Lamp Red=11,1

[0071] EPS1_TorsionBar Torque valid=12,1

[0072] EPS1_TorsionBar Torque=0,8,13,3

[0073] EPS1_SteeringAngle=16,8,24,8

[0074] EPS1_warningLampYellow=40,2

[0075] EPS1_SteerAngleSpd=32,8,42,6

[0076] EPS1_MsgCounter=48,4

[0077] EPS1_Checksum=56,8

[0078] Among them, the validity of the steering angle of the control-by-wire instruction 1 (EPS1_steeringAngleValid) is represented by 8,1; the validity of the steering angle of the control-by-wire instruction 1 is represented by 9,1; the HSTW calibration of the control-by-wire instruction 1 is represented by 10,1; the red warning light of the control-by-wire instruction 1 is represented by 11,1; the validity of the torsion bar torque of the control-by-wire instruction 1 is represented by 12,1; the torsion bar torque of the control-by-wire instruction 1 is represented by 0,8,13,3; the steering angle of the control-by-wire instruction 1 is represented by 16,8,24,8; the yellow warning light of the control-by-wire instruction 1 is represented by 40,2; the steering angle limit of the control-by-wire instruction 1 is represented by 32,8,42,6; the message counter of the control-by-wire instruction 1 is represented by 48,4; and the checksum of the control-by-wire instruction 1 is represented by 56,8.

[0079] In the present invention, as an optional implementation, converting and configuring the values ​​corresponding to the byte bits of a field includes: converting and configuring the values ​​corresponding to the byte bits of the field to a minimum value, a maximum value, amplification factor, an offset, and an initial value, configuring the value type corresponding to the byte bits of the field, and verifying and configuring the configuration type of the field value.

[0080] It should be noted that after the value corresponding to the byte position of the field is extracted from the byte position, when the value is less than one byte position, it is necessary to consider the value range, numerical type conversion processing, etc.; when the value is greater than one byte, it is necessary to consider the endianness of the byte order. In addition, it is necessary to perform checksum verification or loop count processing on the configuration logic for numerical conversion. Among them, the minimum value and maximum value configurations are used for value domain verification, the offset is used in scenarios where values ​​are stored in multiple bytes to implement offset merging processing of multi-byte values ​​and solve the endianness problem of network processing. The initial value can be used for the default value setting of message packet processing, and the default value verification processing can also be performed on the values ​​of some fields. In addition, the loop count of the loop count processing is not limited to any value set to 0 to 15.

[0081] In the present invention, as an optional implementation, converting and configuring the values ​​corresponding to the byte bits of the field also includes: configuring the message instructions into a third configuration table according to the conversion configuration rules of the CAN instruction name; and performing conversion configuration and verification configuration processing on the acquired vehicle-side CAN protocol data stream based on the third configuration table.

[0082] It should be noted that the third configuration table can perform message value conversion configuration and verification configuration. For example, according to the CAN / CANFD instruction name and / or the CAN / CANFD instruction attribute name, the configuration type is (minimum value, maximum value, amplification factor, offset, initial value). For example, the second configuration table can be used to parse and configure the message instruction, such as according to the CAN / CANFD instruction name. The CAN / CANFD instruction name includes the CAN / CANFD instruction attribute name, the corresponding starting position and the corresponding length. For example, in the case of a single byte: starting position, length such as: EPS1_SteeringAngleValid=8,1. For two bytes: starting position, length; starting position, length. For example: EPS1_TorsionBarTorque=0,8;13,3. For example, the configured second configuration table is recorded, such as taking the wire-controlled steering instruction 2EPS Fr02 0B2 record as an example, as follows:

[0083] [EPS_Fr02 0B2]

[0084] EPS2_ADAS_Avatlable=0,0,1,1,0,0,

[0085] EPS2_AssistPraSwitchTODAS=0,0,3,1,0,0,

[0086] EPS2_ADAS Ctrl Abort Feedback=0,0,15,1,0,0,

[0087] EPS2_MotCntrl=0,-8,8,0.01,-8,-8,

[0088] EPS2_Checksum=1,0,255,1,0,0,{4 65 1 42 110 208 168 45 211 25 19122612 167 122 106}

[0089] Among them, advanced driving assistance can be represented by 0,0,1,1,0,0,; wire-assisted DAS adaptive steering is represented by 0,0,3,1,0,0,; advanced driving assistance control termination can be represented by 0,0,15,1,0,0,; user guidance at critical moments is represented by 0,-8,8,0.01,-8,-8,; checksum is represented by 1,0,255,1,0,0,, where the limited range is not limited to {4 651 42 110 208 168 45 211 25 191 226 12 167 122106}.

[0090] In the present invention, as an optional implementation, the first configuration table, the second configuration table and the third configuration table are associated based on the CAN instruction name.

[0091] It should be noted that the first configuration table, the second configuration table and the third configuration table can be associated with each other through the CAN / CANFD instruction name. For example, the name EPS_Fr02_OB2 will exist in the three configuration tables of the first configuration table, the second configuration table and the third configuration table. The first configuration table for data splitting and the second configuration table for data parsing are required configurations, and the third configuration table for value conversion needs to be configured when the value of the field occupies multiple bytes. When the value of the field is less than or equal to one byte, it can be not configured by default. However, if you need to set a default value for the field, you can add the value conversion configuration information of this field. In addition, the code corresponding to the CAN instruction name can also be used to associate the first configuration table, the second configuration table and the third configuration table. If the CAN instruction name is the same, the code corresponding to the same CAN instruction name in the first configuration table, the second configuration table and the third configuration table is also the same, so as to associate the first configuration table, the second configuration table and the third configuration table. For example, when the application is running and parsed, objects in the corresponding first configuration table, second configuration table, and third configuration table (such as instruction names or codes corresponding to instruction names) are generated. The first configuration table, second configuration table, and third configuration table can be designed as a structured configuration format, such as Figure 4 and Figure 5 shown.

[0092] In an embodiment of the present invention, Figure 4As shown, in the first configuration table, a first-class object String is created and a structural framework of the first-class object String is set, for example, the object String includes a first byte description module "canFDFirstByteDesc", an unpacking identification module (CANFDTag), and a signal content module (MessageEntity). Among them, the first description module is not limited to including: data length (+data_len), signal error state (+canfd_error_state), data frame type architecture (+is_canfd_frame), control segment architecture (+is_remote_frame), and expansion segment architecture (+is_expand_frame). The unpacking identification module is not limited to including an index (+index), a byte position (bit position) of the first byte, and an identity identification number (ID) value of canfd. The signal content module is not limited to including characteristic information (+properties) of the signal data segment, address information (+value_configs) of the byte value of the signal data segment, map attribute information (+map_properties) of the signal data segment map, total bit length information (+totalbit length) of the signal data segment, total byte length information (+total byte length) of the signal data segment, and message counter (+message_counter). The first-class object String interacts with the unpacking identification module based on the unpacking identification name in the first byte description module; the first-class object String interacts with the signal content module based on the signal content name; the unpacking identification module and the signal content module identify and interact with each other through the file header information of the module.

[0093] In an embodiment of the present invention, Figure 5As shown, in the second configuration table, create a second class object String and set the structure of the second class object String. For example, the second class object String includes a property value configuration module (PropertyValueConfig), a message data value module (CanValue) and a property information module (Property). Among them, the property value configuration module (PropertyValueConfig) includes type (+type), minimum value (+min_value), maximum value (+max_value), byte order size end (+growth_factor), offset (+offset), default value (+default_value) and check list (+crc_list). The value in the message data value module includes a one-byte value (+u8 value), a two-byte value (+u16 value), a four-byte value (+u32 value), and an 8-byte value (+u64 value). The property information module includes the address (+value_configs), type (+type) and converted value (+converted_value) of the property information value. In the second configuration table, the second type of object String interacts with the attribute value configuration module based on the same tag attribute value, such as the attribute name of the CAN / CANFD instruction; and interacts with the attribute information module through the attribute name (+property_name). The attribute value configuration module interacts with the attribute information module based on the configuration value after value conversion (+value_converter_config); the message data value module interacts with the attribute information module based on the numerical value (+value).

[0094] In another embodiment of the present invention, Figure 6As shown, the vehicle-mounted CAN / CANFD signal set module interacts with the CAN / CANFD to Ethernet device module to exchange information, and converts the CAN / CANFD signal into the target signal (such as CAN / CANFD signal) required by the Ethernet and / or CAN / CANFD data parsing transceiver system. After the signal data is accessed, the unpacked signal data is input to the signal parsing after the signal is unpacked, and the signal unpacking and information parsing can be loaded through the configuration information respectively. After the unpacked signal data is parsed, the parsed signal data encapsulation dictionary is encapsulated, and based on the business processing of the signal data (such as signal unpacking and signal parsing), the signal data after business processing is input to the signal encapsulation default value setting based on the CAN protocol, and the value modification setting based on the business rule is modified, such as the corresponding modification and setting based on the preset configuration table. Specifically, in the unpacking configuration process, the configuration information is loaded such as the information address manager (CanfdConfigManager), such as the initialization of the information address loaded by the configuration information. During the unpacking configuration process, the configuration information is loaded into the information address manager (CanfdConfigManager), such as the initialization of the information address loaded by the configuration information; similarly, the value conversion and verification configuration can be loaded through the configuration information, such as the interaction between the information address manager and the signal encapsulation default value setting and modification setting, and the information address manager loaded by the configuration information completes the signal encapsulation or the value modification setting based on the business rule. The value of the field after the verification configuration is output to the CANFD to Ethernet device in the form of a message for conversion and transmission to the vehicle-mounted CAN / CANFD signal set module.

[0095] The present invention also provides a CAN protocol analysis system, such as Figure 7 As shown, the CAN protocol parsing system 200 includes: a splitting unit 210, which is used to obtain the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate an unpacking identifier, and split the acquired vehicle-side CAN protocol data stream based on the unpacking identifier to generate a plurality of data segments and a first configuration table; a parsing unit 220, which is used to construct a parsing rule for the field based on the byte length of the stored bytes, parse the fields stored in a plurality of data segments based on the parsing rule, and obtain the values ​​corresponding to the byte bits of the corresponding fields in the plurality of data segments, and generate a second configuration table; a configuration verification unit 230, which is used to convert and configure the values ​​corresponding to the byte bits of the field, and obtain the configuration type corresponding to the value of the byte bit; perform configuration verification processing based on the configuration type of the field value; and an output unit 240, which is used to output the value of the field after verification and configuration.

[0096] It should be noted that the splitting unit 210, the parsing unit 220, the configuration verification unit 230 and the output unit 240 included in the CAN protocol parsing system 200 execute the above-mentioned process based on the CAN protocol parsing method when running. Please refer to the corresponding method part mentioned above and will not be repeated here.

[0097] The present invention also provides an electronic device, such as Figure 8 As shown, the electronic device 300 includes: a memory 310 for storing non-temporary computer-readable instructions 330; and a processor 320 for running the computer-readable instructions 330, so that when the computer-readable instructions 330 are executed by the processor 320, the above-mentioned CAN protocol parsing method is implemented.

[0098] The present invention also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on a device, the device executes the above-mentioned CAN protocol parsing method.

[0099] It should be noted that any process or method description in the flowchart or otherwise described herein may be understood to represent a module, fragment or portion of a code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and that the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.

[0100] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.

[0101] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0102] A person skilled in the art may understand that all or part of the steps included in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one of the steps of the method embodiment or a combination thereof.

[0103] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be partially implemented in the form of hardware, or may be implemented in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0104] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

[0105] The above are only preferred embodiments of the present invention, and are not intended to limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not intended to limit the present invention. Any technician familiar with the profession can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still fall within the scope of the technical solution of the present invention.

Claims

1. A CAN protocol analysis method, characterized in that: include: Obtain the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate a depacketization identifier, and split the acquired vehicle-side CAN protocol data stream based on the depacketization identifier to generate a plurality of data segments and a first configuration table; Constructing a parsing rule for a field based on the byte length of the stored bytes, parsing the fields stored in the plurality of data segments based on the parsing rule, obtaining values ​​corresponding to the byte positions of corresponding fields in the plurality of data segments, and generating a second configuration table; Convert and configure the value corresponding to the byte position of the field, and obtain the configuration type corresponding to the value of the byte position; Perform verification configuration processing based on the configuration type of the field value; Output the value of the field after verification configuration.

2. The CAN protocol analysis method according to claim 1, characterized in that: Obtaining the identity number value of the CAN protocol and the first byte value of the transmitted data stream to generate the unpacking identifier includes: Get the identity number value of the CAN protocol; Obtain the first byte format and first byte value of the message in the transmitted data stream, as well as the data length, data status, and data frame type of the first byte to generate an unpacking identifier.

3. The CAN protocol analysis method according to claim 1, characterized in that: Based on the unpacking identifier, the acquired vehicle-side CAN protocol data stream is split and processed to generate several data segments including: Split the message in the data stream of the vehicle-side CAN protocol according to the first byte format to generate the frame start, arbitration segment, control segment, data segment, cyclic redundancy check segment, confirmation character segment and frame end; The message is split based on the data length, data status, and data frame type to generate several data segments.

4. The CAN protocol analysis method according to claim 3, characterized in that: The data length, data status, and data frame type of the message are split and processed to generate a plurality of data segments and a first configuration table, including: Fill the CAN command name to be parsed into the first configuration table according to a predetermined rule; The acquired vehicle-side CAN protocol data stream is split and processed based on the first configuration table.

5. The CAN protocol analysis method according to claim 1, characterized in that: The parsing rules for building fields based on the byte length of the stored bytes include: When the byte of the data segment is a single byte, construct the starting position and byte length of the value of the single byte; When the bytes of the data segment are multiple bytes, the starting position of the multi-byte value and the byte length of the corresponding byte are constructed in sequence.

6. The CAN protocol analysis method according to claim 5, characterized in that: The starting position and length of the corresponding bytes of the two-byte value are constructed in sequence: The start bit of the first byte, the length of the first byte, the start bit of the second byte, and the length of the second byte are constructed in sequence according to the order of the two bytes.

7. The CAN protocol analysis method according to claim 5, characterized in that: The parsing rules for constructing fields also include: The message command is configured into the second configuration table according to the parsing rule of the CAN command name; The acquired vehicle-side CAN protocol data stream is parsed and processed based on the second configuration table.

8. The CAN protocol analysis method according to claim 1, characterized in that: The configuration for converting the values ​​corresponding to the byte bits of the field includes: The value corresponding to the byte bit of the field is converted and configured with the minimum value, maximum value, amplification factor, offset and initial value, and the value configuration type corresponding to the byte bit of the field is configured to verify the configuration type of the field value.

9. The CAN protocol analysis method according to claim 8, characterized in that: The configuration for converting the values ​​corresponding to the byte bits of the field also includes: The message command is configured into the third configuration table according to the conversion configuration rule of the CAN command name; The acquired vehicle-side CAN protocol data stream is converted and verified based on the third configuration table.

10. The CAN protocol analysis method according to claim 1, characterized in that: The first configuration table, the second configuration table, and the third configuration table are associated based on the CAN instruction name.

11. A CAN protocol analysis system, characterized in that: include: A splitting unit, used for acquiring the identity identification number value of the CAN protocol and the first byte value of the transmitted data stream to generate a depacketization identifier, and performing depacketization processing on the acquired vehicle-side CAN protocol data stream based on the depacketization identifier to generate a plurality of data segments and a first configuration table; A parsing unit, configured to construct a parsing rule for a field based on a byte length of stored bytes, parse the fields stored in the plurality of data segments based on the parsing rule, obtain values ​​corresponding to byte bits of corresponding fields in the plurality of data segments, and generate a second configuration table; A configuration verification unit is used to convert and configure the value corresponding to the byte bit of the field, and obtain the configuration type corresponding to the value of the byte bit; Perform verification configuration processing based on the configuration type of the field value; The output unit is used to output the value of the field after verification configuration.

12. An electronic device comprising: a memory for storing non-transitory computer-readable instructions; as well as A processor is used to run computer-readable instructions, so that when the computer-readable instructions are executed by the processor, the CAN protocol parsing method as described in any one of claims 1 to 10 is implemented.

13. A computer-readable storage medium, characterized in that: It comprises computer instructions, and when the computer instructions are executed on a device, the device executes the CAN protocol parsing method as claimed in any one of claims 1 to 10.

Citation Information

Cited By

  • Standard message analysis method and device, electronic equipment and storage medium

    CN119697297A

  • File transmission method and device based on CAN protocol and storage medium

    CN119814774A

  • New energy automobile OBD protocol conversion method and system

    CN119922244A