Communication protocol coding method based on CAN bus
By extending the CAN 2.0 frame ID and defining a variety of functional and security fields, the problem of CAN 2.0 standard packet length limitation and insufficient functionality is solved, and efficient and accurate communication between multiple devices is achieved and the flexibility and security of system are achieved. promote.
Patent Information
- Application Number
- CN202410970125.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-11-12
AI Technical Summary
The CAN 2.0 standard packet length limitation and lack of error codes, security verification and other fields, resulting in incomplete information transmission in most application environments where communication messages exceed 8 bytes, and the existing frame ID does not have sufficient functionality. and security, it is difficult to achieve efficient and accurate communication between multiple devices.
By extending CAN 2.0 frame ID, the function code, source address, destination address, multi-frame flag, end frame mark, redundant check, error code, security check and message serial number are enhanced to enhance the functionality and security of the message , ensure data integrity and uniqueness.
It realizes efficient, accurate and stable communication between multiple devices, ensures data integrity, uniqueness and security, is compatible with different devices, improves the flexibility and scalability of the system, and provides a deeper understanding of security-related processing. control ability.
Smart Images

Figure CN118945235A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of equipment communication, in particular to a communication protocol encoding method based on a CAN bus. Background Art
[0002] With the widespread application of the CAN 2.0 standard in various industries, especially in the fields of automobiles, industrial automation, medical equipment, ships, and aerospace, it has become an indispensable communication backbone in these industries. Since the CAN bus, as a communication medium, must rely on specific communication protocols to perform its functions, it is crucial to understand and effectively use these protocols. The CAN 2.0 standard stipulates that each message can only carry a maximum of 8 bytes of data, which poses a challenge in the current application environment where most communication messages exceed 8 bytes. This requires users to adopt a subpacketization strategy to ensure the integrity and efficient transmission of information. In addition, during the communication process, it is also necessary to consider how to effectively manage the information of the two communicating parties, such as their unique IDs, the functional type of the message, etc. These are elements that need to be carefully considered during the design and implementation stages.
[0003] The current data transmission method based on the CAN2.0 standard usually uses 8 bytes as the basic data message length. This limitation is mainly due to the strict definition of the message format in the CAN2.0 standard. For example, in typical application scenarios such as the automotive industry, the 8-byte data capacity sometimes cannot fully cover the amount of information required to be transmitted, so the information must be divided into multiple CAN messages for transmission.
[0004] Moreover, the existing CAN2.0 standard frame ID usually does not include fields such as error code and safety check. Summary of the invention
[0005] The object of the present invention is to provide a communication protocol encoding method based on CAN bus. The present invention has the advantages of being able to realize efficient, accurate and stable communication among multiple devices.
[0006] The technical solution of the present invention is a communication protocol encoding method based on the CAN bus, which defines the message ID based on the standard CAN2.0 extended frame; the CAN2.0 extended frame is defined as the corresponding function code, source address, destination address, multi-frame flag, end frame mark, redundancy check, error code, safety check and message sequence number.
[0007] In the aforementioned communication protocol encoding method based on CAN bus, the function code refers to the type of message, indicates the function of the message, and has a length of 2 bits; the function code 00 is a heartbeat message, 01 is a normal communication message, 10 is a warning message, and 11 is an emergency message.
[0008] In the aforementioned communication protocol encoding method based on the CAN bus, the source address represents the device address where the message is generated and has a length of 6 bits.
[0009] In the aforementioned communication protocol encoding method based on the CAN bus, the destination address represents the address of the destination device to which the message is sent, and has a length of 6 bits.
[0010] In the aforementioned communication protocol encoding method based on the CAN bus, the multi-frame flag indicates whether the frame is a single frame or multiple frames, and has a length of 1 bit.
[0011] In the aforementioned communication protocol encoding method based on the CAN bus, the end frame mark indicates whether it is the last frame of the message and has a length of 1 bit.
[0012] In the aforementioned communication protocol encoding method based on CAN bus, the redundancy check indicates whether it is a redundant message, and the length is 1 bit; the redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
[0013] In the aforementioned communication protocol encoding method based on CAN bus, the error code represents error information and has a length of 2 bits; the error code 00 represents a correct message, 01 represents a request error message, 10 represents a request unsupported message, and 11 represents a node error message.
[0014] In the aforementioned communication protocol encoding method based on CAN bus, the safety check indicates whether it is a redundant message, and the length is 1 bit; the redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
[0015] In the aforementioned communication protocol encoding method based on CAN bus, the message sequence number represents the serial number of the message, and the length is 8 bits.
[0016] Compared with the prior art, the present invention has the following beneficial effects:
[0017] This application provides a communication protocol encoding scheme based on the CAN2.0 standard, which can achieve efficient and accurate communication between devices on multiple buses;
[0018] By ensuring the integrity, uniqueness, accuracy and security of data, as well as compatibility with different devices, it provides strong support for users to build a stable and reliable communication system.
[0019] This application utilizes the 29-bit extended frame ID of the CAN2.0 standard to implement a variety of other functions, including function code, source address, destination address, multi-frame flag, end frame mark, redundancy check, error code, security check and message sequence number, and provides a variety of fields for users to use for security-related processing, which can provide more in-depth and accurate control of security-related processing.
[0020] Therefore, the present invention has the advantages of being able to achieve efficient, accurate and stable communication among multiple devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 This is a diagram illustrating the format of the extended frame in the CAN2.0 standard. DETAILED DESCRIPTION
[0022] The present invention is further described below in conjunction with the accompanying drawings and embodiments, but they are not intended to limit the present invention.
[0023] Embodiment. A communication protocol encoding method based on CAN bus, defining the message ID based on the standard CAN2.0 extended frame, defining the CAN2.0 extended frame as the corresponding function code, source address, destination address, multi-frame flag, end frame flag, redundancy check, error code, safety check and message sequence number;
[0024] The format of the CAN2.0 standard extended frame is as follows: Figure 1 .
[0025] The function code refers to the type of message, indicating the function of the message, and has a length of 2 bits; the function code 00 is a heartbeat message, 01 is a normal communication message, 10 is a warning message, and 11 is an emergency message.
[0026] The source address indicates the device address where the message originates and has a length of 6 bits.
[0027] The destination address indicates the destination device address of the message, and has a length of 6 bits.
[0028] The multi-frame flag indicates whether the frame is a single frame or multiple frames, and has a length of 1 bit.
[0029] The end frame flag indicates whether it is the last frame of the message and has a length of 1 bit.
[0030] The redundancy check indicates whether it is a redundant message, and its length is 1 bit. The redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
[0031] The error code indicates error information and has a length of 2 bits. The error code 00 indicates a correct message, 01 indicates a request error message, 10 indicates a request unsupported message, and 11 indicates a node error message.
[0032] The security check indicates whether it is a redundant message, and its length is 1 bit. The redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
[0033] The message sequence number indicates the sequence number of the message, and its length is 8 bits.
[0034] Functional division table
[0035]
[0036] The present invention provides users with a complete solution, so that after following the design of this solution, they can easily realize the mutual communication between devices on multiple buses; in addition, the compatibility issues between different devices are fully considered; by adopting the unified CAN2.0 standard, the present invention can realize seamless connection and efficient communication between devices of different manufacturers and models; this allows users to build complex communication systems without worrying about compatibility issues between devices, thereby greatly improving the flexibility and scalability of the system.
[0037] Due to the adoption of a unified standard, even devices from different manufacturers and models can communicate with each other as long as they follow the CAN2.0 standard; this eliminates compatibility barriers caused by manufacturer-specific implementations or private protocols; since there is no need to worry about compatibility issues, users can freely add or replace any device on the bus as needed without having to worry about the compatibility of new devices with existing systems; this greatly increases the flexibility of system configuration and future scalability; unified communication standards encourage device manufacturers to follow the same specifications, thereby promoting technological innovation and rapid market acceptance of products; this also helps reduce development costs and time, as manufacturers can focus on optimizing the unique features of their products rather than creating communication protocols from scratch.
[0038] In addition to compatibility, the present invention utilizes the 29-bit extended frame ID of the CAN2.0 standard to implement a variety of other functions, such as function code, source address, destination address, multi-frame flag, multi-frame end flag, redundancy check, error code, security check and serial number, and provides a variety of fields for users to use for security-related processing, which can provide more in-depth and accurate control of security-related processing.
[0039] In safety-critical situations such as the automotive industry, aerospace industry, etc., the safety-related content in the present invention plays a key role in node communication, enabling the control center to understand the status of each node, conduct deeper and more optimized regulation, and quickly respond to and resolve emergency situations.
[0040] Simulation Application:
[0041] The communication message verification effect is performed based on the present invention.
[0042] A normal communication message, sent from source address 0 to target address 1, non-redundant message, no error, total message length is 16 bytes, encoded according to the communication protocol encoding specification of the present invention, the first message ID sent is: 0x8004200
[0043] HEX 800 4200
[0044] DEC 134,234,624
[0045] OCT 1 000 041 000
[0046] BIN 1000 0000 0000 0100 0010 0000 0000
[0047] The second message ID sent is: 0x800620
[0048] HEX 800 6201
[0049] DEC 134,242,817
[0050] OCT 1 000 061 001
[0051] BIN 1000 0000 0000 0110 0010 0000 0001
[0052] Send an emergency message of a node error, from source address 1 to target address 0, which is a redundant message, with a total message length of 30 bytes. According to the communication protocol coding specification of the present invention, the first message ID sent is: 0x18205E00
[0053] HEX 1820 5E00
[0054] DEC 404,774,400
[0055] OCT 3 010 057 000
[0056] BIN 0001 1000 0010 0000 0101 1110 0000 0000
[0057] The second message ID sent is: 0x18205E01
[0058] HEX 1820 5E01
[0059] DEC 404,774,401
[0060] OCT 3 010 057 001
[0061] BIN 0001 1000 0010 0000 0101 1110 0000 0001
[0062] The third message ID sent is: 0x18205E01
[0063] HEX 1820 5E02
[0064] DEC 404,774,402
[0065] OCT 3 010 057 002
[0066] BIN 0001 1000 0010 0000 0101 1110 0000 0010
[0067] The fourth message ID sent is: 0x18205E01
[0068] HEX 1820 7E03
[0069] DEC 404,782,595
[0070] OCT 3 010 077 003
[0071] BIN 0001 1000 0010 0000 0111 1110 0000 0011.
Claims
1. A communication protocol encoding method based on CAN bus, defining the message ID based on the standard CAN2.0 extended frame, characterized in that: The CAN2.0 extended frame is defined as the corresponding function code, source address, destination address, multi-frame flag, end frame flag, redundancy check, error code, safety check and message sequence number.
2. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The function code refers to the type of message, indicating the function of the message, and has a length of 2 bits; the function code 00 is a heartbeat message, 01 is a normal communication message, 10 is a warning message, and 11 is an emergency message.
3. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The source address indicates the device address where the message originates and has a length of 6 bits.
4. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The destination address indicates the destination device address of the message, and has a length of 6 bits.
5. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The multi-frame flag indicates whether the frame is a single frame or multiple frames, and has a length of 1 bit.
6. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The end frame flag indicates whether it is the last frame of the message and has a length of 1 bit.
7. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The redundancy check indicates whether it is a redundant message, and its length is 1 bit. The redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
8. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The error code indicates error information and has a length of 2 bits. The error code 00 indicates a correct message, 01 indicates a request error message, 10 indicates a request unsupported message, and 11 indicates a node error message.
9. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The security check indicates whether it is a redundant message, and its length is 1 bit. The redundancy check, 0 indicates a non-redundant message, and 1 indicates a redundant message.
10. The communication protocol encoding method based on CAN bus according to claim 1, characterized in that: The message sequence number indicates the sequence number of the message, and its length is 8 bits.
