Data forwarding method and device, vehicle and storage medium
By using a combination of routing module and CANTP module in cars, the effective forwarding of diagnostic command messages is achieved, solving the challenges of diagnostic data transmission efficiency and accuracy in modern cars, and improving the reliability and stability of data forwarding.
Patent Information
- Application Number
- CN202510194027.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-20
AI Technical Summary
The increase in the number of electronic control units (ECUs) in modern cars has led to a sharp increase in the amount of internal communication data of vehicles, requiring higher communication efficiency and accuracy. Especially in the diversity and complexity of diagnostic data, effective routing and forwarding and arbitration mechanisms are needed to ensure the correct transmission of diagnostic data.
The diagnostic command message sent by the upper computer is received through the routing module in the first core, and forwarded it to the CANTP module through the first state machine of the routing module. Finally, the diagnostic command message is sent to other CAN nodes by the CANTP module.
It improves the reliability and stability of data forwarding, ensures the correct transmission of diagnostic data, and adapts to the complex communication environment of modern cars.
Smart Images

Figure CN120186087A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of vehicles, and particularly relates to a data forwarding method, apparatus, vehicle, and storage medium. Background Art
[0002] With the improvement of the electronic level of automobiles, the number of electronic control units (ECUs) has been increasing continuously, and the functions have become more complex. This has led to a sharp increase in the amount of communication data inside the vehicle, posing higher requirements for communication efficiency and accuracy. To address the challenges brought by automotive electronics, the domain controller architecture has gradually become the mainstream trend of the automotive electronic and electrical architecture. The domain controller divides the automotive electronic system into several functional blocks according to functions, and the system architecture inside each functional block is mainly built under the leadership of the domain controller. This helps to optimize the vehicle's electronic and electrical circuits and improve communication efficiency and reliability. In modern automobiles, multiple bus systems (such as CAN, LIN, Ethernet, etc.) coexist to achieve communication between different ECUs. This has led to the diversity and complexity of diagnostic data, and an effective routing forwarding and arbitration mechanism is needed to ensure the correct transmission of diagnostic data. Summary of the Invention
[0003] In view of the above problems, this application proposes a data forwarding method, apparatus, vehicle, and storage medium to improve the above problems.
[0004] In a first aspect, an embodiment of this application provides a data forwarding method, which includes: receiving, by a routing module in a first core, a diagnostic command message sent by a host computer, where the diagnostic command message is used to indicate diagnosing other CAN nodes hung under the first core; forwarding, by a first state machine of the routing module, the diagnostic command message to a CANTP module in the first core, where the first state machine is in an idle state; and sending, by the CANTP module, the diagnostic command message to the other CAN nodes.
[0005] In a second aspect, an embodiment of this application provides a data forwarding apparatus, which includes: a receiving unit, configured to receive, by a routing module in a first core, a diagnostic command message sent by a host computer, where the diagnostic command message is used to indicate diagnosing other CAN nodes hung under the first core; a forwarding unit, configured to forward, by a first state machine of the routing module, the diagnostic command message to a CANTP module in the first core, where the first state machine is in an idle state; and a sending unit, configured to send, by the CANTP module, the diagnostic command message to the other CAN nodes.
[0006] In a third aspect, an embodiment of the present application provides a data forwarding system, which includes a host computer and a first core. The first core includes a routing module and a CANTP module. The host computer is configured to send a diagnostic command message to the routing module, and the diagnostic command message is used to indicate diagnosing other CAN nodes connected to the first core. The routing module is configured to receive the diagnostic command message and forward the diagnostic command message to the CANTP module through a first state machine, where the first state machine is in an idle state. The CANTP module is configured to send the diagnostic command message to the other CAN nodes.
[0007] In a fourth aspect, an embodiment of the present application provides a vehicle, which includes one or more processors and a memory; and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.
[0008] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which program code is stored, and when the program code runs, it executes the above-mentioned method.
[0009] An embodiment of the present application provides a data forwarding method, device, vehicle and storage medium. First, the routing module in the first core receives a diagnostic command message sent by the host computer, and the diagnostic command message is used to indicate diagnosing other CAN nodes connected to the first core. Then, the diagnostic command message is forwarded to the CANTP module in the first core through the first state machine of the routing module, and the first state machine is in an idle state. Finally, the diagnostic command message is sent to the other CAN nodes through the CANTP module. Through the above method, the diagnostic command message is forwarded through the state machine of the routing module, improving the reliability and stability of data forwarding. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0011] Figure 1 FIG. shows a schematic diagram of an application scenario of a data forwarding method proposed in an embodiment of the present application;
[0012] Figure 2 FIG. shows a flowchart of a data forwarding method proposed in an embodiment of the present application;
[0013] Figure 3 The flowchart of a data forwarding method proposed by another embodiment of the present application is shown;
[0014] Figure 4 The structural block diagram of a data forwarding device proposed by an embodiment of the present application is shown;
[0015] Figure 5 The structural block diagram of a data forwarding device proposed by an embodiment of the present application is shown;
[0016] Figure 6 The structural block diagram of a data forwarding system proposed by an embodiment of the present application is shown;
[0017] Figure 7 The structural block diagram of a vehicle for executing the data forwarding method according to the embodiment of the present application in the embodiment of the present application is shown;
[0018] Figure 8 The storage unit for storing or carrying the program code for implementing the data forwarding method according to the embodiment of the present application in the embodiment of the present application is shown. Specific embodiments
[0019] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.
[0020] An embodiment of the present application proposes a data forwarding method, device, vehicle, and storage medium. First, the routing module in the first core receives the diagnostic command message sent by the host computer, and this diagnostic command message is used to indicate the diagnosis of other CAN nodes hung under the first core. Then, the first state machine of the routing module forwards the diagnostic command message to the CANTP module in the first core, and this first state machine is in the idle state. Finally, the CANTP module sends the diagnostic command message to other CAN nodes. Through the above method, the diagnostic command message is forwarded by the state machine of the routing module, improving the reliability and stability of data forwarding.
[0021] Next, the application environment of the data forwarding method provided in the embodiment of the present application will be introduced:
[0022] Please refer to Figure 1 , the data forwarding method provided in the embodiment of the present application can be applied to the data forwarding system 100, and this data forwarding system 100 may include a host computer 110, a first core 120, a second core 130, and an external CAN node 140.
[0023] Among them, the first core 120 may include a routing module 121, an ETHTP module 122, and a CANTP module 123. The second core 130 includes an ETH module 131. In the embodiment of the present application, both the ETHTP module 122 and the CANTP module 123 are communicatively connected to the routing module 121. Other CAN nodes 140 are hung under the first core 120, and the other CAN nodes 140 are communicatively connected to the CANTP module 123. The routing module 121 is located in the middleware layer of the CCU (Central Control Unit, in-vehicle central domain control unit) in the architecture, between the application layer and the bottom layer, and performs data interaction with the bottom-layer ETHTP module 122 and CANTP module 123, and can implement functions such as DOIP (Diagnostic over Internet Protocol, IP-based automotive diagnostic protocol) to DOCAN (Diagnostic over CAN, CAN-based automotive diagnostic protocol) data conversion, DOCAN to DOIP data conversion, OBDCAN (On-Board Diagnostics over CAN, communication method for in-vehicle diagnostics via the CAN bus) diagnostic data routing and forwarding, and channel arbitration.
[0024] The first core 120 and the second core 130 are processors in the CCU. When the host computer 110 is connected to the second core 130 through Ethernet and needs to diagnose other CAN nodes 140 hung under the first core 120, the host computer 110 constructs and sends a diagnostic command message to the second core 130. Optionally, the host computer 110 can also be connected to the CAN network of the system through the OBDCAN interface. When it is necessary to diagnose other CAN nodes 140, the host computer 110 constructs and sends a diagnostic command message to the CAN network.
[0025] The embodiments of the present application will be specifically described below with reference to the accompanying drawings.
[0026] Please refer to Figure 2 , a data forwarding method provided by an embodiment of the present application, the method includes:
[0027] Step S110: Receive a diagnostic command message sent by a host computer through a routing module in the first core, where the diagnostic command message is used to indicate diagnosing other CAN nodes hung under the first core.
[0028] In the embodiment of the present application, the first core can be understood as the M core in the CCU, and the host computer can be Figure 1The host computer connected to the ETH module or the host computer connected to the CANTP module is not specifically limited herein. The diagnostic command message is diagnostic data constructed and sent by the host computer, and the diagnostic command message can be diagnostic data in the DOIP format or diagnostic data in the OBDCAN format, which is not specifically limited herein. Specifically, if the host computer is the host computer connected to the ETH module, the diagnostic command message is diagnostic data in the DOIP format; if the host computer is the host computer connected to the CANTP module, the diagnostic command message is diagnostic data in the OBDCAN format.
[0029] Among them, the diagnostic command message is message data indicating the diagnosis of other CAN nodes, and the diagnostic command message may include the source address, target address, UDS (Unified Diagnostic Services) data, etc. of the CAN node to be diagnosed.
[0030] Step S120: Forward the diagnostic command message to the CANTP module in the first core through the first state machine of the routing module, and the first state machine is in the idle state.
[0031] In the embodiment of the present application, the number of state machines in the routing module is determined by the number of routed nodes, that is, according to the number of routed nodes, the corresponding number of state machines is configured. The states of the state machine are further divided into idle state, initialization state, CANTP receiving data state, CANTP sending data state, ETHTP receiving data state, and ETHTP sending data state.
[0032] As a way, when the diagnostic command message is the diagnostic data sent by the host computer connected to the ETH module, the path of the diagnostic command message transmitted to the routing module is as follows: The host computer constructs and sends a diagnostic command message in the DOIP format to the ETH module of the second core, and then the ETH module of the second core forwards the received diagnostic command message in the DOIP format to the ETHTP module of the first core, and then the ETHTP module copies the diagnostic command message in the DOIP format to the routing module. When the routing module receives the diagnostic command message in the DOIP format, it traverses the internal state machines to find a state machine in the idle state (i.e., the first state machine), and after finding it, copies the diagnostic command message in the DOIP format to the buffer area of the state machine in the idle state, and then the diagnostic command message in the DOIP format can be sent to the CANTP module through the state machine in the idle state.
[0033] In the above method, when the routing module finds the first state machine, it initializes the first state machine and switches its state to the initialization state. Then, the routing module can copy the diagnostic command message in DOIP format into the buffer of the initialized first state machine. The state of the first state machine is switched to the ETHTP data receiving state, and the diagnostic command message in DOIP format is disassembled to check whether it conforms to the standard. If the diagnostic command message in DOIP format does not conform to the standard or is abnormal, the diagnostic command message is directly discarded, and the first state machine in the ETHTP data receiving state is switched to the idle state; if the diagnostic command message in DOIP format is normal, the first state machine in the ETHTP data receiving state identifies the source address, target address, and UDS data of the diagnostic command message in DOIP format, performs data conversion on the diagnostic command message in DOIP format according to the preset routing information table, and switches the state of the first state machine in the ETHTP data receiving state to the CANTP data sending state; the first state machine in the CANTP data sending state calls the CANTP function interface to notify the CANTP module to copy the diagnostic command message after data conversion.
[0034] As another method, when the diagnostic command message is the diagnostic data sent by the host computer connected to the CANTP module, the path for the diagnostic command message to be transmitted to the routing module is as follows: the host computer constructs and sends the diagnostic command message in OBDCAN format to the CANTP module. When the CANTP module receives the diagnostic command message in OBDCAN format, it triggers the function interface of the routing module. After receiving the trigger from the CANTP module, the routing module finds an idle state machine (i.e., the first state machine), copies the diagnostic command message in OBDCAN format into the buffer of the idle state machine, and then the CANTP module calls back the data interface of the routing module to find the state machine storing the diagnostic command message in OBDCAN format and copies the diagnostic command message in OBDCAN format from its buffer.
[0035] In the above manner, when the routing module finds the first state machine, it initializes the first state machine and switches its state to the initialization state. Then, the routing module copies the diagnostic command message in OBDCAN format into the buffer area of the initialized first state machine, and then switches the initialized first state machine to the CANTP receive data state (indicating that it is ready to process the received CAN data). The first state machine in the CANTP receive data state performs data conversion on the diagnostic command message in OBDCAN format according to the preset routing information table, and then the state of the first state machine in the CANTP receive data state is switched to the CANTP send data state (indicating that it is ready to send data). The first state machine in the CANTP send data state calls the send data interface of the CANTP module to notify the CANTP module to copy the converted diagnostic command message from its buffer area.
[0036] Step S130: Send the diagnostic command message to the other CAN nodes through the CANTP module.
[0037] In the embodiment of the present application, when the CANTP module receives the notification sent by the first state machine in the CANTP send data state, the CANTP module calls the function interface of the routing module to find the first state machine in the CANTP send data state and report the converted diagnostic command message from its buffer area. When the CANTP module finishes copying the converted diagnostic command message from the buffer area of the first state machine in the CANTP send data state, the state of the first state machine in the CANTP send data state is switched to the idle state. The other CAN nodes can be understood as the ECUs connected to the CCU.
[0038] When the CANTP module finishes copying the converted diagnostic command message from the buffer area of the first state machine in the CANTP send data state, the CANTP module sends the converted diagnostic command message to the other CAN nodes for diagnosing the other CAN nodes.
[0039] A data forwarding method provided by the present application forwards the diagnostic command message through the state machine of the routing module, improving the reliability and stability of data forwarding.
[0040] Please refer to Figure 3 , a data forwarding method provided by the embodiment of the present application, the method includes:
[0041] Step S210: Receive, through the routing module in the first core, a diagnostic command message sent by the host computer, where the diagnostic command message is used to indicate diagnosing other CAN nodes hung under the first core.
[0042] Step S220: Determine the first state machine among multiple state machines through the routing module.
[0043] In the embodiment of the present application, the routing module is pre-configured with multiple state machines. When the routing module receives a diagnostic command message sent by the host computer, it traverses the state machines inside it and determines the state machine in the idle state as the first state machine.
[0044] Step S230: Copy the diagnostic command message to the buffer area of the first state machine through the routing module.
[0045] As a way, after step S230, it further includes: converting the diagnostic command message into message data in DOCAN format by the first state machine according to the pre-set routing information table.
[0046] In the embodiment of the present application, if the diagnostic command message is in DOIP format, the first state machine converts the DOIP format diagnostic command message into a CANTP format diagnostic command message according to the pre-set routing information table; if the diagnostic command message is an OBDCAN format diagnostic command message, the first state machine converts the OBDCAN format diagnostic command message into a CANTP format diagnostic command message according to the pre-set routing information table.
[0047] Step S240: Switch the first state machine to the CANTP data sending state.
[0048] Step S250: Call the CANTP function interface through the first state machine in the CANTP data sending state to notify the CANTP module to copy the diagnostic command message from the buffer area.
[0049] As a way, step S250 includes: calling the CANTP function interface through the first state machine in the CANTP data sending state to notify the CANTP module to copy the message data in DOCAN format from the buffer area.
[0050] Step S260: When the CANTP module copies the diagnostic command message from the buffer area, send the diagnostic command message to the other CAN nodes.
[0051] As a way, send the message data in DOCAN format to the other CAN nodes through the CANTP module; switch the first state machine in the CANTP data sending state to the idle state.
[0052] As another way, after sending the diagnostic command message to the other CAN node through the CANTP module, the following steps are further included: receiving a reply message through the CANTP module, where the reply message is a diagnostic message sent by the other CAN node after diagnosing based on the diagnostic command message; when the CANTP module receives the reply message, triggering the routing module to determine a second state machine, and copying the reply message to the buffer area of the second state machine, where the second state machine is in an idle state; switching the second state machine to the CANTP receive data state, and performing format conversion on the reply message through the second state machine in the CANTP receive data state to obtain a reply message after format conversion.
[0053] In the embodiment of the present application, after receiving a diagnostic command message in DOCAN format, the other CAN node diagnoses itself, then constructs and sends a reply message to the CAN bus (i.e., the CANTP module). When the CANTP module receives the reply message, it triggers the routing module again. The routing module finds an idle state machine (i.e., the second state machine), initializes the second state machine, copies the reply message to the buffer area of the initialized second state machine, and switches the state of the initialized second state machine to the CANTP receive data state. The second state machine in the CANTP receive data state can perform format conversion on the reply message according to the preset routing information table. At this time, when the second state machine in the CANTP receive data state performs format conversion on the reply message, it needs to determine whether the current diagnostic channel is the A-core - M-core diagnostic channel or the OBDCAN diagnostic channel, and then can convert the reply message into a reply message in the corresponding format according to the diagnostic channel.
[0054] Among them, the reply message is the message data in DOCAN format. Performing format conversion on the reply message can be converting the message data in DOCAN format into a reply message in DOIP format, or converting the message data in DOCAN format into a reply message in OBDCAN format. Specifically, if the diagnostic channel is the A-core - M-core diagnostic channel, then convert the message data in DOCAN format into a reply message in DOIP format; if the diagnostic channel is the OBDCAN channel, then convert the message data in DOCAN format into a reply message in OBDCAN format.
[0055] Optionally, after the second state machine in the CANTP receive data state performs format conversion on the reply message to obtain a reply message with format conversion, the following steps are further included: If the reply message with format conversion is a DOIP format reply message, switch the second state machine in the CANTP receive data state to the ETHTP send data state; call the ETHTP data interface through the second state machine in the ETHTP send data state to notify the ETHTP module in the first core to copy the DOIP format reply message from the buffer; after the ETHTP module copies the DOIP format reply message from the buffer, send the DOIP format reply message to the second core to send the DOIP format reply message to the host computer through the second core.
[0056] Optionally, after the second state machine in the CANTP receive data state performs format conversion on the reply message to obtain a reply message with format conversion, the following steps are further included: If the reply message with format conversion is an OBDCAN format reply message, switch the second state machine in the CANTP receive data state to the CANTP send data state; call the CANTP data interface through the second state machine in the CANTP send data state to notify the CANTP module in the first core to copy the OBDCAN format reply message from the buffer; after the CANTP module copies the OBDCAN format reply message from the buffer, send the OBDCAN format reply message to the host computer.
[0057] In the embodiment of the present application, the second core may be the A core in the CCU. If the converted reply message is a DOIP format reply message, it can be determined that the routing module needs to forward the converted reply message to the host computer connected to the ETH module; if the converted reply message is an OBDCAN format reply message, it can be determined that the converted reply message needs to be forwarded to the host computer connected to the CANTP module.
[0058] In the foregoing manner, the state of the second state machine in the CANTP receive data state is switched to the ETHTP send data state; the second state machine in the ETHTP send data state calls the data interface of the ETHTP module to notify the ETHTP module to copy the DOIP - formatted response message. The ETHTP module calls the function interface of the routing module to copy the DOIP - formatted response message from the buffer of the second state machine in the ETHTP send data state. The ETHTP module sends the DOIP - formatted response message to the second core through the Ethernet, and then returns it to the host computer connected to the ETH module. At this time, the second state machine in the ETHTP send data state is switched to the idle state, ready to process the next task.
[0059] In the following manner, the state of the second state machine in the CANTP receive data state is switched to the CANTP send data state; the second state machine in the CANTP send data state calls the data interface of the CANTP module to notify the CANTP module to copy the OBDCAN - formatted response message. The CANTP module calls the function interface of the routing module to copy the OBDCAN - formatted response message from the buffer of the second state machine in the CANTP send data state. The CANTP module sends the OBDCAN - formatted response message to the host computer connected to the CANTP module through the OBDCAN interface. At this time, the second state machine in the CANTP send data state is switched to the idle state, ready to process the next task.
[0060] Step S270: If the diagnostic command message is an OBDCAN - formatted diagnostic message, send a DOIP diagnostic command prohibition to the second core through the routing module to prohibit the second core from sending a diagnostic command message to the routing module.
[0061] In the embodiment of the present application, if the diagnostic command message is an OBDCAN - formatted diagnostic message, after the routing module receives the trigger from the CANTP module, it will first send a signal of a diagnostic command message prohibiting the DOIP format to the second core to ensure that the second core will not send interfering diagnostic command messages through the Ethernet during the diagnosis process. This step S270 is executed after step S210 and before step S220.
[0062] Optionally, after the routing module sends a signal of a diagnostic command message prohibiting the DOIP format to the second core, start timing. If no DOCAN diagnosis is performed within a preset time (such as 5 s), resume receiving the DOIP diagnostic command messages sent by the second core through the Ethernet.
[0063] Through step S270, possible interference during the diagnosis process can be avoided, improving the accuracy and reliability of the diagnosis.
[0064] A data forwarding method provided by this application can ensure the correct transmission and processing of diagnostic command messages and response messages through precise control and state transitions of the state machine. At the same time, by sending a signal to prohibit DOIP diagnostic command messages to the second core, potential interference during the diagnosis is avoided, improving the accuracy and reliability of the diagnosis.
[0065] Please refer to Figure 4 , a data forwarding device 300 provided by an embodiment of this application, the device 300 includes:
[0066] A receiving unit 310, configured to receive a diagnostic command message sent by a host computer through a routing module in the first core, where the diagnostic command message is used to indicate diagnosing other CAN nodes connected to the first core.
[0067] As a way, the receiving unit 340 is specifically configured to receive a response message through the CANTP module, where the response message is a diagnostic message constructed and sent by the other CAN nodes based on the diagnostic command message; when the CANTP module receives the response message, trigger the routing module to determine a second state machine, and copy the response message to a buffer area of the second state machine, where the second state machine is in an idle state; switch the second state machine to the CANTP receive data state, and perform format conversion on the response message through the second state machine in the CANTP receive data state to obtain a response message after format conversion.
[0068] A forwarding unit 320, configured to forward the diagnostic command message to a CANTP module in the first core through a first state machine of the routing module, where the first state machine is in an idle state.
[0069] As a way, the routing module is pre-configured with multiple state machines; the forwarding unit 320 is specifically configured to determine a first state machine among the multiple state machines through the routing module; copy the diagnostic command message to a buffer area of the first state machine through the routing module; switch the first state machine to the CANTP send data state; and call a CANTP function interface through the first state machine in the CANTP send data state to notify the CANTP module to copy the diagnostic command message from the buffer area.
[0070] Furthermore, the forwarding unit 320 is specifically configured to convert the diagnostic command message into message data in DOCAN format through the first state machine according to a preset routing information table; and call a CANTP function interface through the first state machine in the CANTP send data state to notify the CANTP module to copy the message data in DOCAN format from the buffer area.
[0071] A sending unit 330 is configured to send the diagnostic command message to the other CAN nodes through the CANTP module.
[0072] As a mode, the sending unit 330 is specifically configured to send the diagnostic command message to the other CAN nodes when the CANTP module copies the diagnostic command message from the buffer.
[0073] As another mode, the sending unit 330 is specifically configured to send the message data in the DOCAN format to the other CAN nodes through the CANTP module; and switch a first state machine in the CANTP data sending state to an idle state.
[0074] Optionally, please refer to Figure 5 , the apparatus 300 further includes:
[0075] A copying unit 340 is configured to, if the format-converted response message is a DOIP format response message, switch a second state machine in the CANTP data receiving state to an ETHTP data sending state; call an ETHTP data interface through the second state machine in the ETHTP data sending state to notify the ETHTP module in the first core to copy the DOIP format response message from the buffer; and after the ETHTP module copies the DOIP format response message from the buffer, send the DOIP format response message to the second core, so as to send the DOIP format response message to the host computer through the second core.
[0076] As a mode, the copying unit 350 is specifically configured to, if the format-converted response message is an OBDCAN format response message, switch a second state machine in the CANTP data receiving state to a CANTP data sending state; call a CANTP data interface through the second state machine in the CANTP data sending state to notify the CANTP module in the first core to copy the OBDCAN format response message from the buffer; and after the CANTP module copies the OBDCAN format response message from the buffer, send the OBDCAN format response message to the host computer.
[0077] A prohibiting unit 350 is configured to, if the diagnostic command message is an OBDCAN format diagnostic message, send a prohibiting DOIP diagnostic command to the second core through the routing module to prohibit the second core from sending a diagnostic command message to the routing module.
[0078] Please refer to Figure 6, a data forwarding system 400 provided by an embodiment of the present application, the system 400 includes: a host computer 410 and a first core 420, and the first core 410 includes a routing module 411 and a CANTP module 412.
[0079] The host computer 410 is configured to send a diagnostic command message to the routing module 411, and the diagnostic command message is used to indicate diagnosing other CAN nodes connected to the first core 410.
[0080] The routing module 411 is configured to receive the diagnostic command message and forward the diagnostic command message to the CANTP module through a first state machine, and the first state machine is in an idle state.
[0081] The CANTP module 412 is configured to send the diagnostic command message to the other CAN nodes.
[0082] It should be noted that the device embodiments in the present application correspond to the foregoing method embodiments. The specific principles in the device embodiments can be referred to the content in the foregoing method embodiments, and will not be elaborated herein.
[0083] Next, Figure 7 a vehicle provided by the present application will be described.
[0084] Please refer to Figure 7 , based on the foregoing data forwarding method and device, another vehicle 800 that can execute the foregoing data forwarding method is further provided by an embodiment of the present application. The vehicle 800 includes one or more (only one is shown in the figure) processors 802, a memory 804, and a network module 806 that are coupled to each other. Among them, a program that can execute the content in the foregoing embodiments is stored in the memory 804, and the processor 802 can execute the program stored in the memory 804.
[0085] Among them, the processor 802 may include one or more processing cores. The processor 802 connects various parts within the entire vehicle 800 through various interfaces and circuits, and executes various functions of the vehicle 800 and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 804, and by calling the data stored in the memory 804. Optionally, the processor 802 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). The processor 802 may integrate one or a combination of several of a central processing unit (CPU), a graphics processing unit (GPU), and a modem, etc. Among them, the CPU mainly processes the operating system, user interface, application programs, etc.; the GPU is responsible for rendering and drawing the displayed content; the modem is used to process wireless communication. It can be understood that the above modem may not be integrated into the processor 802 and may be implemented separately through a communication chip.
[0086] The memory 804 may include random access memory (RAM) and may also include read-only memory. The memory 804 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 804 may include a program storage area and a data storage area. Among them, the program storage area may store instructions for implementing the operating system, instructions for implementing at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created during the use of the vehicle 800 (such as phone book, audio and video data, chat record data, etc.).
[0087] The network module 806 is used to receive and transmit electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, such as communicating with a vehicle. The network module 806 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, subscriber identity module (SIM) cards, memories, and so on. The network module 806 can communicate with various networks such as the Internet, enterprise intranets, wireless networks or communicate with other devices through a wireless network. The above-mentioned wireless network may include a cellular phone network, a wireless local area network or a metropolitan area network. For example, the network module 806 can interact with a base station for information.
[0088] Please refer to Figure 8 , which shows a structural block diagram of a computer-readable storage medium provided by an embodiment of the present application. Program code is stored in the computer-readable storage medium 900, and the program code can be called by a processor to execute the method described in the above method embodiment.
[0089] The computer-readable storage medium 900 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. Optionally, the computer-readable storage medium 900 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 900 has a storage space for the program code 910 that executes any method step in the above method. These program codes can be read out from or written into one or more computer program products. The program code 910 can be compressed in an appropriate form, for example.
[0090] A data forwarding method, device, vehicle and storage medium provided by the present application first receive a diagnostic command message sent by a host computer through a routing module in a first core. The diagnostic command message is used to indicate the diagnosis of other CAN nodes hanging under the first core. Then, the diagnostic command message is forwarded to a CANTP module in the first core through a first state machine of the routing module. The first state machine is in an idle state. Finally, the diagnostic command message is sent to other CAN nodes through the CANTP module. Through the above method, the diagnostic command message is forwarded through the state machine of the routing module, improving the reliability and stability of data forwarding.
[0091] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative rather than restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit of the present invention and the scope protected by the claims, and all of them fall within the protection scope of the present invention.
Claims
1. A data forwarding method, characterized in that: The method comprises: Receiving, through the routing module in the first core, a diagnostic command message sent by the host computer, wherein the diagnostic command message is used to instruct to diagnose other CAN nodes under the first core; forwarding the diagnostic command message to the CANTP module in the first core through the first state machine of the routing module, wherein the first state machine is in an idle state; The diagnostic command message is sent to the other CAN nodes through the CANTP module.
2. The method according to claim 1, characterized in that The routing module is pre-configured with a plurality of state machines, and the first state machine of the routing module forwards the diagnostic command message to the CANTP module in the first core, including: Determining a first state machine among the plurality of state machines by the routing module; Copying the diagnostic command message to the buffer area of the first state machine through the routing module; Switching the first state machine to a CANTP data sending state; Calling a CANTP function interface through a first state machine in a CANTP data sending state to notify the CANTP module to copy the diagnostic command message from the buffer area; The sending the diagnostic command message to the other CAN nodes through the CANTP module includes: When the CANTP module copies the diagnostic command message from the buffer area, the diagnostic command message is sent to the other CAN nodes.
3. The method according to claim 2, characterized in that After the diagnostic command message is copied to the buffer area of the first state machine by the routing module, the method further includes: Converting the diagnostic command message into message data in DOCAN format according to a preset routing information table by the first state machine; The calling of the CANTP function interface by the first state machine in the CANTP data sending state to notify the CANTP module to copy the diagnostic command message from the buffer area includes: Calling a CANTP function interface through a first state machine in a CANTP data sending state to notify the CANTP module to copy the message data in the DOCAN format from the buffer area; The sending the diagnostic command message to the other CAN nodes through the CANTP module includes: Sending the message data in the DOCAN format to the other CAN nodes through the CANTP module; The first state machine in the CANTP data sending state is switched to the idle state.
4. The method according to claim 3, characterized in that After sending the diagnostic command message to the other CAN nodes through the CANTP module, the following further includes: Receiving a reply message through the CANTP module, wherein the reply message is a diagnostic message sent by the other CAN nodes after performing diagnosis based on the diagnostic command message; When the CANTP module receives the reply message, the routing module is triggered to determine the second state machine, and the reply message is copied to the buffer area of the second state machine, and the second state machine is in an idle state; The second state machine is switched to the CANTP data receiving state, and the reply message is format-converted by the second state machine in the CANTP data receiving state to obtain a reply message after the format conversion.
5. The method according to claim 4, characterized in that The step of converting the format of the reply message by the second state machine in the CANTP data receiving state to obtain the reply message after the format conversion also includes: If the reply message after the format conversion is a reply message in DOIP format, the second state machine in the CANTP data receiving state is switched to the ETHTP data sending state; Calling the ETHTP data interface through the second state machine in the ETHTP data sending state, notifying the ETHTP module in the first core to copy the reply message in the DOIP format from the buffer area; After the ETHTP module copies the reply message in the DOIP format from the buffer area, the reply message in the DOIP format is sent to the second core, so that the reply message in the DOIP format is sent to the host computer through the second core.
6. The method according to claim 4, characterized in that The step of converting the format of the reply message by the second state machine in the CANTP data receiving state to obtain the reply message after the format conversion also includes: If the reply message after the format conversion is a reply message in the OBDCAN format, the second state machine in the CANTP data receiving state is switched to the CANTP data sending state; Calling the CANTP data interface through the second state machine in the CANTP data sending state, notifying the CANTP module in the first core to copy the reply message in the OBDCAN format from the buffer area; After the CANTP module copies the reply message in the OBDCAN format from the buffer area, the reply message in the OBDCAN format is sent to the host computer.
7. The method according to claim 1, characterized in that After receiving the diagnostic command message sent by the host computer through the routing module in the first core, the method further includes: If the diagnostic command message is a diagnostic message in the OBDCAN format, a DOIP diagnostic prohibition command is sent to the second core through the routing module to prohibit the second core from sending the diagnostic command message to the routing module.
8. A data forwarding device, characterized in that: The device comprises: A receiving unit, used for receiving a diagnostic command message sent by a host computer through a routing module in the first core, wherein the diagnostic command message is used for instructing to diagnose other CAN nodes under the first core; a forwarding unit, configured to forward the diagnostic command message to the CANTP module in the first core through a first state machine of the routing module, wherein the first state machine is in an idle state; A sending unit is used to send the diagnostic command message to the other CAN nodes through the CANTP module.
9. A data forwarding system, characterized in that: The system includes a host computer and a first core, wherein the first core includes a routing module and a CANTP module; The host computer is used to send a diagnostic command message to the routing module, wherein the diagnostic command message is used to instruct to diagnose other CAN nodes under the first core; The routing module is used to receive the diagnostic command message and forward the diagnostic command message to the CANTP module through a first state machine, wherein the first state machine is in an idle state; The CANTP module is used to send the diagnostic command message to the other CAN nodes.
10. A vehicle, characterized in that: The method comprises one or more processors and a memory; one or more programs are stored in the memory and are configured so that the one or more processors execute the method according to any one of claims 1 to 7.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 7 is executed.
Citation Information
Cited By
Switching method of state machine, state machine and system
CN121567728A
Switching method of state machine, state machine and system
CN121567728B