Message transmission method and apparatus, and electronic device
Through dynamic packet grouping technology, multiple messages received from the CAN bus are converted into CANFD messages, solving the problems of low packet transmission efficiency and poor flexibility in the existing technology, achieving efficient and flexible message transmission, and reducing the development and maintenance costs of the gateway.
Patent Information
- Application Number
- CN202510059129.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, the efficiency and flexibility of message transmission are low and the flexibility of message transmission are especially in the conversion process between CAN and CANFD bus protocols. The fixed packet grouping method leads to waste of bandwidth and frequent changes in the communication matrix, which affects the efficiency and flexibility of message transmission.
By receiving multiple CAN messages from the CAN bus, the attribute information and data of each message are determined, and the message to be filled is determined based on the message length and the data field of the CANFD message. The dynamic group packet is filled into the CANFD message and sent to the CANFD bus.
It realizes that the CAN message ID is changed without changing the communication matrix, which improves the flexibility of message transmission, avoids bandwidth waste, reduces the development and maintenance costs of gateways, and improves the efficiency of data transmission.
Smart Images

Figure CN119945826A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of vehicles, and in particular to a message transmission method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the increase of intelligent and networked functions of automobiles, the number of on-board electronic and electrical components is increasing, the real-time requirements for information interaction between controllers are also getting higher and higher, and the vehicle load rate has reached the limit. The traditional CAN (Controller Area Network) bus transmission method can no longer meet the network communication of some models, so it is necessary to introduce the CANFD (CAN with Flexible Data-rate) bus for data transmission. Different bus protocols such as CAN and CANFD will exist in a network at the same time, and the gateway needs to realize the conversion of different bus protocols. The gateway usually needs to merge the CAN message group packets into CANFD messages for sending and receiving, which is used to reduce the vehicle load rate and ensure the communication quality of the vehicle.
[0003] The maximum data field capacity of CAN message can support 8 bytes, and the maximum data field capacity of CANFD message can support 64 bytes. The commonly used gateway message packetization method is to directly merge 8 frames of CAN messages from CAN message 1 to CAN message 8 into one frame of CANFD message. However, this packetization method requires the sender and receiver to develop according to a fixed communication matrix. When the CAN message ID of the CANFD message packet is changed, the communication matrix needs to be changed, which greatly affects the efficiency and flexibility of message transmission.
[0004] Therefore, how to improve the efficiency and flexibility of message transmission is a technical problem to be solved by those skilled in the art. Summary of the invention
[0005] In order to solve the problems of low efficiency and poor flexibility of message transmission in the prior art, the present invention provides a message transmission method, device, electronic device and computer-readable storage medium.
[0006] A message transmission method, comprising: Receive multiple CAN messages from a CAN bus, and determine attribute information and message data of each CAN message; the attribute information includes message length and message ID; Determine the message to be filled according to the message length of each CAN message and the data field of the CANFD message; Fill the attribute information and message data of the message to be filled into the CANFD message, and send the CANFD message to the CANFD bus.
[0007] Optionally, determining the message to be filled according to the message length of each CAN message and the data field of the CAN FD message includes: Accumulate the message lengths according to the order in which the CAN messages are received to obtain corresponding accumulation results; Determine the maximum value of the accumulated result that is less than or equal to the data field capacity of the CANFD message as the optimal value; The CAN message corresponding to the optimal value is determined as the message to be filled.
[0008] Optionally, the data field of the CAN FD message includes a data group and a check group, wherein: The data group includes at least one set of data sets; the data sets include attribute information and message data of the message to be filled; the number of the data sets is consistent with the number of the messages to be filled; The checksum includes a cycle count and a checksum.
[0009] Optionally, the attribute information also includes a protocol version; The filling of the attribute information and the message data of the message to be filled into the CANFD message includes: Convert the protocol version, message length and message ID of the message to be filled into binary data in sequence; storing the binary data of the protocol version in the first and second bits of the data set; storing the binary data of the message length in the third to fifth bits of the data set; storing the binary data of the message ID in the sixth to sixteenth bits of the data set; Sequentially fill the remaining bits of the data set with the message data of the message to be filled.
[0010] Optionally, the method further includes: When all the data sets have completed data filling, calculating a checksum based on the data in all the data sets; The cycle count is increased by one, and the cycle count and the checksum are filled into the check group.
[0011] Optionally, the method further includes: Receiving the CAN FD message from the CAN FD bus; Parsing the CANFD message to obtain attribute information and message data of each CAN message; Generate a corresponding CAN message according to the attribute information and message data of each CAN message, and send each CAN message to the CAN bus.
[0012] Optionally, after parsing the CAN FD message to obtain attribute information and message data of each CAN message, the method further includes: The attribute information and message data of each CAN message are uploaded to the server.
[0013] A message transmission device, comprising: A receiving module, used to receive multiple CAN messages from the CAN bus, and determine the attribute information and message data of each CAN message; the attribute information includes the message length and the message ID; A packetizing module, used to determine a packetizing mode of a CAN FD message according to the message length of each CAN message, and fill the attribute information and message data of the CAN message into the CAN FD message according to the packetizing mode; The sending module is used to send the CANFD message to the CANFD bus.
[0014] An electronic device, comprising: A processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the method for message transmission as described in any one of the above items is implemented.
[0015] A computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the message transmission method as described in any one of the above.
[0016] The message transmission method provided by the embodiment of the present invention determines the attribute information and message data of each CAN message, determines the message to be filled according to the message length of each CAN message and the data field of the CANFD message, and finally fills the attribute information and message data of the message to be filled into the CANFD message, and sends the CANFD message to the CANFD bus. The present invention flexibly combines multiple CAN messages into a CANFD message according to the message length and content of each message, thereby avoiding the bandwidth waste that may occur in the traditional fixed packet grouping method and improving the efficiency of data transmission. At the same time, through the dynamic packet grouping method, the CAN message ID is changed without changing the communication matrix, which greatly improves the flexibility of message transmission and reduces the development and maintenance costs of the gateway. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A schematic diagram of a gateway packaging method in the prior art; Figure 2 A flow chart of a message transmission method provided by an embodiment of the present invention; Figure 3 for Figure 2 A flowchart of a practical expression of S02 in a provided message transmission method; Figure 4 A schematic diagram of a gateway package assembly method provided by an embodiment of the present invention; Figure 5 for Figure 2 A flowchart of another practical expression of S02 in a message transmission method provided; Figure 6 A schematic diagram illustrating an example of a gateway package assembly method in the prior art; Figure 7 A schematic diagram of an example of a gateway package assembly method provided in an embodiment of the present invention; Figure 8 A flowchart of another message transmission method provided by an embodiment of the present invention; Fig. 9 A schematic diagram of the structure of a message transmission device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0020] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0022] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0023] With the increase of intelligent and networked functions of automobiles, the number of on-board electronic and electrical components is increasing, the real-time requirements for information interaction between controllers are also getting higher and higher, and the vehicle load rate has reached the limit. The traditional CAN (Controller Area Network) bus transmission method can no longer meet the network communication of some models, so it is necessary to introduce the CANFD (CAN with Flexible Data-rate) bus for data transmission. Different bus protocols such as CAN and CANFD will exist in a network at the same time, and the gateway needs to realize the conversion of different bus protocols. The gateway usually needs to merge the CAN message group packets into CANFD messages for sending and receiving, which is used to reduce the vehicle load rate and ensure the communication quality of the vehicle.
[0024] The maximum data field capacity of CAN message can support 8 bytes, and the maximum data field capacity of CANFD message can support 64 bytes. The commonly used gateway message packetization method is to directly merge 8 frames of CAN messages from CAN message 1 to CAN message 8 into one frame of CANFD message. Please refer to Figure 1 , is a schematic diagram of a gateway packet assembly method in the prior art. Figure 1 As shown, this packetization method requires the sender and the receiver to develop according to a fixed communication matrix. When the CAN message ID of the CAN FD message packet is changed, the communication matrix needs to be changed, which greatly affects the efficiency and flexibility of message transmission.
[0025] Therefore, the present invention provides a message transmission method for solving the above-mentioned problem.
[0026] Please refer to Figure 2 , which is a flow chart of a message transmission method provided by an embodiment of the present invention, comprises the following steps: Step S01, receiving multiple CAN messages from the CAN bus, and determining attribute information and message data of each CAN message.
[0027] The attribute information includes the message length and the message ID.
[0028] This embodiment involves monitoring and collecting multiple CAN messages from a CAN bus. These CAN messages contain communication information between various electronic control units inside the vehicle. This process can identify attribute information of each CAN message, such as message length and message ID, and extract message data carried by the CAN message.
[0029] This embodiment can dynamically process messages sent by different electronic control units. By identifying the attribute information of each message, the system can decide how to effectively combine or convert CAN messages into CANFD format to adapt to higher data transmission rates and larger data packet sizes. This not only improves the flexibility and efficiency of data transmission, but also enables optimized management of the vehicle's internal network and improves communication quality.
[0030] In some embodiments, the process of receiving multiple CAN messages from the CAN bus and determining the attribute information and message data of each CAN message mentioned in step S01 may include: 1) The gateway monitors the communication on the CAN bus through the CAN transceiver. Whenever the gateway detects a new CAN message, it uses the CAN controller to read the CAN message ID.
[0031] 2) The gateway parses the data field of the CAN message and extracts the message data carried by the CAN message. The message data may include the vehicle's speed, engine status, sensor readings, etc. The attribute information of the CAN message also includes the message length, which indicates how many bytes of valid information are contained in the message data. In this way, the gateway can accurately receive and understand multiple CAN messages from the CAN bus, providing a data basis for the subsequent combination of CANFD messages.
[0032] Step S02, determining the message to be filled according to the message length of each CAN message and the data field of the CAN FD message.
[0033] In this embodiment, the data field of the CAN FD message can support a longer data payload, up to 64 bytes, far exceeding the 8-byte limit of the traditional CAN message. The gateway selects the message to be filled in the CAN FD message from each CAN message according to the message length of each CAN message and the capacity of the CAN FD message data field.
[0034] In some embodiments, the data field capacity of the CAN FD message can be utilized to the maximum extent according to the message length of each CAN message, so that the remaining data field capacity of the CAN FD message is minimized, and the CAN message that meets this requirement is determined as the message to be filled. For example, assuming that the message lengths of CAN messages 1 to CAN messages 15 are 7 bytes, 7 bytes, 6 bytes, 6 bytes, 5 bytes, 5 bytes, 5 bytes, 5 bytes, 5 bytes, 5 bytes, 4 bytes, 4 bytes, 3 bytes, 3 bytes, 3 bytes, 3 bytes, respectively, it can be calculated that 7 +7 +6 +6 +5 +5 +5 +5 +5 +5 +4 +4=64, so CAN messages 1 to CAN messages 12 can be determined as messages to be filled.
[0035] This embodiment can dynamically adjust the filling strategy of the CANFD message according to the actual message length, ensuring that the data field of the CANFD message is fully utilized and avoiding space waste caused by the fixed packet grouping method. This flexibility enables the network to more effectively manage and allocate bandwidth resources according to real-time communication needs, especially when the network load is high or the data transmission demand changes greatly, which can significantly improve the response speed and stability of the network.
[0036] Step S03, filling the attribute information and message data of the message to be filled into the CANFD message, and sending the CANFD message to the CANFD bus.
[0037] In this embodiment, after determining the message to be filled, its attribute information and message data are placed in the data field of the CANFD message in an orderly manner according to the format requirements of the CANFD protocol to ensure that the data of all messages can be correctly encapsulated and will not be lost or erroneous when transmitted on the CAN FD bus. In this way, data that originally requires multiple CAN messages to be transmitted can be combined into one CAN FD message, thereby reducing the frequency of network communication, improving the efficiency of data transmission, and reducing the demand for network bandwidth.
[0038] This embodiment fills the attribute information together with the message data into the CANFD message, so that the receiver can dynamically process messages of different lengths and types according to the message length and message ID in the attribute information, and the whole process does not need to change the communication matrix. For example, suppose there are three messages to be filled, whose IDs are 0x111, 0x112 and 0x113, and the data lengths are 3 bytes, 5 bytes and 7 bytes respectively. The gateway first reads the attribute information and data of these messages, and then fills them into a 64-byte CANFD message according to the format requirements of the CANFD protocol. This CANFD message can contain a header indicating the total number and type of messages, followed by the ID and data of each CAN message.
[0039] With this method, even if the message ID changes, there is no need to update the communication matrix, because the structure of the CANFD message allows the receiver to dynamically parse out the ID and data of each CAN message. This reduces the development and maintenance costs of the gateway while increasing the flexibility of message transmission.
[0040] Based on the above technical scheme, the message transmission method provided by the embodiment of the present invention determines the attribute information and message data of each CAN message, and determines the message to be filled according to the message length of each CAN message and the data field of the CANFD message, and finally fills the attribute information and message data of the message to be filled into the CANFD message, and sends the CANFD message to the CANFD bus. The present invention flexibly combines multiple CAN messages into a CANFD message according to the message length and content of each message, thereby avoiding the bandwidth waste that may occur in the traditional fixed packet grouping method and improving the efficiency of data transmission. At the same time, through the dynamic packet grouping method, the CAN message ID is changed without changing the communication matrix, which greatly improves the flexibility of message transmission and reduces the development and maintenance costs of the gateway.
[0041] Please refer to Figure 3 ,for Figure 1 A flowchart of an actual performance of S02 in a method for message transmission is provided. In some embodiments, the process mentioned in step S02, determining the message to be filled according to the message length of each CAN message and the data field of the CANFD message, may specifically include the following: Figure 3 Steps shown: Step S11, accumulating the message lengths according to the order in which the CAN messages are received to obtain corresponding accumulation results.
[0042] In this embodiment, the message lengths are accumulated one by one according to the order in which the CAN messages are received. After each accumulation, the system will obtain a temporary sum, which represents the cumulative data length of all messages so far. By dynamically evaluating the current accumulated total length and comparing it with the data field capacity of the CANFD message, the gateway can determine in real time how many CAN messages can be included without exceeding the CANFD data field capacity. This accumulation process not only ensures the effective packaging of data, but also maximizes the data load of each CANFD message, thereby improving the transmission efficiency of the network.
[0043] At the same time, this method allows the gateway to adjust the packet assembly strategy according to the actual length and order of the received messages. Even if the message length changes or the message reception order is irregular, the gateway can adapt to these changes and find the optimal packet assembly solution, which helps to reduce network congestion and improve the reliability of data transmission.
[0044] Step S12, determining the maximum value of the accumulated results that are less than or equal to the data field capacity of the CAN FD message as the optimal value.
[0045] The purpose of this embodiment is to pack as many CAN messages as possible without exceeding the maximum data field capacity of the CAN FD message. Specifically, the gateway will continuously accumulate the length of the received CAN messages until the accumulated total length is close to or equal to the data field capacity of the CAN FD message.
[0046] During the accumulation process, the gateway records the results of each accumulation and searches for a maximum value among these results, which is less than or equal to the data field capacity of the CANFD message. This maximum value is regarded as the optimal value, which represents the maximum number of CAN messages that can be packaged without violating the data field capacity limit. By selecting this optimal value, the system can maximize the data utilization of each CANFD message and reduce the number of message transmissions required, thereby improving network transmission efficiency and reducing bandwidth usage.
[0047] Step S13, determining the CAN message corresponding to the optimal value as the message to be filled.
[0048] In this embodiment, after determining the optimal value, the gateway will identify the CAN message set corresponding to the optimal value as the message to be filled, that is, fill the message to be filled into the CAN FD message for transmission. This method ensures that the data field of the CAN FD message is fully utilized, while avoiding transmission errors or reduced efficiency caused by exceeding the data field capacity.
[0049] Based on the above technical solution, this embodiment allows the gateway to dynamically accumulate the message length according to the order in which the CAN messages are received, until the accumulated result reaches or approaches the data field capacity of the CANFD message. This accumulation process not only simplifies the packetization process, but also ensures the maximum utilization of the data field and reduces bandwidth waste caused by improper packetization.
[0050] Please refer to Figure 4 , is a schematic diagram of a gateway package assembly method provided by an embodiment of the present invention. Figure 4 As shown, the data field of the CANFD message may include a data group and a check group, wherein: The data group includes at least one set of data sets; the data sets include attribute information of the message to be filled and message data; the number of data sets is consistent with the number of messages to be filled; The checksum group includes the cycle count and the checksum.
[0051] On this basis, please refer to Figure 5 ,for Figure 1A flowchart of another practical embodiment of S02 in a method for message transmission is provided. In some embodiments, the attribute information may also include a protocol version. As mentioned in step S03, the attribute information and message data of the message to be filled are filled into the CANFD message, and the process may specifically include the following: Figure 3 Steps shown: Step S21, converting the protocol version, message length and message ID of the message to be filled into binary data in sequence.
[0052] In this embodiment, the gateway converts the attribute information of the message to be filled, that is, the protocol version, message length and message ID, into binary data, with the purpose of filling it into the specific bits of the CANFD message so that the receiver can correctly parse and identify the content and meaning of each message. This conversion not only ensures the consistency and accuracy of the data, but also improves the efficiency and reliability of data transmission.
[0053] Step S22, storing the binary data of the protocol version in the first and second bits of the data set.
[0054] Step S23, storing the binary data of the message length in the third to fifth bits of the data set.
[0055] Step S24, storing the binary data of the message ID in the sixth to sixteenth bits of the data set.
[0056] Step S25, sequentially filling the message data of the message to be filled into the remaining bits of the data set.
[0057] like Figure 4 As shown, this embodiment encodes the key attribute information of the CAN message into the CANFD message in a specific format and position, ensuring the structuring and standardization of the CAN FD message, making the transmission of the message in the network more efficient and reliable. Through this orderly encoding method, the receiver can quickly and accurately parse the attributes and data of each message, thereby improving the communication efficiency of the entire vehicle network. This sophisticated bit allocation strategy not only optimizes the storage and transmission of data, but also provides a solid communication foundation for the intelligence and networking of vehicles.
[0058] Step S26, when all data sets have completed data filling, calculate the checksum based on the data in all data sets.
[0059] In this embodiment, after all the attribute information and message data of the message to be filled are filled into the CAN FD message, the gateway will calculate the checksum. The checksum is an error detection mechanism that generates a fixed-length value by performing a specific mathematical operation (usually a sum or XOR operation) on all the data in the data set. The checksum can be appended to the end of the CANFD message or stored in a specific bit position so that the receiver can verify it. When the message is transmitted in the network and received by the receiver, the receiver will recalculate the checksum of the received data set using the same algorithm. If the calculated checksum matches the checksum attached to the message, this indicates that the data has not been tampered with or damaged during transmission, thereby verifying the integrity of the data.
[0060] Step S27, increase the cycle count by one, and fill the cycle count and the checksum into the check group.
[0061] In this embodiment, the cycle count is a mechanism for tracking the order in which packets are transmitted. Each time a new packet is ready to be sent, the cycle count is incremented. The check group is a portion of the packet that is used for error detection and verification of data integrity.
[0062] After the data is filled, the system calculates the checksum of the entire data set, which is a value obtained by performing a specific algorithm on all the data in the data set to detect whether errors occurred during data transmission. Then, the current value of the loop counter is increased by one, and the updated loop count and the just calculated checksum are filled into the checksum group of the data packet.
[0063] This check group is then sent to the CANFD bus along with the rest of the data packet. After receiving the data packet, the receiver extracts the cycle count and checksum from the check group, recalculates the checksum using the same algorithm, and compares it with the received checksum. If the two are consistent, it means that no error occurred during the transmission of the data packet. At the same time, by comparing the cycle count, the receiver can detect the loss or duplication of the data packet and take appropriate measures, such as requesting the retransmission of the lost data packet. This method improves the accuracy of data transmission and the reliability of the network, which is crucial for the stable operation of the automotive network.
[0064] Please refer to Figure 6 and Figure 7 , Figure 6 The figure is a schematic diagram showing an example of a gateway packaging method in the prior art. Figure 7 The schematic diagram is an example of a gateway package assembly method provided by an embodiment of the present invention. Figure 6 and Figure 7As shown, for the same CAN message, the gateway packetization method provided in the embodiment of the present invention can add the CAN message protocol version, message length, message ID, cycle count checksum information. Moreover, compared with the waste of CANFD message data field capacity by the existing gateway message packetization method, the gateway packetization method provided in the embodiment of the present invention can maximize the load rate optimization, and the data has high reliability, ensuring the quality of vehicle network communication. At the same time, the change of the packaged CAN message will not affect the software change of the receiving module, and the module software can adapt to multiple configuration models, realizing platformization.
[0065] Please refer to Figure 8 , is a flow chart of another message transmission method provided by an embodiment of the present invention, comprising the following steps: Step S31, receiving a CAN FD message from the CAN FD bus.
[0066] Step S32, parse the CAN FD message to obtain attribute information and message data of each CAN message.
[0067] In this embodiment, by parsing the CAN FD message and generating a corresponding CAN message based on its attribute information and message data, the method allows different parts of the vehicle network (which may only support the traditional CAN bus) to seamlessly receive and process data from the CAN FD bus. In this way, data compatibility and transmission continuity can be ensured even in a mixed network environment with different communication protocols.
[0068] Step S33, generating a corresponding CAN message according to the attribute information and message data of each CAN message, and sending each CAN message to the CAN bus.
[0069] In this embodiment, the parsed CAN message is sent to the CAN bus, so that all electronic control units in the entire vehicle network (including those directly connected to the CAN FD bus or directly connected to the CAN bus) can access and utilize this data. This method improves the flexibility and scalability of the network, while reducing the cost of network upgrades due to protocol incompatibility. In this way, the vehicle network can manage and utilize data more effectively, improving the overall communication efficiency and intelligence level.
[0070] On the basis of the above embodiments, in some embodiments, after parsing the CANFD message and obtaining the attribute information and message data of each CAN message, the attribute information and message data of each CAN message can also be uploaded to the server. This method makes it possible to remotely monitor the vehicle status. The server can receive and analyze these data in real time to facilitate vehicle maintenance and management. At the same time, the server can store a large amount of CAN message data to provide records for the vehicle's operating history. These data are of great value for fault diagnosis, performance evaluation, and predictive maintenance.
[0071] Please refer to Fig. 9 , is a schematic diagram of the structure of a message transmission device provided by an embodiment of the present invention. Fig. 9 As shown, the message transmission device may include: The receiving module 100 is used to receive multiple CAN messages from the CAN bus and determine the attribute information and message data of each CAN message; the attribute information includes the message length and the message ID; The packaging module 200 is used to determine the packaging method of the CAN FD message according to the message length of each CAN message, and fill the attribute information and message data of the CAN message into the CAN FD message according to the packaging method; The sending module 300 is used to send the CAN FD message to the CAN FD bus.
[0072] Based on the above embodiments, in some embodiments, the package assembly module 200 can be specifically used for: The message lengths are accumulated according to the order in which the CAN messages are received to obtain the corresponding accumulated results; The maximum value of the accumulated result that is less than or equal to the data field capacity of the CANFD message is determined as the optimal value; The CAN message corresponding to the optimal value is determined as the message to be filled.
[0073] Based on the above embodiments, in some embodiments, the data field of the CAN FD message includes a data group and a check group, wherein: The data group includes at least one set of data sets; the data sets include attribute information of the message to be filled and message data; the number of data sets is consistent with the number of messages to be filled; The checksum group includes the cycle count and the checksum.
[0074] Based on the above embodiments, in some embodiments, the attribute information further includes a protocol version; The package assembly module 200 can be specifically used for: Convert the protocol version, message length and message ID of the message to be filled into binary data in sequence; Store the binary data of the protocol version in the first and second bits of the data set; The binary data of the message length is stored in the third to fifth bits of the data set; The binary data of the message ID is stored in the sixth to sixteenth bits of the data set; Sequentially fill the remaining bits of the data set with the message data of the message to be filled.
[0075] Based on the above embodiments, in some embodiments, the package assembly module 200 may also be used for: When all data sets have completed data filling, the checksum is calculated based on the data in all data sets; The cycle count is incremented by one, and the cycle count and checksum are filled into the check group.
[0076] On the basis of the above embodiments, in some embodiments, the message transmission device may further include: A receiving module, used for receiving CANFD messages from the CANFD bus; The parsing module is used to parse the CANFD message to obtain the attribute information and message data of each CAN message; The message generation module is used to generate a corresponding CAN message according to the attribute information and message data of each CAN message, and send each CAN message to the CAN bus.
[0077] Based on the above embodiments, in some embodiments, the parsing module may also be used to: Upload the attribute information and message data of each CAN message to the server.
[0078] This embodiment provides an electronic device, including a processor and a memory, the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the above-mentioned message transmission method is implemented. Its execution method and beneficial effects are similar and will not be repeated here.
[0079] An embodiment of the present invention provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned message transmission method is implemented. Its execution method and beneficial effects are similar and will not be repeated here.
[0080] It should be noted that although the above describes the various steps in a specific order, it does not mean that the various steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently or even in a different order as long as the required functions can be achieved.
[0081] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for message transmission, characterized in that: include: Receive multiple CAN messages from the CAN bus, and determine attribute information and message data of each of the CAN messages; The attribute information includes message length and message ID; Determine the message to be filled according to the message length of each CAN message and the data field of the CANFD message; Fill the attribute information and message data of the message to be filled into the CANFD message, and send the CANFD message to the CANFD bus.
2. The method according to claim 1, characterized in that Determining the message to be filled according to the message length of each CAN message and the data field of the CANFD message includes: Accumulate the message lengths according to the order in which the CAN messages are received to obtain corresponding accumulation results; Determine the maximum value of the accumulated result that is less than or equal to the data field capacity of the CANFD message as the optimal value; The CAN message corresponding to the optimal value is determined as the message to be filled.
3. The method according to claim 2, characterized in that The data field of the CANFD message includes a data group and a check group, wherein: The data group includes at least one set of data sets; the data sets include attribute information and message data of the message to be filled; the number of the data sets is consistent with the number of the messages to be filled; The checksum includes a cycle count and a checksum.
4. The method according to claim 3, characterized in that The attribute information also includes a protocol version; The filling of the attribute information and the message data of the message to be filled into the CANFD message includes: Convert the protocol version, message length and message ID of the message to be filled into binary data in sequence; storing the binary data of the protocol version in the first and second bits of the data set; storing the binary data of the message length in the third to fifth bits of the data set; storing the binary data of the message ID in the sixth to sixteenth bits of the data set; Sequentially fill the remaining bits of the data set with the message data of the message to be filled.
5. The method according to claim 4, characterized in that The method further comprises: When all the data sets have completed data filling, calculating a checksum based on the data in all the data sets; The cycle count is increased by one, and the cycle count and the checksum are filled into the check group.
6. The method according to claim 1, characterized in that The method further comprises: Receiving the CAN FD message from the CAN FD bus; Parsing the CANFD message to obtain attribute information and message data of each CAN message; Generate a corresponding CAN message according to the attribute information and message data of each CAN message, and send each CAN message to the CAN bus.
7. The method according to claim 6, characterized in that After parsing the CAN FD message to obtain the attribute information and message data of each CAN message, the method further includes: The attribute information and message data of each CAN message are uploaded to the server.
8. A message transmission device, characterized in that: include: A receiving module, used for receiving a plurality of CAN messages from the CAN bus, and determining attribute information and message data of each of the CAN messages; The attribute information includes message length and message ID; A packetizing module, used to determine a packetizing mode of a CAN FD message according to the message length of each CAN message, and fill the attribute information and message data of the CAN message into the CAN FD message according to the packetizing mode; The sending module is used to send the CANFD message to the CANFD bus.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store at least one instruction, and when the instruction is loaded and executed by the processor, the method for message transmission as described in any one of claims 1 to 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, the method for message transmission as described in any one of claims 1 to 7 is implemented.