A method, system, device and storage medium for quickly reading and writing CAN communication messages

By using idle bits as identifiers in CAN messages, the data update situation is judged, and if there is no update, the previous message is copied to speed up the loading process, and only interpreting the update content to improve the decoding speed, the problem of low reading and writing speed of CAN messages in the prior art is solved, and more efficient information interaction is achieved.

CN119766906APending Publication Date: 2025-04-04GUANGXI XINGWANG ZHIYUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411800666.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The prior art has a low speed when reading and writing CAN communication packets, especially when the signal definition is relatively alternative or the data is large, resulting in complex and time-consuming construction of the model.

Method used

By selecting the idle bit in the data segment of the CAN message as an identifier of whether the data is the same, it is determined whether the content is updated. If there is no update, the previous message will be copied to speed up the loading process, and only the update content will be interpreted during decoding to improve the speed.

Benefits of technology

It significantly accelerates the reading and writing speed of CAN packets, reduces the complexity and time of model construction, and improves the efficiency of information interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766906A_ABST
    Figure CN119766906A_ABST
Patent Text Reader

Abstract

The present invention discloses a method, system, device and storage medium for fast reading and writing of CAN communication messages, belongs to the field of communication technology, and solves the technical problem of slow reading and writing speed of the existing EngineDriverRequestTorque message encoding process. The method is: in the data segment of the CAN message after the CANID, at least one idle bit is selected as an identifier of whether the data is the same; when encoding, the value of the parameter currently required to be loaded is compared with the same parameter value sent by the last load; if they are consistent, the current identifier is set to the first value, and the signal transmitted by the last load is copied for loading and sending; if they are inconsistent, the current identifier is set to the second value, and the whole process of message loading is completed and sent; when decoding, after reading the CANID, the identifier is read first; if the identifier is the first value, stop reading other bit data in the data segment; otherwise, continue to read other bit data in the data segment, which greatly speeds up the loading and interpretation speed of the message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and more specifically, to a method, system, device and storage medium for quickly reading and writing CAN communication messages. Background Art

[0002] like Figure 1 The figure shows the communication matrix definition of the vehicle engine signal EngineDriverRequestTorque. The conventional method of reading CAN messages is based on the communication matrix definition. Developers can extract the EngineDriverRequestTorque signal by building a simple model.

[0003] However, when the definition of the signal is more alternative or the signal data is more, the complexity of building the signal extraction model will be greatly increased, which is time-consuming and labor-intensive, and the reading and writing speed of CAN messages is low. Summary of the invention

[0004] The technical problem to be solved by the present invention is to address the above-mentioned deficiencies in the prior art. One purpose of the present invention is to provide a method for quickly reading and writing CAN communication messages.

[0005] A second object of the present invention is to provide a system for quickly reading and writing CAN communication messages.

[0006] A third object of the present invention is to provide a computer device.

[0007] A fourth objective of the present invention is to provide a computer storage medium.

[0008] In order to achieve the above-mentioned purpose one, the present invention provides a method for quickly reading and writing CAN communication messages, comprising the following steps:

[0009] Step 1. In the data segment of the CAN message following the CANID, select at least one free bit as an identifier of whether the data is identical;

[0010] Step 2. When encoding, compare the value of the parameter currently to be loaded with the same parameter value sent in the last load;

[0011] If they are consistent, the current identifier is set to the first value, and the signal of the last load transmission is copied after removing the identifier, and then the load transmission is performed;

[0012] If they are inconsistent, the current identifier is set to the second value, and the whole process of loading the message is completed and sent;

[0013] Step 3. When decoding, after reading the CANID, read the identifier first;

[0014] If the identifier is the first value, stop reading other bit data in the data segment;

[0015] If the identifier is the second value, continue reading other bit data in the data segment.

[0016] As a further improvement, the first value is 1 and the second value is 0.

[0017] Furthermore, after the loading and sending is completed, the sent data is stored in the corresponding message body and named as the last sent message for copying during the next encoding.

[0018] Furthermore, after the decoding is completed, the sent data is stored in the corresponding message body and named as the last parsed message for reference or calculation during the next decoding.

[0019] Furthermore, the first value is 11111, and the second value is 00000.

[0020] Further, encrypting and decrypting the identifier includes:

[0021] The identifier 11111 encryption process, the identifier 11111 indicates that the content of the previous and next messages is consistent; by inserting the special binary character 000, the digital conversion from 5-bit binary digits to 8-bit binary digits bit, the 000 character is inserted into the third, fourth and fifth bits from the left of the identifier, 11111 becomes 11000111;

[0022] During the decryption process of the identifier 11000111, the third, fourth and fifth digits are removed to restore the original identifier 11111;

[0023] The identifier 00000 encryption process, the identifier 00000 indicates that the previous and next message contents are inconsistent; by inserting the special binary character 111, the digital conversion is converted from a 5-bit binary number to an 8-bit binary number bit, and the 111 character is inserted into the third, fourth, and fifth positions from the left of the identifier, 00000 becomes 00111000;

[0024] During the decryption process of the identifier 00111000, the third, fourth and fifth digits are removed to restore the original identifier 00000.

[0025] Furthermore, the encrypted identifier is error checked, and the error checking adopts padding check, bit monitoring, format check, cyclic redundancy check and ACK check;

[0026] Padding check ensures synchronization, bit monitoring detects transmission errors, format check verifies message format, CRC check ensures data integrity, and ACK check confirms message reception;

[0027] When an error is detected, the CAN node will send an error signal and update the error counter; when an error is detected, the message will be resent; if an error still occurs after resending, it will be repeated again; the number of transmissions shall not exceed five times; if it reaches five times, an alarm will be issued to the sender and receiver, and it is recommended to check the line or surrounding environment.

[0028] In order to achieve the above-mentioned second objective, the present invention provides a system for quickly reading and writing CAN communication messages, comprising:

[0029] A selection module is used to select at least one idle bit in the data segment of the CAN message following the CANID as an identifier of whether the data is identical;

[0030] The encoding module is used to compare the value of the parameter to be loaded currently with the same parameter value sent last time when encoding; if they are consistent, the current identifier is set to the first value, and the signal transmitted last time is copied after removing the identifier, and then the loading is sent; if they are inconsistent, the current identifier is set to the second value, and the whole process of message loading is completed and sent;

[0031] The decoding module is used to read the identifier first after reading the CANID during decoding; if the identifier is the first value, stop reading other bit data in the data segment; if the identifier is the second value, continue reading other bit data in the data segment.

[0032] In order to achieve the third objective above, the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned method for quickly reading and writing CAN communication messages when executing the computer program.

[0033] In order to achieve the fourth objective above, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for quickly reading and writing CAN communication messages is implemented.

[0034] Beneficial Effects

[0035] Compared with the prior art, the present invention has the following advantages:

[0036] The present invention specifically judges and marks whether the content has been updated during the CAN message generation process; stores the messages that have been successfully sent; when it is judged that the content has not been updated, it is not necessary to complete the entire message loading process for the message, and only needs to copy the previous message, which greatly speeds up the message loading speed. The CAN message interpretation process also greatly increases the interpretation speed because only the updated content mark is interpreted. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 Define a graph for the communication matrix of the prior art;

[0038] Figure 2 A flowchart of the coding in the present invention;

[0039] Figure 3 This is a flowchart of decoding in the present invention. DETAILED DESCRIPTION

[0040] The present invention will be further described below with reference to the specific embodiments in the accompanying drawings.

[0041] From the above EngineDriverRequestTorque message encoding process, it can be seen that according to the conventional reading and encoding method, the process is relatively cumbersome.

[0042] During the information exchange between automobile controllers, many parameters often remain constant for a certain period of time.

[0043] See also Figure 2-3 , a method for quickly reading and writing CAN communication messages, comprising the following steps 1 to 5:

[0044] Step 1. In the data segment of the CAN message following the CANID, select at least one free bit as an identifier (flag) to indicate whether the data is identical.

[0045] Step 2: When encoding, compare the value of the parameter that needs to be loaded currently with the same parameter value sent in the last load.

[0046] If they are consistent, the current identifier is set to the first value, and the signal of the last loading transmission is copied after removing the identifier, and then loaded and sent. That is, there is no need to complete the whole message loading process for the message, only the previous message needs to be copied, which greatly speeds up the message loading speed.

[0047] If they are inconsistent, the current identifier is set to the second value, and the entire message loading process is completed and sent.

[0048] Step 3. When decoding, after reading the CANID, read the identifier first.

[0049] If the identifier is the first value, stop reading other bits of data in the data segment, that is, there is no need to continue interpreting the data, and only the content of the previously interpreted message needs to be used for reference or calculation.

[0050] If the identifier is the second value, continue to read other bits of data in the data segment, that is, all the data are interpreted.

[0051] In one embodiment, the first value is 1 and the second value is 0.

[0052] Specifically, after the loading and sending is completed, the sent data is stored in the corresponding message body and named as the last sent message for copying during the next encoding.

[0053] After decoding is completed, the sent data is stored in the corresponding message body and named as the last parsed message for reference or calculation during the next decoding.

[0054] In one embodiment, the first value is 11111 and the second value is 00000. Encrypting and decrypting the identifier includes:

[0055] The identifier 11111 encryption process, the identifier 11111 indicates that the content of the previous and subsequent messages is consistent; by inserting the special binary character 000, the digital conversion is converted from a 5-bit binary number to an 8-bit binary number bit (i.e. 1 byte), and the 000 character is inserted into the third, fourth, and fifth positions from the left of the identifier, and 11111 becomes 11000111.

[0056] During the decryption process of the identifier 11000111, the third, fourth and fifth digits are removed to restore the original identifier 11111.

[0057] In the encryption process of identifier 00000, the identifier 00000 indicates that the content of the previous and subsequent messages is inconsistent; by inserting the special binary character 111, the digital conversion is converted from a 5-bit binary number to an 8-bit binary number bit (i.e. 1 byte), and the 111 character is inserted into the third, fourth, and fifth positions from the left of the identifier, and 00000 becomes 00111000.

[0058] During the decryption process of the identifier 00111000, the third, fourth and fifth digits are removed to restore the original identifier 00000.

[0059] It is also necessary to perform error checking on the encrypted identifier, which uses padding check, bit monitoring, format check, cyclic redundancy check and ACK check.

[0060] The padding check ensures synchronization, the bit monitoring detects transmission errors, the format check verifies the message format, the CRC check ensures data integrity, and the ACK check confirms message reception.

[0061] When an error is detected, the CAN node will send an error signal and update the error counter; when an error is detected, the message will be resent; if an error still occurs after resending, it will be repeated again; the number of transmissions shall not exceed five times; if it reaches five times, which includes the first transmission and the repeated transmission, an alarm will be issued to the sender and receiver, and it is recommended to check the line or surrounding environment (for example, excessive electromagnetic interference).

[0062] The detailed definitions are as follows:

[0063] Padding check (receiver)

[0064] Stuffing check is used to check the bit stream. The CAN protocol stipulates that the sender must transmit the opposite bit after transmitting five identical bits in order to achieve synchronization. If more than five identical bits are received in succession, a stuffing error occurs.

[0065] Bit monitoring (sender)

[0066] Within the framework of bit monitoring, the sender compares the transmitted bit level with the actual bus level. If the sender detects a difference between the two levels, a bit error occurs. Bit monitoring ensures that all global errors and all local errors of the sender are detected.

[0067] Format check (receiver)

[0068] The format check is used to check the format of the CAN message. All CAN messages always present the same bit sequence at certain positions, namely the CRC delimiter, ACK delimiter and EOF. The sender always transmits these message parts at a recessive level. If the receiver detects a dominant bus level in one of the bits during the format check, a format error occurs.

[0069] Cyclic Redundancy Check (Receiver)

[0070] In the cyclic redundancy code, the polynomial R(x) associated with the received data frame or remote frame should be a multiple of the generator polynomial G(x) specified in ISO 11898-1. If it is not, a CRC error will occur, indicating that the data frame or remote frame has been corrupted during transmission.

[0071] ACK check (sender)

[0072] The response mechanism defined in the CAN protocol stipulates that all receivers must immediately respond to each received CAN message after completing the cyclic redundancy check. An ACK is sufficient to inform the sender that at least one receiver has correctly received the CAN message it sent. If the sender does not receive any ACK, an ACK error occurs.

[0073] A system for quickly reading and writing CAN communication messages, comprising:

[0074] A selection module is used to select at least one idle bit in the data segment of the CAN message following the CANID as an identifier of whether the data is identical;

[0075] The encoding module is used to compare the value of the parameter to be loaded currently with the same parameter value sent last time when encoding; if they are consistent, the current identifier is set to the first value, and the signal transmitted last time is copied after removing the identifier, and then the loading is sent; if they are inconsistent, the current identifier is set to the second value, and the whole process of message loading is completed and sent;

[0076] The decoding module is used to read the identifier first after reading the CANID during decoding; if the identifier is the first value, stop reading other bit data in the data segment; if the identifier is the second value, continue reading other bit data in the data segment.

[0077] A computer device comprises a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the method for quickly reading and writing CAN communication messages is implemented.

[0078] A computer-readable storage medium stores a computer program, which implements the above-mentioned method for quickly reading and writing CAN communication messages when executed by a processor.

[0079] For vehicles and agricultural machinery traveling and operating at a constant speed, the method of the present invention can effectively reduce the reading and filling time and reduce the CAN message receiving and solving process. Moreover, the present invention is a modification made in the conventional CAN reading and writing process, which can effectively utilize the existing technical confidentiality and software stability.

[0080] The above are only preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the structure of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent.

Claims

1. A method for quickly reading and writing CAN communication messages, characterized in that: The following steps are involved: Step 1. In the data segment of the CAN message following the CANID, select at least one free bit as an identifier of whether the data is identical; Step 2. When encoding, compare the value of the parameter currently to be loaded with the same parameter value sent in the last load; If they are consistent, the current identifier is set to the first value, and the signal of the last load transmission is copied after removing the identifier, and then the load transmission is performed; If they are inconsistent, the current identifier is set to the second value, and the whole process of loading the message is completed and sent; Step 3. When decoding, after reading the CANID, read the identifier first; If the identifier is the first value, stop reading other bit data in the data segment; If the identifier is the second value, continue reading other bit data in the data segment.

2. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: The first value is 1, and the second value is 0.

3. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: After the loading and sending is completed, the sent data is stored in the corresponding message body and named as the last sent message for copying during the next encoding.

4. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: After decoding is completed, the sent data is stored in the corresponding message body and named as the last parsed message for reference or calculation during the next decoding.

5. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: The first value is 11111, and the second value is 00000.

6. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: Encrypting and decrypting identifiers involves: The identifier 11111 encryption process, the identifier 11111 indicates that the content of the previous and next messages is consistent; by inserting the special binary character 000, the digital conversion from 5-bit binary digits to 8-bit binary digits bit, the 000 character is inserted into the third, fourth and fifth bits from the left of the identifier, 11111 becomes 11000111; During the decryption process of the identifier 11000111, the third, fourth and fifth digits are removed to restore the original identifier 11111; The identifier 00000 encryption process, the identifier 00000 indicates that the previous and next message contents are inconsistent; by inserting the special binary character 111, the digital conversion is converted from a 5-bit binary number to an 8-bit binary number bit, and the 111 character is inserted into the third, fourth, and fifth positions from the left of the identifier, 00000 becomes 00111000; During the decryption process of the identifier 00111000, the third, fourth and fifth digits are removed to restore the original identifier 00000.

7. A method for quickly reading and writing CAN communication messages according to claim 1, characterized in that: Perform error checking on the encrypted identifier, using padding check, bit monitoring, format check, cyclic redundancy check and ACK check; Padding check ensures synchronization, bit monitoring detects transmission errors, format check verifies message format, CRC check ensures data integrity, and ACK check confirms message reception; When an error is detected, the CAN node sends an error signal and updates the error counter; When an error is detected, the message will be resent; if an error still occurs after resending, it will be repeated again; The number of times sent shall not exceed five times; If it reaches five times, an alarm will be issued to the sender and receiver, and it is recommended to check the line or surrounding environment.

8. A system for quickly reading and writing CAN communication messages, characterized in that: include: A selection module is used to select at least one idle bit in the data segment of the CAN message following the CANID as an identifier of whether the data is identical; The encoding module is used to compare the value of the parameter currently to be loaded with the same parameter value sent last time when encoding; if they are consistent, the current identifier is set to the first value, and the signal of the last load transmission is copied after removing the identifier, and then the load is sent; If they are inconsistent, the current identifier is set to the second value, and the whole process of loading the message is completed and sent; The decoding module is used to read the identifier first after reading the CANID during decoding; if the identifier is the first value, stop reading other bit data in the data segment; if the identifier is the second value, continue reading other bit data in the data segment.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for quickly reading and writing CAN communication messages described in any one of claims 1-7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a method for quickly reading and writing CAN communication messages as described in any one of claims 1 to 7 is implemented.