Data transmission method and apparatus, device, and storage medium
By configuring a preset routing table and verification mechanism, the inefficiency and stability issues caused by inconsistent ECU protocols in the automotive gateway are resolved, achieving efficient and stable data transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- DEEPAL AUTOMOBILE TECH CO LTD
- Filing Date
- 2023-07-31
- Publication Date
- 2026-07-03
AI Technical Summary
In automotive gateways, existing technologies often result in inefficient routing methods and high computational resource consumption when the ECU supports different protocols. Furthermore, the lack of exception handling mechanisms leads to unstable data transmission.
By configuring a preset routing table, querying routing information, and verifying the length and protocol type of business data, the system ensures that data is transmitted to the target ECU. It also employs message buffers and retransmission buffers for efficient and stable data routing.
It improves the efficiency of gateway routing processing, reduces computing resource consumption, ensures the stability and accuracy of data transmission, and avoids errors caused by ECUs not supporting protocol types.
Smart Images

Figure CN117014361B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle control technology, and more particularly to the field of automotive gateway technology, specifically to a data transmission method, apparatus, device, and storage medium. Background Technology
[0002] With the rapid development of automotive intelligence, the number of electronic control units (ECUs) in automotive controller area networks (CAN) is increasing. To meet the demands of vehicle communication data volume and speed, some ECUs support both the CAN protocol and the CAN with flexible data rate (CANFD) protocol.
[0003] When some ECUs only support the CAN protocol, while others support both CAN and CANFD protocols, the common CAN gateway routing method is to process the data at the application (APP) layer based on the protocol standard before sending it. This routing method tends to consume a lot of computing resources and is relatively inefficient. Summary of the Invention
[0004] This application provides a data transmission method, apparatus, device, and storage medium to at least improve the technical problem of high computational resource consumption and low efficiency when a gateway executes routing logic. The technical solution of this application is as follows:
[0005] According to a first aspect of this application, a data transmission method is provided, comprising: receiving a first message from a first network segment; the first message including a first message identifier corresponding to the first message and service data to be transmitted;
[0006] When a correspondence exists between a first network segment and a first packet identifier in the preset routing table, the data length of the service data, the protocol type of the first packet, and the protocol type of the first target ECU are verified. When the verification passes, the service data is transmitted to the first target ECU. The preset routing table includes correspondences between multiple network segments and multiple packet identifiers, as well as correspondences between multiple packet identifiers and multiple target ECUs. The first target ECU is used to represent the target ECU that has a correspondence with the first packet identifier in the preset routing table.
[0007] Based on the aforementioned technical means, this application can configure a preset routing table in the gateway. By querying the preset routing table, routing information can be obtained accurately and efficiently, thereby improving the efficiency of the gateway in executing routing processing logic and effectively reducing the consumption of computing resources. Furthermore, after obtaining the routing information, this application can verify the data length of the business data, the protocol type of the first message, and the protocol type of the first target ECU. This ensures stable data transmission while efficiently implementing data routing, avoiding data transmission errors caused by the first target ECU not supporting the protocol type of the first message.
[0008] In one possible implementation, the preset routing table further includes the protocol type of each target ECU; the method for verifying the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU specifically includes:
[0009] Parse the first message identifier to determine the protocol type of the first message, and read the protocol type of the first target ECU from the preset routing table;
[0010] If the protocol type of the first message is CAN protocol, the verification is considered successful;
[0011] If the protocol type of the first message is CANFD and the protocol type of the first target ECU is CANFD, the verification is considered successful.
[0012] When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is CAN protocol, the first message is parsed to determine the data length of the service data, and if the data length is greater than the preset length threshold, the verification is determined to fail, or if the data length is less than or equal to the preset length threshold, the verification is determined to pass.
[0013] Based on the above technical means, this application can accurately determine whether transmitting business data to the target ECU will cause a bus read error in the first target ECU, thereby effectively supporting the transmission of business data to the first target ECU and avoiding damage to the bus of the first target ECU.
[0014] In one possible implementation, the method for transmitting service data to a first target ECU specifically includes:
[0015] Determine the working status of the message buffer corresponding to the first target ECU;
[0016] When the working state corresponding to the message buffer is idle, the transmission configuration information carrying the service data is added to the message buffer to send the service data to the first target ECU.
[0017] Based on the above technical means, this application can directly write the service data to be transmitted into the message buffer corresponding to the first target ECU when the message types of the first message and the first target ECU are the same or different, so as to realize route transmission, improve the problem of low routing efficiency when the message types are different in general technology, and improve data transmission efficiency.
[0018] In one possible implementation, the preset routing table further includes protocol data unit identifiers for each target ECU; the data transmission method further includes:
[0019] When the working status corresponding to the message buffer is busy, the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU is added to the retransmission buffer to resend the service data to the first target ECU.
[0020] Based on the above technical means, this application can add the information of failed transmission to the retransmission buffer when the message buffer corresponding to the first target ECU is busy, so as to support the retransmission of service data and improve the stability and accuracy of the gateway when executing routing logic.
[0021] In one possible implementation, the preset routing table also includes mailbox identifiers for each target ECU; the method for resending service data to the first target ECU specifically includes:
[0022] Update the current storage location of the information buffer and add the mailbox identifier of the first target ECU to the current storage location;
[0023] When the current read position of the information buffer is inconsistent with the current storage position, the transmission configuration information is read from the retransmission buffer based on the mailbox identifier of the first target ECU, and the business data is transmitted to the first target ECU, and the current read position is updated.
[0024] Based on the above technical means, this application can determine whether the current read position and the current storage position of the information buffer are consistent, and then retransmit the transmission configuration information stored in the retransmission buffer to improve the stability and accuracy of the gateway when executing routing logic.
[0025] In one possible implementation, before adding the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU to the retransmission buffer, the data transmission method further includes:
[0026] The protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the service data are verified to obtain the verification result. The verification result is used to indicate whether it is allowed to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer, or not allowed to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer.
[0027] Based on the above technical means, this application can improve the stability and accuracy of the gateway when executing routing logic by setting a length verification mechanism to avoid abnormal information configuration situations that the gateway may face.
[0028] According to a second aspect provided in this application, a data transmission apparatus is provided, comprising: a receiving unit and a processing unit;
[0029] The receiving unit is configured to receive a first message from the first network segment; the first message includes a first message identifier corresponding to the first message and service data to be transmitted.
[0030] The processing unit is used to verify the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU when a correspondence between the first network segment and the first message identifier exists in the preset routing table, and to transmit the service data to the first target ECU when the verification passes; the preset routing table includes a correspondence between multiple network segments and multiple message identifiers, as well as a correspondence between multiple message identifiers and multiple target ECUs; the first target ECU is used to represent the target ECU that has a correspondence with the first message identifier in the preset routing table.
[0031] In one possible implementation, the preset routing table further includes the protocol type of each target ECU; the processing unit is specifically used for:
[0032] Parse the first message identifier to determine the protocol type of the first message, and read the protocol type of the first target ECU from the preset routing table;
[0033] If the protocol type of the first message is CAN protocol, the verification is considered successful;
[0034] If the protocol type of the first message is CANFD and the protocol type of the first target ECU is CANFD, the verification is considered successful.
[0035] When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is CAN protocol, the first message is parsed to determine the data length of the service data, and if the data length is greater than the preset length threshold, the verification is determined to fail, or if the data length is less than or equal to the preset length threshold, the verification is determined to pass.
[0036] In one possible implementation, the processing unit is specifically used for:
[0037] Determine the working status of the message buffer corresponding to the first target ECU;
[0038] When the working state corresponding to the message buffer is idle, the transmission configuration information carrying the service data is added to the message buffer to send the service data to the first target ECU.
[0039] In one possible implementation, the preset routing table also includes the protocol data unit identifier of each target ECU;
[0040] The processing unit is also used to add the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU in the retransmission buffer when the working state corresponding to the message buffer is busy, so as to resend the service data to the first target ECU.
[0041] In one possible implementation, the preset routing table further includes mailbox identifiers for each target ECU; the processing unit is specifically used for:
[0042] Update the current storage location of the information buffer and add the mailbox identifier of the first target ECU to the current storage location;
[0043] When the current read position of the information buffer is inconsistent with the current storage position, the transmission configuration information is read from the retransmission buffer based on the mailbox identifier of the first target ECU, and the business data is transmitted to the first target ECU, and the current read position is updated.
[0044] In one possible implementation, the processing unit is further configured to verify the protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the service data, and obtain a verification result; the verification result is used to indicate whether it is permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer, or not permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer.
[0045] According to a third aspect provided in this application, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement the method of the first aspect described above and any possible implementation thereof.
[0046] According to a fourth aspect provided in this application, a computer-readable storage medium is provided that, when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the methods described in the first aspect and any possible implementation thereof.
[0047] According to the fifth aspect provided in this application, a computer program product is provided, the computer program product including computer instructions, which, when executed on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.
[0048] Therefore, the above-mentioned technical features of this application have the following beneficial effects:
[0049] (1) This application can configure a preset routing table in the gateway, and obtain routing information accurately and efficiently by querying the preset routing table, thereby improving the efficiency of the gateway in executing routing processing logic and effectively reducing the consumption of computing resources. Furthermore, after obtaining the routing information, this application can verify the data length of the business data, the protocol type of the first message, and the protocol type of the first target ECU. This can ensure the stability of data transmission while efficiently implementing data routing, and avoid data transmission errors caused by the first target ECU not supporting the protocol type of the first message.
[0050] (2) This application can accurately determine whether transmitting business data to the target ECU will cause a bus read error in the first target ECU, thereby effectively supporting the transmission of business data to the first target ECU and avoiding damage to the bus of the first target ECU.
[0051] (3) When the message types of the first message and the first target ECU are the same or different, this application can directly write the service data to be transmitted into the message buffer corresponding to the first target ECU to realize route transmission, improve the problem of low routing efficiency when the message types are different in general technology, and improve data transmission efficiency.
[0052] (4) When the message buffer corresponding to the first target ECU is busy, the application can add the information of failed transmission to the retransmission buffer to support the retransmission of service data and improve the stability and accuracy of the gateway when executing routing logic.
[0053] (5) This application can determine whether the current read position and the current storage position of the information buffer are consistent, and retransmit the transmission configuration information stored in the retransmission buffer to improve the stability and accuracy of the gateway when executing routing logic.
[0054] (6) This application can avoid abnormal information configuration situations that the gateway may face by setting a length verification mechanism, thereby improving the stability and accuracy of the gateway when executing routing logic.
[0055] It should be noted that the technical effects of any of the implementation methods in aspects two through five can be found in the technical effects of the corresponding implementation methods in aspect one, and will not be repeated here.
[0056] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0057] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application, and do not constitute an undue limitation of this application.
[0058] Figure 1 This is a schematic diagram illustrating a routing logic according to an exemplary embodiment;
[0059] Figure 2 This is a schematic diagram illustrating a data transmission method according to an exemplary embodiment;
[0060] Figure 3 This is a schematic diagram illustrating a routing table lookup process according to an exemplary embodiment;
[0061] Figure 4 This is a schematic diagram illustrating an information configuration process according to an exemplary embodiment;
[0062] Figure 5 This is a schematic diagram illustrating yet another data transmission method according to an exemplary embodiment;
[0063] Figure 6 This is a schematic diagram illustrating yet another data transmission method according to an exemplary embodiment;
[0064] Figure 7 This is a schematic diagram illustrating a retransmission process according to an exemplary embodiment;
[0065] Figure 8 This is a schematic diagram illustrating a retransmission information caching process according to an exemplary embodiment;
[0066] Figure 9 This is a schematic diagram illustrating the structure of a routing table according to an exemplary embodiment;
[0067] Figure 10 This is a schematic diagram illustrating a routing process according to an exemplary embodiment;
[0068] Figure 11 This is a schematic diagram illustrating yet another routing logic according to an exemplary embodiment;
[0069] Figure 12 This is a block diagram illustrating a data transmission apparatus according to an exemplary embodiment;
[0070] Figure 13 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation
[0071] To enable those skilled in the art to better understand the technical solutions of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0072] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0073] With the rapid development of automotive intelligence, the number of ECUs in automotive CAN is increasing. The efficient and low-error routing capabilities of the gateway are crucial for the communication stability of the entire vehicle's CAN network and even driving safety. To meet the demands of the vehicle's communication data volume and speed, some ECUs support both the CAN protocol and the CANFD protocol.
[0074] In cases where some ECUs only support the CAN protocol, while others support both CAN and CANFD protocols, the common CAN gateway routing method typically involves processing the data at the application layer based on the protocol standard before transmission. Specifically, combining... Figure 1 This method typically involves receiving messages from the CAN layer, then disassembling and parsing them step-by-step through the CAN interface (CANIF) layer, protocol data unit router (PDUR) layer, and cluster communication port (COM) layer. The messages are then transmitted by the runtime environment (RTE) module to the APP layer for processing, and further distributed and reassembled through the COM layer, PDUR layer, and CANIF layer before finally being sent by the CAN layer. This routing method has overly complex processing logic, consumes significant computing resources, and is inefficient.
[0075] To improve gateway routing efficiency, a common technique involves directly forwarding packets to the receiving node when the bus types of the sending and receiving nodes are the same, without further processing. When the bus types differ, processing follows a pre-defined logic. This logic requires acquiring network segment signals and bytes for calculations when processing different packet types, and then distinguishing between different routing methods based on the calculation results. However, this pre-defined logic is not concise. Therefore, when gateways face large amounts of diverse data, it is difficult to effectively improve gateway routing efficiency compared to the original routing logic, nor does it significantly reduce computational resource consumption. Furthermore, this common technique lacks a corresponding exception handling mechanism to improve the accuracy of gateway routing.
[0076] To address the aforementioned issues, this application proposes a data transmission method. After receiving a first message from a first network segment, if a correspondence exists between the first network segment and the first message identifier in a preset routing table, the method verifies the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU. If the verification passes, the service data is transmitted to the first target ECU. Based on this, this application can configure a preset routing table in the gateway, accurately and efficiently obtaining routing information by querying the preset routing table, thereby improving the efficiency of the gateway in executing routing processing logic and effectively reducing computational resource consumption. Furthermore, after obtaining the routing information, this application can verify the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU. This ensures stable data transmission while efficiently implementing data routing, avoiding data transmission errors caused by the first target ECU not supporting the protocol type of the first message.
[0077] For ease of understanding, the data transmission method provided in this application will be described in detail below with reference to the accompanying drawings.
[0078] Figure 2 This is a flowchart illustrating a data transmission method according to an exemplary embodiment, such as... Figure 2 As shown, the data transmission method includes the following steps: S101-S102.
[0079] S101, The gateway receives the first message from the first network segment.
[0080] The first message may include the first message identifier corresponding to the first message and the service data to be transmitted.
[0081] In one possible approach, the gateway can be a gateway deployed within the vehicle's CAN bus, also known as a CAN gateway. Multiple ECUs can also be deployed within the vehicle's CAN bus. Different ECUs can be used to control different modules of the vehicle (such as the engine and battery). Furthermore, different ECUs can collaborate through data exchange to provide stability and comfort during vehicle operation.
[0082] In a CAN bus, different ECUs can be configured with different network segments. This means the gateway can receive messages from different ECUs based on different network segments and transmit the data from those messages to other ECUs, enabling data exchange between them. When one ECU sends data to one or more other ECUs through a gateway, that ECU can be called the source ECU, and the other ECUs can be called the target ECUs. The message sent by the source ECU typically includes a message identifier. This message identifier is used to identify the target ECU for that message.
[0083] In one possible approach, the first message can be a message sent from any source ECU to the gateway. The first network segment is the network segment configured for that source ECU. The first message identifier can be used to identify the target ECU corresponding to the first message.
[0084] In one possible approach, the service data to be transmitted could be engine speed data, or battery remaining power data, etc.
[0085] In one possible implementation, the first source ECU can send a first message to the gateway on the first network segment. Correspondingly, the gateway can receive the first message from the first source ECU on the first network segment, parse the first message, and obtain the first message identifier and the service data to be transmitted.
[0086] In one possible approach, the first message identifier can be used to represent the CAN identity document (CANID) corresponding to the first message.
[0087] In one possible way, such as Figure 3 As shown, after the gateway receives the first message, the routing table lookup process may include S1011-S1012.
[0088] S1011. The gateway traverses multiple network segments in the preset routing table based on the first network segment of the received first message to find the source message network segment. If the source message network segment lookup fails, the routing table lookup also fails.
[0089] The preset routing table can include the mapping between multiple network segments and multiple message identifiers, as well as the mapping between multiple message identifiers and multiple target ECUs. Message identifiers can also be called source message CANIDs. The preset routing table may also include relevant information for each ECU (such as protocol type).
[0090] S1011. The gateway traverses the CANIDs of each source message under the corresponding network segment in the preset routing table according to the CANID of the first message. If the query is successful, the routing table query is successful; otherwise, the routing table query fails. If the query is successful, the relevant information of the target ECU can be obtained.
[0091] After the gateway obtains the relevant information of the target ECU corresponding to the first message, it can further transmit business data to the target ECU corresponding to the first message.
[0092] S102. When the gateway has a correspondence between the first network segment and the first message identifier in the preset routing table, it verifies the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU, and transmits the service data to the first target ECU when the verification passes.
[0093] In one possible approach, the first target ECU can be used to represent a target ECU that corresponds to the first packet identifier in a preset routing table, and there can be multiple first target ECUs. When there are multiple first target ECUs, the gateway can sequentially execute the processing logic of S102 on each first target ECU.
[0094] In practical applications, the gateway serves as the core of the vehicle's CAN network, handling over 50% of the vehicle's messages. The gateway's efficient and low-error routing capabilities are crucial for the communication stability of the vehicle's CAN network and even driving safety. Therefore, gateway design not only needs to consider how to efficiently handle massive amounts of data but also how to accurately route CAN and CANFD type messages. Currently, in the automotive open system architecture (AUTOSAR), the primary routing method involves disassembling and parsing all received messages at each level of the CAN layer, then reassembling and sending them from the APP layer before finally transmitting them from the CAN layer. While this routing logic can accurately route CAN and CANFD type messages, the process is overly lengthy and consumes significant computing resources, hindering the gateway's efficient handling of massive data volumes.
[0095] In a CAN network, messages are typically divided into messages used to transmit signaling data (hereinafter referred to as "signaling messages") and messages used to transmit service data (hereinafter referred to as "data messages"). Considering that signaling messages generally require the APP layer to implement relevant control logic, routing can be performed based on a combination of the CAN layer and the APP layer. For messages transmitting service data, routing based on this combination of CAN layer and APP layer is not necessary. Instead, after unpacking and parsing at the CAN layer, the CANIF layer can perform logical judgments and directly transmit the data to the target ECU, avoiding the inefficiency caused by processing by the APP layer.
[0096] Based on this, we consider pre-configuring the routing logic for multiple data packets using a preset routing table. This involves configuring the mapping between multiple network segments and multiple packet identifiers, as well as the mapping between multiple packet identifiers and multiple target ECUs, in the preset routing table. Each packet identifier corresponds one-to-one with a specific data packet.
[0097] After receiving the first packet from the first network segment, the gateway can parse the first packet to obtain the first packet identifier corresponding to the first packet, and further determine whether there is a correspondence between the first network segment and the first packet identifier in the preset routing table.
[0098] If there is no correspondence between the first network segment and the first packet identifier in the preset routing table, it indicates that the first packet is not a data packet and routing needs to be performed based on the combination of the CAN layer and the APP layer. In this case, the gateway can disassemble and parse the first packet step by step from the CAN layer, then send it down and reassemble it step by step from the APP layer, and finally send it from the CAN layer.
[0099] If a correspondence exists between the first network segment and the first packet identifier in the preset routing table, it indicates that the first packet is a data packet. In this case, the gateway can identify the target ECU corresponding to the first packet identifier in the preset routing table as the first target ECU, and further verify the data length of the service data, the protocol type of the first packet, and the protocol type of the first target ECU to determine whether the first target ECU supports parsing the first packet.
[0100] If the verification fails, it indicates that the first target ECU does not support parsing the first message. In this case, the gateway can terminate the routing process for the first message and output a message indicating that the routing of the first message failed. If the verification passes, it indicates that the first target ECU supports parsing the first message. In this case, the gateway can transmit service data to the first target ECU.
[0101] In one possible way, such as Figure 4 As shown, when the gateway transmits service data to the first target ECU, the target message can be configured based on the process of S1021-S1022.
[0102] S1021. The gateway configures the business data and data length of the target message based on the business data and the byte length of the business data in the first message.
[0103] Specifically, the gateway can set the service data of the first message to the service data corresponding to the target message, and set the data length of the target message to be the same as the byte length of the service data of the first message.
[0104] S1022. If the protocol type of the target message is CANFD, the gateway sets the CANID of the target message to the first identifier; or, if the protocol type of the target message is CAN, the gateway sets the CANID of the target message to the second identifier.
[0105] The first identifier can be 0x40000A. The second identifier can be 0x00000A. A is used to represent the sum between the first message identifier and 0x7FF.
[0106] In some embodiments, in order to verify the data length of the business data, the protocol type of the first message, and the protocol type of the first target ECU, this application embodiment provides an optional implementation method, including: S201-S204.
[0107] S201. The gateway parses the first message identifier to determine the protocol type of the first message, and reads the protocol type of the first target ECU from the preset routing table.
[0108] The preset routing table can also include the protocol type of each target ECU.
[0109] In one possible approach, the preset routing table may include the CANFD flag for each target ECU. The CANFD flag can be used to indicate whether the target ECU's protocol type is CANFD or not. If the CANFD flag indicates that the target ECU's protocol type is not CANFD, then the target ECU's protocol type can be CAN. Based on this, the gateway can read the CANFD flag of the first target ECU from the preset routing table to determine the first target ECU's protocol type.
[0110] In one possible implementation, the gateway can parse the first message identifier to determine the protocol type of the first message. Specifically, the gateway can parse the received first message through the CANIF layer to determine the first message identifier. The first message identifier can be a 32-bit CANID. If the 30th bit (binary digit, BIT) is 1, the gateway can determine that the protocol type of the first message is CANFD. If the 30th bit is 0, the gateway can determine that the protocol type of the first message is CAN.
[0111] S202. When the protocol type of the first message is CAN protocol, the gateway determines that the verification is successful.
[0112] In one possible approach, the CANFD protocol is compatible with the CAN protocol. That is, an ECU that supports the CANFD protocol can also support the CAN protocol. Based on this, if the gateway determines that the protocol type of the first message is CAN, it indicates that regardless of whether the protocol type of the first target ECU is CANFD or CAN, it can support parsing the first message. In this case, the gateway can determine that the verification has passed.
[0113] S203. When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is CANFD protocol, the gateway determines that the verification is successful.
[0114] In one possible scenario, the CAN protocol is not well-compatible with the CANFD protocol. Specifically, the CAN protocol supports a data length of 8 bytes, while the CANFD protocol offers more flexible data frame lengths (frames recording service data), which can be 8 bytes or longer. That is, the CANFD protocol supports data lengths of 8 bytes, 16 bytes, 64 bytes, etc. In this case, an ECU configured with the CAN protocol can be compatible with CANFD protocol messages with a data length of 8 bytes, but not with CANFD protocol messages with a data length greater than 8 bytes.
[0115] Therefore, if the gateway determines that the protocol type of the first message is CANFD, it needs to further determine the protocol type of the first target ECU. If the gateway further determines that the protocol type of the first target ECU is CANFD, it indicates that the protocol type of the first target ECU is the same as the protocol type of the first message, and the first target ECU can support parsing the first message. In this case, the gateway can determine that the verification has passed.
[0116] If the gateway further determines that the protocol type of the first target ECU is CAN protocol, then it is necessary to further determine whether the first target ECU can support parsing the first message based on the data length of the service data in the first message.
[0117] S204. When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is CAN protocol, the gateway parses the first message to determine the data length of the service data, and determines that the verification fails when the data length is greater than the preset length threshold, or determines that the verification passes when the data length is less than or equal to the preset length threshold.
[0118] In one possible approach, the preset length threshold can be set reasonably by the staff according to the specifications of the CANFD protocol and the CAN protocol. For example, the preset length threshold could be 8 bytes.
[0119] In one possible approach, if the protocol type of the first message is CANFD and the protocol type of the first target ECU is CAN, the gateway can parse the first message to determine the data length of the service data and compare the data length of the service data in the first message with a preset length threshold.
[0120] If the length of the service data in the first message exceeds a preset length threshold, it indicates that the first target ECU does not support parsing the first message. In this case, the gateway can determine that the verification failed.
[0121] If the length of the service data in the first message is less than or equal to a preset length threshold, it indicates that the first target ECU supports parsing the first message. In this case, the gateway can confirm that the verification has passed.
[0122] In some embodiments, such as Figure 5 As shown, when the gateway transmits service data to the first target ECU, this application embodiment provides an optional implementation method, including: S301-S302.
[0123] S301, The gateway determines the working status of the message buffer corresponding to the first target ECU.
[0124] In one possible approach, the gateway can determine the address information of the message buffer corresponding to the first target ECU, and further read the status value corresponding to the address information of the message buffer to determine the working status of the message buffer corresponding to the first target ECU.
[0125] Optionally, the working state of the message buffer corresponding to the first target ECU can be idle or busy.
[0126] Optionally, the preset routing table may also store the address information of the message buffer corresponding to each target ECU. Based on this, the gateway can read the address information of the message buffer corresponding to the first target ECU from the preset routing table.
[0127] Alternatively, the preset routing table can store mailbox identifiers corresponding to each target ECU. The gateway can also store multiple network configuration information entries, each corresponding one-to-one with the node identifiers (also known as CANIDs) of multiple target ECUs. The network configuration information can include the buffer base address (also known as the message buffer) of the network segment corresponding to the target ECU. Based on this, the gateway can determine the node identifier of the first target ECU and, based on the determined node identifier, read the buffer base address of the network segment corresponding to the first target ECU. Furthermore, the gateway can read the mailbox identifier corresponding to the first target ECU from the preset routing table and, based on the mailbox identifier, obtain the offset address of the first target ECU relative to the buffer base address of its corresponding network segment. Thus, the gateway can add the buffer base address of the network segment corresponding to the first target ECU to the offset address of the first target ECU to obtain the address information of the message buffer corresponding to the first target ECU.
[0128] In one possible approach, the gateway can determine the node identifier of the first target ECU based on its protocol type and the first message identifier. Specifically, if the protocol type of the first target ECU is CANFD, the gateway can determine the node identifier of the first target ECU as 0x40000A. If the protocol type of the first target ECU is CAN, the gateway can determine the node identifier of the first target ECU as 0x00000A. Here, A represents the sum of the first message identifier and 0x7FF.
[0129] S302. When the working state corresponding to the message buffer is idle, the gateway adds the transmission configuration information carrying the service data to the message buffer to send the service data to the first target ECU.
[0130] In one possible approach, if the message buffer's corresponding working state is idle, it indicates that the message buffer corresponding to the first target ECU is currently unused, and service data can be transmitted through the first target ECU's message buffer. In this case, the gateway can generate transmission configuration information carrying the service data and add this information to the message buffer to send the service data to the first target ECU.
[0131] Specifically, the gateway can write service data into the register according to the standard definition of the data length code (DLC). The length of the service data written into the register is generally the same as the length of the service data in the first message. The transmission configuration information may also include the node identifier of the first target ECU, the protocol type of the first target ECU, the transmission status, and other bit definition information. After the transmission configuration information is successfully added, when an interrupt query finds that the transmission configuration information to be sent exists in the message buffer, it can automatically send the transmission configuration information to the CAN bus of the first target ECU. At this point, the routing process for the first message is completed, and the gateway can report a routing success message.
[0132] In some embodiments, combined with Figure 5 ,like Figure 6 As shown, the data transmission method provided in this application embodiment further includes: S401.
[0133] S401. When the working status corresponding to the message buffer is busy, the gateway adds the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU in the retransmission buffer so as to resend the service data to the first target ECU.
[0134] In one possible approach, staff can pre-configure a retransmission buffer within the gateway. This retransmission buffer can be a global buffer used to retransmit target ECU information according to the target ECU's protocol data unit identifier record, and can be used to store information that can be retransmitted (e.g., transmission configuration information).
[0135] In one possible approach, the pre-defined routing table may also include the protocol data unit identifier for each target ECU. The protocol data unit identifier may be an index identifier used when the message is processed at the CANIF layer.
[0136] Therefore, if the message buffer's operating status is busy, it indicates that the message buffer corresponding to the first target ECU is currently in use, and service data cannot be transmitted through the first target ECU's message buffer. In this case, the gateway can add the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU to the retransmission buffer to resend service data to the first target ECU.
[0137] In some embodiments, when the gateway resends service data to the first target ECU, this application embodiment provides an optional implementation method, including: S501-S502.
[0138] S501, the gateway updates the current storage location of the information buffer and adds the mailbox identifier of the first target ECU to the current storage location.
[0139] In one possible approach, staff can pre-configure an information buffer within the gateway. This information buffer could be a global buffer used to record retransmitted information, or it could be used to determine if there is information that needs to be retransmitted (e.g., configuration information).
[0140] In one possible approach, the mailbox identifier could be an index identifier used when the message is processed at the CAN layer.
[0141] Specifically, the gateway can determine whether there is information that needs to be retransmitted by comparing the current storage location and the current read location of the information buffer. That is, if the current storage location and the current read location of the information buffer are the same, the gateway can determine that there is no information that needs to be retransmitted. If the current storage location and the current read location of the information buffer are different, the gateway can determine that there is information that needs to be retransmitted.
[0142] In one possible approach, after the gateway adds the mapping between the transmission configuration information and the protocol data unit identifier of the first target ECU to the retransmission buffer, it can update the current storage location of the information buffer. This involves adding a new storage location to the current storage location to obtain the updated current storage location, and then adding the mailbox identifier of the first target ECU to this updated current storage location. Subsequently, the gateway can retransmit service data based on the mailbox identifier of the first target ECU stored in this updated current storage location.
[0143] S502. When the current read position of the information buffer is inconsistent with the current storage position, the gateway reads the transmission configuration information from the retransmission buffer based on the mailbox identifier of the first target ECU, transmits the business data to the first target ECU, and updates the current read position.
[0144] In one possible approach, the gateway can periodically send confirmations, i.e., determine whether the current read position of the information buffer is consistent with the current storage position. If the current storage position and the current read position of the information buffer are inconsistent, the gateway can determine that there is information that needs to be retransmitted. In this case, the gateway can read the mailbox identifier of the first target ECU in the current storage position, and further determine the protocol data unit identifier of the first target ECU based on the mailbox identifier of the first target ECU. Thus, it can read the transmission configuration information corresponding to the protocol data unit identifier of the first target ECU in the retransmission buffer. Based on this, the gateway can again determine the working status of the message buffer corresponding to the first target ECU, and further execute S302 or S401 to transmit service data to the first target ECU.
[0145] After reading the transmission configuration information corresponding to the protocol data unit identifier of the first target ECU, the gateway can update the current read position of the information buffer to match the current storage position. Subsequently, the gateway can determine that there is no information that needs to be retransmitted by confirming that the current storage position and the current read position of the information buffer are consistent.
[0146] In one possible approach, the execution logic of S401 and S501-S502 can be understood as a gateway routing failure handling mechanism, which is part of the overall gateway design. S501-S502 can also rely on other functional modules to complete its operation and achieve information retransmission. To minimize routing latency while implementing retransmission, the execution logic of S501-S502 can be deployed within the ECU's normal CAN transmission confirmation processing module, and the gateway can call this processing module to execute S501-S502.
[0147] It should be noted that in a CAN network, the period for sending acknowledgments is relatively short, meaning that the frequency of sending acknowledgments is high. Therefore, retransmission will not cause excessive routing delays.
[0148] In one possible way, such as Figure 7 As shown, a retransmission process provided in an embodiment of this application includes: S5021-S5023.
[0149] S5021, The gateway obtains the current read position and current storage position of the information buffer.
[0150] S5022. The gateway determines whether the current read position and the current storage position are consistent. If they are consistent, the retransmission process ends. If they are inconsistent, the gateway reads the transmission configuration information and transmits the service data to the first target ECU.
[0151] S5023, Current read position of the gateway update information buffer.
[0152] In some embodiments, before the gateway adds the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU in the retransmission buffer, the data transmission method provided in this application embodiment further includes: S601.
[0153] S601, The gateway verifies the protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the business data, and obtains the verification result.
[0154] The verification result can be used to indicate whether adding the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer is allowed, or whether adding the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer is not allowed.
[0155] In one possible approach, the gateway may be pre-configured with standard definitions for the byte length of the protocol data unit identifier, the byte length of the mailbox identifier, the data length of the service data corresponding to the CAN protocol, and the data length of the service data corresponding to the CANFD protocol.
[0156] Based on this, in order to improve the stability and security of the data transmission process, the gateway can verify the protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the business data to determine whether the byte length of the protocol data unit identifier of the first target ECU conforms to the standard definition, whether the byte length of the mailbox identifier of the first target ECU conforms to the standard definition, and whether the data length of the business data conforms to the standard definition, and obtain the verification result.
[0157] If the protocol data unit identifier, mailbox identifier, and service data of the first target ECU all conform to the preset standard definition, the gateway can determine that the verification result allows the addition of transmission configuration information and the correspondence between the first target ECU in the retransmission buffer.
[0158] If one or more of the protocol data unit identifier, mailbox identifier, and service data of the first target ECU do not conform to the preset standard definition, the gateway can determine that the verification result is not allowed to add the transmission configuration information and the correspondence between the first target ECU in the retransmission buffer, so as to avoid the problem that the target ECU may generate unexpected errors due to abnormalities in the message processing.
[0159] In one possible way, such as Figure 8 As shown, this application provides a retransmission information caching process, including S701-S704.
[0160] S701, the gateway obtains the mailbox identifier and protocol data unit identifier of the first target ECU, as well as the current storage location and transmission configuration information of the information buffer.
[0161] S702, the gateway verifies whether the mailbox identifier and protocol data unit identifier of the first target ECU, as well as the data length of the target message, conform to the standard definition.
[0162] S703: If the gateway passes the verification, it writes the transmission configuration information and the protocol data unit identifier of the first target ECU into the retransmission buffer. If the verification fails, it ends the buffering.
[0163] S704, the current storage location of the gateway update information buffer, and the correspondence between the current storage location and the mailbox identifier and protocol data unit identifier of the first target ECU.
[0164] It should be noted that the preset routing table in this embodiment can be the complete set of routing information in the vehicle CAN network communication matrix, and can be a direct representation of the routing relationships in the vehicle CAN network communication. Furthermore, based on the standardized definition of AUTOSAR, the preset routing table can be generated quickly and accurately using a script, has a convenient writing method, and can support the flexible application of this application.
[0165] Specifically, such as Figure 9 As shown, to support the various configurable functions of the gateway, the preset routing table can include routing table entries for each network segment and the number of routing table entries for each network segment. That is, it represents the correspondence between multiple network points and multiple routing table entries, as well as the number of routing table entries that correspond to each network segment. A routing table entry can include the packet identifier of a source packet (e.g., the first packet identifier of the first packet), the number of destination nodes (i.e., the number of destination ECUs), the mailbox identifier of each destination node (e.g., the mailbox identifier of the first destination ECU), the protocol data unit identifier of each destination node (e.g., the protocol data unit identifier of the first destination ECU), and the CANFD flag of each destination node (e.g., the CANFD flag of the first destination ECU).
[0166] In some embodiments, such as Figure 10 The diagram illustrates a data transmission process provided in an embodiment of this application. The process begins after the gateway receives a message (e.g., the first message). The gateway can query a preset routing table based on the received message. If the query fails, i.e., the correspondence between the network segment and the message identifier of the received message is not found in the preset routing table, the process ends.
[0167] If the query is successful, meaning the mapping between the network segment and the packet identifier of the received packet is found in the preset routing table, the gateway can obtain the source node protocol type (also known as the packet protocol type), the number of target nodes, and the protocol type of each target node. Specifically, the gateway can parse the packet identifier corresponding to the received packet to determine the source node protocol type, and read the number of target nodes corresponding to the packet identifier and the protocol type of each target node from the preset routing table.
[0168] The gateway can determine whether the current index value is less than the number of target nodes. The initial value of the current index value can be 0, indicating the current number of target nodes that have completed routing. If the current index value is not less than the number of target nodes, that is, the current index value is equal to the number of target nodes, it indicates that all target nodes corresponding to the packet identifier have completed data routing, and the process ends.
[0169] If the current index value is less than the number of target nodes, it indicates that there are target nodes that need to be routed. The gateway can obtain the node identifier, data length, and message data of the target nodes. Specifically, the gateway can determine the node identifier of the target node based on the protocol type of the target node and the message identifier of the received message, and determine the data length and message data (i.e., service data) of the received message as the data length and message data corresponding to the target node.
[0170] The gateway can perform validation by combining the protocol type of the source node, the data length of the business data, and the protocol type of the target node. If the validation fails, the gateway can update the current index value by incrementing it by 1 and then determine that the process has ended.
[0171] If the verification passes, the gateway can route the message and send it, then provide feedback on the sending result. If the sending fails, the gateway can cache the transmission configuration information, update the current index value, and confirm the end of the process. If the sending succeeds, the gateway can update the current index value and confirm the end of the process.
[0172] It should be noted that, in combination Figure 1 ,like Figure 11 As shown, the routing processing logic provided in this application embodiment can be implemented in the CANIF layer of the gateway. That is, after receiving a message from the CAN layer, the routing processing logic in each of the above steps can be executed by the CANIF layer of the gateway. If the preset routing table does not contain a routing table entry corresponding to the received message, then via... Figure 1 The routing logic is as shown. If a routing entry corresponding to the received message exists in the preset routing table, it can be processed by the gateway's CANIF layer before being sent by the CAN layer. Based on this, this application can support the routing logic of data packets being pushed down to the CANIF layer, eliminating the redundant logic of layer-by-layer packet disassembly and reassembly in the AUTOSAR software architecture, and improving gateway routing efficiency by simplifying the routing logic of data packets.
[0173] The foregoing mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the vehicle terminal or user terminal includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0174] This application embodiment can, according to the above method, exemplarily divide an in-vehicle terminal or user terminal into functional modules. For example, the in-vehicle terminal or user terminal may include various functional modules corresponding to each functional division, or two or more functions may be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.
[0175] Figure 12 This is a block diagram illustrating a data transmission apparatus according to an exemplary embodiment. (Refer to...) Figure 12 The data transmission device includes a receiving unit 801 and a processing unit 802.
[0176] The receiving unit 801 is configured to receive a first message from the first network segment; the first message includes a first message identifier corresponding to the first message and service data to be transmitted.
[0177] The processing unit 802 is used to verify the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU when a correspondence between the first network segment and the first message identifier exists in the preset routing table, and to transmit the service data to the first target ECU when the verification passes; the preset routing table includes a correspondence between multiple network segments and multiple message identifiers, as well as a correspondence between multiple message identifiers and multiple target ECUs; the first target ECU is used to represent the target ECU that has a correspondence with the first message identifier in the preset routing table.
[0178] In one possible implementation, the preset routing table also includes the protocol type of each target ECU; the processing unit 802 is specifically used for:
[0179] Parse the first message identifier to determine the protocol type of the first message, and read the protocol type of the first target ECU from the preset routing table;
[0180] If the protocol type of the first message is CAN protocol, the verification is considered successful;
[0181] If the protocol type of the first message is CANFD and the protocol type of the first target ECU is CANFD, the verification is considered successful.
[0182] When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is CAN protocol, the first message is parsed to determine the data length of the service data, and if the data length is greater than the preset length threshold, the verification is determined to fail, or if the data length is less than or equal to the preset length threshold, the verification is determined to pass.
[0183] In one possible implementation, the processing unit 802 is specifically used for:
[0184] Determine the working status of the message buffer corresponding to the first target ECU;
[0185] When the working state corresponding to the message buffer is idle, the transmission configuration information carrying the service data is added to the message buffer to send the service data to the first target ECU.
[0186] In one possible implementation, the preset routing table also includes the protocol data unit identifier of each target ECU;
[0187] The processing unit 802 is also used to add the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU in the retransmission buffer when the working state corresponding to the message buffer is busy, so as to resend the service data to the first target ECU.
[0188] In one possible implementation, the preset routing table also includes the mailbox identifiers of each target ECU; the processing unit 802 is specifically used for:
[0189] Update the current storage location of the information buffer and add the mailbox identifier of the first target ECU to the current storage location;
[0190] When the current read position of the information buffer is inconsistent with the current storage position, the transmission configuration information is read from the retransmission buffer based on the mailbox identifier of the first target ECU, and the business data is transmitted to the first target ECU, and the current read position is updated.
[0191] In one possible implementation, the processing unit 802 is further configured to verify the protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the service data, and obtain a verification result; the verification result is used to indicate whether it is permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer, or not permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer.
[0192] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0193] Figure 13 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Figure 13 As shown, the electronic device includes, but is not limited to, a processor 801 and a memory 802.
[0194] The memory 802 described above is used to store the executable instructions of the processor 801. It is understood that the processor 801 is configured to execute instructions to implement the data transmission method in the above embodiments.
[0195] It should be noted that those skilled in the art will understand that Figure 13 The electronic device structure shown does not constitute a limitation on the electronic device; the electronic device may include, but is not limited to, other electronic devices. Figure 13 This may indicate more or fewer components, or combinations of certain components, or different component arrangements.
[0196] The processor 801 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 802, and by calling data stored in the memory 802, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. The processor 801 may include one or more processing units. Optionally, the processor 801 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 801.
[0197] The memory 802 can be used to store software programs and various data. The memory 802 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, application programs required by at least one functional module (such as a determination unit, processing unit, etc.), etc. Furthermore, the memory 802 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0198] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 802 including instructions, which can be executed by a processor 801 of an electronic device 800 to implement the methods in the above embodiments.
[0199] In actual implementation, Figure 12 The functions of the receiving unit 801 and the processing unit 802 can both be provided by Figure 13 The processor 801 calls the computer program stored in the memory 802 to implement the process. The specific execution process can be found in the method section of the previous embodiment, and will not be repeated here.
[0200] Optionally, the computer-readable storage medium may be a non-transitory computer-readable storage medium, such as a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0201] In an exemplary embodiment, this application also provides a computer program product including one or more instructions, which can be executed by a processor 801 of an electronic device to perform the methods described above.
[0202] It should be noted that when one or more instructions in the computer-readable storage medium or computer program product are executed by the processor of an electronic device, they implement the various processes of the above method embodiments and achieve the same technical effect as the above method. To avoid repetition, they will not be described again here.
[0203] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0204] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0205] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the classified units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0206] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0207] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, essentially, or the part that contributes to the prior art, or a complete or partial classification of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0208] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data transmission method, characterized by, include: Receive the first message from the first network segment; The first message includes a first message identifier corresponding to the first message and the service data to be transmitted; When the preset routing table contains a correspondence between the first network segment and the first message identifier, the data length of the service data, the protocol type of the first message, and the protocol type of the first target electronic control unit (ECU) are verified, and the service data is transmitted to the first target ECU when the verification passes; the preset routing table includes a correspondence between multiple network segments and multiple message identifiers, as well as a correspondence between the multiple message identifiers and multiple target ECUs; The first target ECU is used to represent a target ECU that has a corresponding relationship with the first message identifier in the preset routing table; The preset routing table also includes the protocol type of each target ECU; The verification of the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU includes: The protocol type of the first message is determined by parsing the first message identifier, and the protocol type of the first target ECU is read from the preset routing table; When the protocol type of the first message is Controller Area Network (CAN) protocol, the verification is deemed successful. When the protocol type of the first message is Variable Rate Controller Area Network (CANFD) protocol, and the protocol type of the first target ECU is the CANFD protocol, the verification is determined to be successful. When the protocol type of the first message is the CANFD protocol and the protocol type of the first target ECU is the CAN protocol, the first message is parsed to determine the data length of the service data, and when the data length is greater than a preset length threshold, the verification is determined to fail, or when the data length is less than or equal to the preset length threshold, the verification is determined to pass.
2. The method of claim 1, wherein, The transmission of the service data to the first target ECU includes: Determine the working status of the message buffer corresponding to the first target ECU; When the working state corresponding to the message buffer is idle, the transmission configuration information carrying the service data is added to the message buffer to send the service data to the first target ECU.
3. The method of claim 2, wherein, The preset routing table also includes the protocol data unit identifier of each target ECU; and also includes: When the working state corresponding to the message buffer is busy, the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU is added to the retransmission buffer to resend the service data to the first target ECU.
4. The method of claim 3, wherein, The preset routing table also includes the mailbox identifier of each target ECU; the step of resending the service data to the first target ECU includes: Update the current storage location of the information buffer, and add the mailbox identifier of the first target ECU to the current storage location; When the current read position of the information buffer is inconsistent with the current storage position, the transmission configuration information is read from the retransmission buffer based on the mailbox identifier of the first target ECU, the service data is transmitted to the first target ECU, and the current read position is updated.
5. The method of claim 3, wherein, Before adding the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU to the retransmission buffer, the method further includes: The protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the service data are verified to obtain a verification result. The verification result is used to indicate whether it is allowed to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer, or not allowed to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer.
6. A data transmission apparatus characterized by comprising: include: Receiving unit and processing unit; The receiving unit is used to receive a first message from the first network segment; The first message includes a first message identifier corresponding to the first message and the service data to be transmitted; The processing unit is configured to verify the data length of the service data, the protocol type of the first message, and the protocol type of the first target ECU when a correspondence between the first network segment and the first message identifier exists in the preset routing table, and to transmit the service data to the first target ECU when the verification passes; the preset routing table includes a correspondence between multiple network segments and multiple message identifiers, as well as a correspondence between the multiple message identifiers and multiple target ECUs; The first target ECU is used to represent a target ECU that has a corresponding relationship with the first message identifier in the preset routing table; The preset routing table also includes the protocol type of each target ECU; the processing unit is specifically used for: The protocol type of the first message is determined by parsing the first message identifier, and the protocol type of the first target ECU is read from the preset routing table; If the protocol type of the first message is CAN protocol, the verification is confirmed to be successful; When the protocol type of the first message is CANFD protocol and the protocol type of the first target ECU is the CANFD protocol, the verification is determined to be successful; When the protocol type of the first message is the CANFD protocol and the protocol type of the first target ECU is the CAN protocol, the first message is parsed to determine the data length of the service data, and when the data length is greater than a preset length threshold, the verification is determined to fail, or when the data length is less than or equal to the preset length threshold, the verification is determined to pass.
7. The apparatus of claim 6, wherein, The processing unit is specifically used for: Determine the working status of the message buffer corresponding to the first target ECU; When the working state corresponding to the message buffer is idle, the transmission configuration information carrying the service data is added to the message buffer to send the service data to the first target ECU.
8. The apparatus of claim 7, wherein, The preset routing table also includes the protocol data unit identifier of each target ECU; The processing unit is further configured to add the correspondence between the transmission configuration information and the protocol data unit identifier of the first target ECU to the retransmission buffer when the working state corresponding to the message buffer is busy, so as to resend the service data to the first target ECU.
9. The apparatus of claim 8, wherein, The preset routing table also includes mailbox identifiers for each target ECU; the processing unit is specifically used for: Update the current storage location of the information buffer, and add the mailbox identifier of the first target ECU to the current storage location; When the current read position of the information buffer is inconsistent with the current storage position, the transmission configuration information is read from the retransmission buffer based on the mailbox identifier of the first target ECU, the service data is transmitted to the first target ECU, and the current read position is updated.
10. The apparatus according to claim 8, characterized in that, The processing unit is further configured to verify the protocol data unit identifier of the first target ECU, the mailbox identifier of the first target ECU, and the length of the service data to obtain a verification result; the verification result is used to indicate whether it is permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer, or not permissible to add the correspondence between the transmission configuration information and the first target ECU in the retransmission buffer.
11. An electronic device, comprising: include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 5.
12. A computer-readable storage medium, characterized in that, When the computer-executable instructions stored in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is capable of performing the method as described in any one of claims 1 to 5.