Time synchronization method and system and storage medium

By using the time synchronization protocol module in the electronic control unit to read or feedback the global time basis, combining the automotive open system architecture and the Ethernet time synchronization protocol, the complexity and cost of time synchronization in the on-board system are solved, and a simplified time synchronization process is achieved.

CN120263329APending Publication Date: 2025-07-04ECARX (HUBEI) TECHCO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510518001.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

In the prior art, the AUTOSAR time synchronization scheme is complex and costly in the on-board system, and many on-board systems do not support the gptp protocol, resulting in high difficulty and cost in time synchronization.

Method used

Time synchronization is achieved by using the time synchronization protocol module to read or feedback the global time basis in the electronic control unit, combining the automotive open system architecture and the Ethernet time synchronization protocol.

Benefits of technology

It reduces the difficulty and cost of time synchronization implementation and simplifies the time synchronization process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120263329A_ABST
    Figure CN120263329A_ABST
Patent Text Reader

Abstract

The invention relates to the field of vehicle-mounted communication, and discloses a time synchronization method and system and a storage medium, the method is applied to an electronic control unit, the electronic control unit serves as a main node, and the method comprises the following steps: when a time synchronization protocol module based on a current node receives a time synchronization request sent by a downstream node, the downstream node sends the time synchronization request to the downstream node; reading a current global time base from a synchronization time base management module of the current node; and based on the time synchronization protocol module of the current node, feeding back the current global time base to the downstream node. According to the technical scheme of the invention, the implementation difficulty and implementation cost of time synchronization can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of vehicle communication, and particularly to a time synchronization method, system, and storage medium. Background Art

[0002] To meet the requirements of automotive application scenarios with strict time synchronization requirements, such as airbag control systems and braking systems, AUTOSAR (Auto Motive Open System Architecture) Classic Platform defines relevant time synchronization solutions, mainly implemented by combining the StbM (Synchronized Time-Base Manager) with time synchronization modules on different buses. Among them, the time synchronization module on the Ethernet bus is EthTSyn (Ethernet Time Synchronization), which is based on the IEEE802.1AS protocol, that is, gptp (generalized Precision Time Protocol).

[0003] However, the gptp protocol is relatively complex in software implementation and depends on implementation conditions such as hardware timestamps. Moreover, the time synchronization solution of AUTOSAR makes a certain degree of trimming to the gptp protocol during implementation. Also, many vehicle-mounted systems do not natively support the gptp protocol, and purchasing related protocol stacks will bring higher costs.

[0004] In view of this, the present invention is specifically proposed. Summary of the Invention

[0005] To solve the above technical problems, the present invention provides a time synchronization method, system, and storage medium, achieving the effects of reducing the implementation difficulty and cost of time synchronization.

[0006] An embodiment of the present invention provides a time synchronization method, which is applied to an electronic control unit, and the electronic control unit serves as a master node. The method includes:

[0007] When a time synchronization request sent by a downstream node is received based on the time synchronization protocol module of the current node, read the current global time base from the synchronization time base management module of the current node;

[0008] Based on the time synchronization protocol module of the current node, feedback the current global time base to the downstream node.

[0009] An embodiment of the present invention provides a time synchronization method, which is applied to an electronic control unit. The electronic control unit serves as a slave node, and the method includes:

[0010] Based on the time synchronization protocol module of the current node, send a time synchronization request to the upstream node to receive the current global time base fed back by the upstream node; wherein, the current global time base fed back by the upstream node is read from the synchronization time base management module of the upstream node by the time synchronization protocol module of the upstream node.

[0011] Based on the time synchronization protocol module of the current node, correct the current global time base of the current node according to the current global time base fed back by the upstream node, and send the corrected current global time base to the synchronization time base management module of the current node.

[0012] An embodiment of the present invention provides a time synchronization system, which includes: a global master node, a gateway node, and a global slave node; the global master node performs time synchronization with the global slave node via at least one gateway node;

[0013] Among them, the electronic control unit corresponding to the global master node is used to execute the time synchronization method described in any embodiment; the electronic control unit corresponding to the gateway node is used to execute the time synchronization method described in any embodiment; the electronic control unit corresponding to the global slave node is used to execute the time synchronization method described in any embodiment.

[0014] An embodiment of the present invention provides a computer-readable storage medium, which stores a program or instructions, and the program or instructions cause a computer to execute the steps of the time synchronization method described in any embodiment.

[0015] The embodiment of the present invention has the following technical effects:

[0016] In the case that the time synchronization protocol module of the current node receives a time synchronization request sent by a downstream node, read the current global time base from the synchronization time base management module of the current node, and based on the time synchronization protocol module of the current node, feed back the current global time base to the downstream node, and perform time distribution processing on the downstream node in combination with the time synchronization protocol module of the automotive open system architecture and the time synchronization protocol of Ethernet. Compared with using the gptp protocol for time synchronization, it achieves the effect of reducing the implementation difficulty and implementation cost of time synchronization. Description of the Drawings

[0017] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0018] Figure 1 is a flowchart of a time synchronization method provided by an embodiment of the present invention;

[0019] Figure 2 is a timing diagram of a time synchronization method provided by an embodiment of the present invention;

[0020] Figure 3 is a flowchart of another time synchronization method provided by an embodiment of the present invention;

[0021] Figure 4 is a timing diagram of another time synchronization method provided by an embodiment of the present invention;

[0022] Figure 5 is a schematic structural diagram of an electronic control unit provided by an embodiment of the present invention;

[0023] Figure 6 is a schematic structural diagram of a time synchronization system provided by an embodiment of the present invention. Specific Embodiments

[0024] To make the objectives, technical solutions and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions of the present invention. Obviously, the described embodiments are only some of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.

[0025] The time synchronization method provided by the embodiments of the present invention is mainly applicable to the case of performing time synchronization to downstream nodes according to the requirements of downstream nodes. The time synchronization method provided by the embodiments of the present invention can be executed by an Electronic Control Unit (ECU).

[0026] Figure 1It is a flowchart of a time synchronization method provided by an embodiment of the present invention. This method is applied to an electronic control unit and is used when the electronic control unit acts as the master node. It can be understood that, as the current node, in the process of the current time synchronization method, it can be used as the master node of other slave nodes, that is, the master node sends time to the slave node. However, the current node can also be used as the slave node of other master nodes in the subsequent process of the time synchronization method, that is, the slave node receives the time sent by the master node. Specifically, attention needs to be paid to the position and role of the current node in the entire time synchronization architecture. Refer to Figure 1 , the time synchronization method specifically includes:

[0027] S110. When the time synchronization protocol module based on the current node receives a time synchronization request sent by a downstream node, read the current global time base from the synchronization time base management module of the current node.

[0028] Among them, the current node is the current electronic control unit, and the downstream node is another electronic control unit that receives the time sent by the current node. The current node and the downstream node are equivalent to the master node and the slave node in time synchronization. It can be understood that the current node is the time provider, and the downstream node is the party whose time is to be synchronized. It should be noted that the current node is the upstream node corresponding to the downstream node at this time. The time synchronization protocol module (Network Time Protocol, NTP) is a protocol used to synchronize the clock of a computer system. It can provide high-precision time synchronization. In this example, it can be used to synchronize the current global time base to StbM, or obtain the current global time base from StbM and send it to other downstream nodes for time synchronization. The time synchronization request is a request sent by the downstream node to the current node to request the current global time base for time synchronization. The synchronization time base management module is mainly responsible for creating and managing the synchronization time base, maintaining the local time and the global time, supporting the time synchronization protocol module through different buses to send time to other downstream nodes, or receiving the time sent by other upstream nodes, and can also act as a gateway for time synchronization. In addition, it has functions such as rate correction. The current global time base is the global time base composed of the current local time and the global time stored inside the current node. For example, it can be in the form of [local time, global time], etc.

[0029] Specifically, the downstream node corresponding to the current node can send a time synchronization request to the current node based on a preset period. When the time synchronization protocol module of the current node receives the time synchronization request sent by the downstream node, it needs to respond to the time synchronization request and finally feedback the current global time base of the current node for the downstream node to perform time synchronization processing. The synchronization time base management module of the current node maintains the current global time base of the current node. Therefore, the time synchronization protocol module of the current node can read the current global time base from it.

[0030] Based on the above example, when the time synchronization protocol module based on the current node receives a time synchronization request sent by a downstream node, before reading the current global time base from the synchronization time base management module of the current node, that is, when the initially started ECU performs the initialization of the current global time base and establishes a communication connection with the downstream node, specifically:

[0031] Based on the synchronization time base management module of the current node, initialize the current global time base and determine that the update status of the current global time base is the initial state;

[0032] Based on the time synchronization protocol module of the current node, establish a socket connection with the time synchronization protocol module of the downstream node.

[0033] Among them, the update status is used to describe the update situation of the current global time base. For example, the initial state, valid state, timeout state, and jump state, etc. The initial state is the state after initialization, and it is usually unavailable at this time. A socket connection is an abstract connection of the endpoints for two-way communication between the current node and the downstream node, used to implement socket communication.

[0034] Specifically, when initially starting the ECU, the synchronization time base management module of the current node can be used to initialize the current global time base of the current node. For example, the format of the current global time base is [local time, global time], and after initialization, it is [0,0], etc. Furthermore, determine that the update status of the current global time base is the initial state, indicating that only the initialization process has been performed on the current global time base. Based on the time synchronization protocol module of the current node, send a connection request to the time synchronization protocol module of the downstream node. When the time synchronization protocol module of the downstream node responds to this connection request, a socket connection is established between the time synchronization protocol module of the current node and the time synchronization protocol module of the downstream node, which is used for subsequent transmission of time synchronization requests and the corresponding current global time base of the time synchronization request, etc.

[0035] S120. Based on the time synchronization protocol module of the current node, feedback the current global time base to the downstream node.

[0036] Specifically, the obtained current global time base can be sent to the downstream node through the time synchronization protocol module of the current node, and this current global time base is the feedback information corresponding to the time synchronization request. It can be based on the pre-established socket connection to feedback the current global time base to the time synchronization protocol module of the downstream node.

[0037] Based on the above example, the following method can be used to feedback the current global time base to the downstream node based on the time synchronization protocol module of the current node:

[0038] The time synchronization protocol module based on the current node performs time format conversion on the current global time base and updates the current global time base;

[0039] Based on the time synchronization protocol module of the current node, the updated current global time base is fed back to the downstream node through the socket connection between the time synchronization protocol module of the current node and the time synchronization protocol module of the downstream node.

[0040] Specifically, since the format of the current global time base stored in the synchronization time base management module of the current node is different from the format of the regional global time base sent by the time synchronization protocol module of the current node through the socket connection, time format conversion is required. For example: the format of the time stamp of the global time is defined in the specification of the synchronization time base management module and consists of a 16-bit high part of seconds, a 32-bit part of seconds, and a 32-bit part of nanoseconds. To ensure that the time stamp formats in the synchronization time base management module and the time synchronization protocol module are consistent, the 16-bit high part of seconds can be processed, such as default filling with 0. Therefore, the time synchronization protocol module of the current node can perform time format conversion on the current global time base and update the current global time base so that the format of the current global time base adapts to the time synchronization protocol module of the current node. Furthermore, the time synchronization protocol module of the current node feeds back the updated current global time base to the time synchronization protocol module of the downstream node through the socket connection between the time synchronization protocol module of the current node and the time synchronization protocol module of the downstream node, so that the downstream node can perform time synchronization based on the received current global time base.

[0041] It can be understood that when the downstream node sends a time synchronization request, it will carry the send request time stamp. When the current node receives this time synchronization request, it will add a receive request time stamp. When the current node feeds back the current global time base, it will carry a feedback send time stamp. These time stamps will be sent to the time synchronization protocol module of the downstream node together when transmitting the current global time base.

[0042] It can be understood that the current node (electronic control unit) can be the global master node or the gateway node as the master node. Among them, the global master node does not accept time synchronization from other nodes, and the gateway node can receive time synchronization from other nodes.

[0043] Based on the above example, if the current node is the global master node, it cannot be time synchronized by other ECUs. The time synchronization system application of the current node needs to provide clock source data to set the current global time. Specifically, it can be:

[0044] When the synchronization time base management module of the current node receives the current global time set by the time synchronization system application of the current node, it updates the current global time base and determines that the update status of the current global time base is the valid status;

[0045] Based on the synchronization time base management module of the current node, the current global time base is updated according to the local time of the current node.

[0046] Among them, when the time synchronization system application (Time-Software Component, TM-SWC) is used as the master node at the current node, it provides clock source data, such as the standard time obtained from GPS (Global Positioning System) or the monotonically increasing time when the ECU starts, etc., and can call the interface of the synchronization time base management module to read and use the global time. The current global time is the time set by the time synchronization system application of the current node, which can be understood as the standard global time. The valid status indicates that the current global time base is in a state of real-time update and can be used effectively. The local time is the time recorded by the synchronization time base management module of the current node itself. For example, the local time can be updated based on devices that stably provide clock signals such as crystal oscillators.

[0047] Specifically, the time synchronization system application of the current node can be used periodically to set the current global time of the synchronization time base management module of the current node to ensure the accuracy of the current global time. When the synchronization time base management module of the current node receives the current global time set by the time synchronization system application of the current node, the time base composed of the current global time and the current local time is used as the new current global time base, and the update status of the current global time base is determined to be the valid status. When the global time set by the time synchronization system application is not received, through the synchronization time base management module of the current node, combined with the local time of the current node in the synchronization time base management module, as the local time changes, a new current global time is calculated. Furthermore, the current global time base can be updated with the real-time changing local time and the current global time.

[0048] Exemplarily, Figure 2 is a timing diagram of a time synchronization method provided by an embodiment of the present invention. As Figure 2As shown in the figure, where Master represents the master node, which is the current node in this example, and Slave represents the slave node, which is the downstream node in this example. Initialize each module, create information such as the current global time base and socket ports in StbM according to the static configuration file to establish a socket connection between the master node and the slave node. And, perform the following steps periodically: TM-SWC calls the API (Application Programming Interface) of the AUTOSAR StbM standard to set the global time. Furthermore, StbM uses the set global time to update and maintain the current global time base. When the NTP module receives a time synchronization request, it calls the AUTOSAR standard interface to obtain the timestamp of the current global time base from the StbM module, performs time format conversion, and constructs an NTP packet (current global time base) together with other parameters. The NTP module calls the socket interface to send the NTP packet. The socket module is configured with information such as the port parameters used by NTP to call the Udp (User Datagram Protocol) interface of Tcp / Ip (Transmission Control Protocol / Internet Protocol) to send the NTP packet. The Tcp / Ip module calls the Ethernet driver hardware to send the packet to the slave node, thus completing the time synchronization response.

[0049] The present invention has the following technical effects: In the case where the time synchronization protocol module based on the current node receives a time synchronization request sent by the downstream node, read the current global time base from the synchronization time base management module of the current node, and based on the time synchronization protocol module of the current node, feedback the current global time base to the downstream node, combine the time synchronization protocol module of the automotive open system architecture and the time synchronization protocol of the Ethernet, and perform time dissemination processing on the downstream node. Compared with using the gptp protocol for time synchronization, it achieves the effect of reducing the implementation difficulty and implementation cost of time synchronization.

[0050] The time synchronization method provided by the embodiment of the present invention is applied to an electronic control unit, and is mainly applicable to the situation of receiving the current global time base fed back by the upstream node as a slave node and performing correction processing. It can be understood that the slave node in the current example may also be the master node in the above example, and there is a transformation in the node identity during time synchronization. The current node (electronic control unit) as a slave node can be a global slave node or a gateway node. Among them, the global slave node cannot disseminate time to other nodes, and the gateway node can disseminate time to other nodes. The time synchronization method provided by the embodiment of the present invention can be executed by the electronic control unit.

[0051] Figure 3 It is a flowchart of another time synchronization method provided by an embodiment of the present invention. Refer to Figure 3 , the time synchronization method specifically includes:

[0052] S210. Based on the time synchronization protocol module of the current node, send a time synchronization request to the upstream node to receive the current global time base fed back by the upstream node.

[0053] Among them, the current global time base fed back by the upstream node is the current global time base read by the time synchronization protocol module of the upstream node from the synchronization time base management module of the upstream node.

[0054] It can be understood that the upstream node is an electronic control unit that provides timing to the current node. The upstream node and the current node are equivalent to the master node and the slave node of time synchronization. It can be understood that the upstream node is the time provider and the current node is the time to be synchronized. It should be noted that the current node is the downstream node corresponding to the upstream node at this time.

[0055] Specifically, the current node needs to periodically or according to the time synchronization requirement, based on the time synchronization protocol module of the current node, send a time synchronization request to the upstream node to receive the current global time base fed back by the upstream node, and process the received current global time base to synchronously update the current global time base inside the current node.

[0056] S220. Based on the time synchronization protocol module of the current node, correct the current global time base of the current node according to the current global time base fed back by the upstream node, and send the corrected current global time base to the synchronization time base management module of the current node.

[0057] Specifically, since the current global time base fed back by the upstream node received by the time synchronization protocol module of the current node is the time base corresponding to the reading in the synchronization time base management module of the upstream node, there is a certain error from the current time. Therefore, it is necessary to calculate the reading time, transmission time, etc. in combination with the information transmission process to correct the current global time base fed back by the upstream node to obtain the current global time base of the current node, that is, the current global time base corresponding to the current local time of the current node. Further, the corrected current global time base can be sent to the synchronization time base management module of the current node through the time synchronization protocol module of the current node.

[0058] Based on the above example, the following method can be used to correct the current global time base of the current node according to the current global time base fed back by the upstream node:

[0059] The time synchronization protocol module based on the current node determines the global timestamp correction value according to the current global time base fed back by the upstream node and each target timestamp;

[0060] Based on the time synchronization protocol module of the current node, the current global time base of the current node is corrected according to the global timestamp correction value and the local time of the current node.

[0061] Among them, the target timestamps include the local timestamp when the current node sends a time synchronization request, the local timestamp when the current node receives the current global time base fed back by the upstream node, the local timestamp when the upstream node receives the time synchronization request, and the local timestamp when the upstream node sends the current global time base fed back by the upstream node. The global timestamp correction value is the global timestamp when the time synchronization protocol module of the current node receives the current global time base.

[0062] Specifically, using the time synchronization protocol module of the current node and combining each target timestamp, the time difference between the current global time base fed back by the upstream node and the current node receiving the current global time base can be calculated. Adding this time difference to the global time in the current global time base fed back by the upstream node can obtain the global timestamp correction value. Furthermore, by using the time synchronization protocol module of the current node to read the local time of the current node and combining it with the global timestamp correction value, the current global time base of the current node can be obtained.

[0063] For example, the local timestamp when the current node sends a time synchronization request is T1, the local timestamp when the current node receives the current global time base fed back by the upstream node is T2, the local timestamp when the upstream node receives the time synchronization request is T3, and the local timestamp when the upstream node sends the current global time base fed back by the upstream node is T4. Then, the time consumed by the current node from sending the time synchronization request to receiving the feedback of the current global time base is T4 - T1, and the time consumed by the upstream node from receiving the time synchronization request to feeding back the current global time base is T3 - T2. Then, the round-trip information transfer time is (T4 - T1) - (T3 - T2). Furthermore, the time difference between the current global time base fed back by the upstream node and the current node receiving the current global time base can be calculated as [(T4 - T1) - (T3 - T2)] / 2. Of course, other methods can also be used for global timestamp correction, which will not be elaborated here.

[0064] Based on the above example, after sending the corrected current global time base to the synchronous time base management module of the current node, the rate correction of the time flow rate can be performed, the current global time base can be updated again, and the corresponding update status can be updated. Specifically, it can be:

[0065] The synchronization time base management module based on the current node performs rate correction according to the corrected current global time base to obtain the current global time base after rate correction;

[0066] The synchronization time base management module based on the current node determines whether there is a jump between the current global time base after rate correction and the stored current global time base; if so, the current global time base of the current node is updated according to the current global time base after rate correction, and the corresponding update status is determined as the jump state; if not, the current global time base of the current node is updated according to the current global time base after rate correction, and the corresponding update status is determined as the valid state.

[0067] Among them, rate correction is to calculate a ratio r of the time change rate between the slave node and the master node. The time flow rates of the master node and the slave node may be different due to reasons such as crystal oscillator errors. When the slave node provides time to the application layer, the parameter r will be attached to the global time base for correction. The jump state is a state where the current global time base updated according to the local time has a large difference from the received current global time base.

[0068] Specifically, through the synchronization time base management module of the current node, rate correction is performed on the corrected current global time base to obtain the current global time base after rate correction. Furthermore, it is determined whether there is a jump between the current global time base after rate correction and the stored current global time base, that is, whether the global time difference between the two current global time bases exceeds a preset difference. If so, there is a jump; if not, there is no jump. If there is a jump, the current global time base of the current node is updated using the current global time base after rate correction and the current local time, and the corresponding update status is determined as the jump state. If not, the current global time base of the current node is updated using the current global time base after rate correction and the current local time, and the corresponding update status is determined as the valid state.

[0069] Based on the above example, an overtime state can also be set when the time has not been synchronized from the upstream node for a long time, and the global time base can be read by other applications. Specifically, it can be:

[0070] In response to the autonomous maintenance duration of the current global time base in the synchronization time base management module of the current node exceeding the preset duration, the corresponding update status is determined as the overtime state;

[0071] In response to the synchronization time base management module of the current node receiving a time reading request sent by the time synchronization system application of the current node, the current global time base of the current node and the corresponding update status are fed back to the time synchronization system application of the current node.

[0072] Among them, the self-maintenance duration is the duration for which the current node maintains and updates the global time according to the local time flow rate. The preset duration is the duration preset for determining whether the current global time base has timed out without being synchronized and updated. The time reading request is a request for an external application to read the global time.

[0073] Specifically, in the synchronization time base management module of the current node, once the current global time base is synchronized, the self-maintenance time can be cleared and the timing restarted to obtain the self-maintenance duration of the current global time base. If the self-maintenance duration of the current global time base exceeds the preset duration, it indicates that the time synchronization with the upstream node has not been performed for a long time, and there may be a time error. Therefore, the corresponding update status can be determined as the timeout status. When the synchronization time base management module of the current node receives a time reading request sent by the time synchronization system application of the current node, it can feedback the current global time base of the current node and the corresponding update status to the time synchronization system application of the current node, so that the external application can read the global time.

[0074] Exemplarily, Figure 4 is a timing diagram of another time synchronization method provided by an embodiment of the present invention. As Figure 4 shown, where Master represents the master node, which is the upstream node in this example, and Slave represents the slave node, which is the current node in this example.

[0075] Initialize each module, create information such as the current global time base and socket port in the StbM according to the static configuration file to establish a socket connection between the master node and the slave node. Periodically execute the following steps: The NTP module of the slave node, as a client, actively sends a data packet for a time synchronization request. The local timestamp can be obtained from the corresponding StbM module. Call the relevant module of the Ethernet protocol stack to send the data packet for the time synchronization request. The NTP module receives the response data packet (the current global time base fed back by the upstream node) from the master node, and calculates the global time (the global timestamp correction value) according to the NTP protocol specification. The NTP module calls the API of the AUTOSAR StbM standard to obtain the local timestamp and update the current global time base of the current node, that is, the time tuple information of [global time, local time]. The NTP module calls the API of the AUTOSAR StbM standard for the bus to set the global time interface and passes the time tuple information (the current global time base) to the StbM module. The StbM updates the current global time base according to the passed-in information, performs rate correction, and sets the corresponding update status, etc. The TM-SWC can call the API of the StbM standard to obtain the time interface, and then read the updated global time and the update status.

[0076] The present invention has the following technical effects: Based on the time synchronization protocol module of the current node, a time synchronization request is sent to the upstream node to receive the current global time base fed back by the upstream node. Based on the time synchronization protocol module of the current node, according to the current global time base fed back by the upstream node, the current global time base of the current node is corrected, and the corrected current global time base is sent to the synchronization time base management module of the current node. Combining the time synchronization protocol module of the automotive open system architecture and the time synchronization protocol of Ethernet, time is synchronized to the downstream nodes. Compared with using the gptp protocol for time synchronization, the effects of reducing the implementation difficulty and implementation cost of time synchronization are achieved.

[0077] Figure 5 FIG. 4 is a schematic structural diagram of an electronic control unit provided by an embodiment of the present invention. As Figure 5 shown, the electronic control unit 300 includes one or more processors 301 and a memory 302.

[0078] The processor 301 may be a central processing unit (CPU) or other form of processing unit having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic control unit 300 to perform desired functions.

[0079] The memory 302 may include one or more computer program products, and the computer program products may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory, etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 301 may run the program instructions to implement the time synchronization method of any embodiment of the present invention described above and / or other desired functions. Various contents such as initial external parameters and thresholds may also be stored in the computer-readable storage medium.

[0080] In one example, the electronic control unit 300 may further include: an input device 303 and an output device 304, and these components are interconnected through a bus system and / or other forms of connection mechanisms (not shown). The input device 303 may include, for example, a keyboard, a mouse, etc. The output device 304 may output various information to the outside, including warning prompt information, braking force, etc. The output device 304 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.

[0081] Of course, for simplicity, Figure 5Only some of the components related to the present invention in the electronic control unit 300 are shown, and components such as buses, input / output interfaces, etc. are omitted. In addition, according to specific application scenarios, the electronic control unit 300 may further include any other appropriate components.

[0082] Figure 6 is a schematic structural diagram of a time synchronization system provided by an embodiment of the present invention. As Figure 6 shown, the system includes: a global master node, a gateway node, and a global slave node; the global master node synchronizes time with the global slave node via at least one gateway node;

[0083] Among them, the electronic control unit corresponding to the global master node is used to execute the time synchronization method provided by the corresponding embodiments such as Figure 1 and Figure 2 ; the electronic control unit corresponding to the gateway node is used to execute the steps of the time synchronization method provided by the corresponding embodiments such as Figure 1 and Figure 2 and the steps of the time synchronization method provided by the corresponding embodiments such as Figure 3 and Figure 4 ; the electronic control unit corresponding to the global slave node is used to execute the steps of the time synchronization method provided by any embodiment of the present invention.

[0084] In addition to the above methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions that cause the processor to execute the steps of the time synchronization method provided by any embodiment of the present invention when the computer program instructions are run by the processor.

[0085] The computer program product can be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present invention. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, executed as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0086] In addition, an embodiment of the present invention may also be a computer-readable storage medium, on which computer program instructions are stored, and the computer program instructions cause the processor to execute the steps of the time synchronization method provided by any embodiment of the present invention when the computer program instructions are run by the processor.

[0087] The computer-readable storage medium may adopt any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0088] It should be noted that the terms used in the present invention are only for describing specific embodiments and do not limit the scope of the present application. As shown in the specification of the present invention, unless the context clearly indicates an exception, words such as "a", "an", "one", and / or "the" are not specifically singular and may also include the plural. The term "comprising", "including", or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, or device including a series of elements not only includes those elements but also includes other elements not expressly listed, or also includes elements inherent to such process, method, or device. Without further limitation, an element defined by the statement "including one..." does not exclude the presence of additional identical elements in the process, method, or device including the said element.

[0089] It should also be noted that the orientation or positional relationship indicated by terms such as "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Unless otherwise clearly specified and defined, terms such as "installed", "connected", "coupled" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or an integral connection; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two elements. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention may be understood according to specific circumstances.

[0090] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the technical solutions of the embodiments of the present invention.

Claims

1. A time synchronization method, characterized in that, Applied to an electronic control unit, the electronic control unit serves as a master node and includes: When the time synchronization protocol module based on the current node receives a time synchronization request sent by a downstream node, read the current global time base from the synchronization time base management module of the current node; Based on the time synchronization protocol module of the current node, feedback the current global time base to the downstream node.

2. The method according to claim 1, characterized in that, Before reading the current global time base from the synchronization time base management module of the current node when the time synchronization protocol module based on the current node receives a time synchronization request sent by a downstream node, it further includes: Based on the synchronization time base management module of the current node, initialize the current global time base and determine that the update status of the current global time base is the initial state; Based on the time synchronization protocol module of the current node, establish a socket connection with the time synchronization protocol module of the downstream node.

3. The method according to claim 1, wherein When the current node is the global master node, it further includes: When the synchronization time base management module of the current node receives the current global time set by the time synchronization system application of the current node, update the current global time base and determine that the update status of the current global time base is the valid state; Based on the synchronization time base management module of the current node, update the current global time base according to the local time of the current node.

4. The method according to claim 1, wherein The step of feedbacking the current global time base to the downstream node based on the time synchronization protocol module of the current node includes: Based on the time synchronization protocol module of the current node, perform time format conversion on the current global time base and update the current global time base; Based on the time synchronization protocol module of the current node, through the socket connection between the time synchronization protocol module of the current node and the time synchronization protocol module of the downstream node, feedback the updated current global time base to the downstream node.

5. A time synchronization method, characterized in that, Applied to an electronic control unit, the electronic control unit serves as a slave node and includes: Based on the time synchronization protocol module of the current node, send a time synchronization request to the upstream node to receive the current global time base feedback by the upstream node; wherein, the current global time base feedback by the upstream node is read from the synchronization time base management module of the upstream node by the time synchronization protocol module of the upstream node; Based on the time synchronization protocol module of the current node, correct the current global time base of the current node according to the current global time base feedback by the upstream node and send the corrected current global time base to the synchronization time base management module of the current node.

6. The method according to claim 5, wherein The step of correcting the current global time base of the current node according to the current global time base feedback by the upstream node includes: Based on the time synchronization protocol module of the current node, determine the global time stamp correction value according to the current global time base feedback by the upstream node and each target time stamp; Based on the time synchronization protocol module of the current node, the current global time base of the current node is corrected according to the global timestamp correction value and the local time of the current node; Among them, the target timestamp includes the local timestamp when the current node sends the time synchronization request, the local timestamp when the current node receives the current global time base fed back by the upstream node, the local timestamp when the upstream node receives the time synchronization request, and the local timestamp when the upstream node sends the current global time base fed back by the upstream node.

7. The method according to claim 5, characterized in that, After sending the corrected current global time base to the synchronization time base management module of the current node, it further includes: Based on the synchronization time base management module of the current node, rate correction is performed according to the corrected current global time base to obtain the rate-corrected current global time base; Based on the synchronization time base management module of the current node, it is determined whether there is a jump between the rate-corrected current global time base and the stored current global time base; if so, the current global time base of the current node is updated according to the rate-corrected current global time base, and the corresponding update status is determined as the jump state; if not, the current global time base of the current node is updated according to the rate-corrected current global time base, and the corresponding update status is determined as the valid state.

8. The method according to claim 5, characterized in that It further includes: In response to the autonomous maintenance duration of the current global time base in the synchronization time base management module of the current node exceeding the preset duration, the corresponding update status is determined as the timeout state; In response to the synchronization time base management module of the current node receiving a time reading request sent by the time synchronization system application of the current node, the current global time base of the current node and the corresponding update status are fed back to the time synchronization system application of the current node.

9. A time synchronization system, characterized in that, It includes: A global master node, a gateway node, and a global slave node; The global master node performs time synchronization with the global slave node via at least one gateway node; Among them, the electronic control unit corresponding to the global master node is used to execute the time synchronization method according to any one of claims 1 to 4; the electronic control unit corresponding to the gateway node is used to execute the time synchronization method according to any one of claims 1 to 4 and the time synchronization method according to any one of claims 5 to 8; the electronic control unit corresponding to the global slave node is used to execute the time synchronization method according to any one of claims 5 to 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program or instruction, and the program or instruction causes the computer to execute the steps of the time synchronization method according to any one of claims 1 to 4 and / or the time synchronization method according to any one of claims 5 to 8.