Vehicle-mounted clock synchronization method, device and system and storage medium
Through the redundant design of the master clock and the hot standby master clock, each working domain is configured with a separate physical clock. By using the preset priority order and time difference judgment, it can quickly switch to the target working domain, solving the problem of time-consuming clock synchronization switching and achieving high-precision and high-reliability clock synchronization.
Patent Information
- Application Number
- CN202510743284.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-16
AI Technical Summary
In the prior art, it takes a long time to switch the clock synchronization to the backup domain, resulting in a short period of clock asynchrony during the switch, which affects the accuracy of clock synchronization.
A redundant design with a master clock and a hot standby master clock is adopted. Each working domain is configured with a separate physical clock. By monitoring the working domain status and the preset priority order, the system quickly switches to the target working domain that meets the error requirements for clock synchronization, and switches back to the high-priority working domain after it recovers.
It realizes seamless switching, improves the accuracy and reliability of clock synchronization, avoids large time deviation before and after switching, and achieves high-precision and high-reliability clock synchronization.
Smart Images

Figure CN120658340A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of clock synchronization, and in particular to a vehicle-mounted clock synchronization method, device, system and storage medium. Background Art
[0002] With the rapid development of automotive electronics technology, in-vehicle networks have placed higher requirements on the accuracy and reliability of time synchronization. As a high-precision clock synchronization technology, the Generalized Precision Time Protocol (gPTP) in Time-Sensitive Networking (TSN) is widely used in in-vehicle networks to meet the high time synchronization requirements of autonomous driving, advanced driver assistance systems, and in-vehicle infotainment systems.
[0003] Currently, existing technologies typically use redundant designs and path switching mechanisms. When a link fails, the clock node switches to the backup domain within three clock synchronization cycles and uses the backup domain's messages for clock synchronization. However, with this clock synchronization method, when a failure is detected and the system switches to the backup domain, the clock needs to go through a process of transitioning from an unlocked state to a clock adjustment state before finally reaching a stable state, which takes a certain amount of time. During the switching period, the system may experience brief clock asynchrony, resulting in a large time deviation before and after the switch, causing clock jumps and affecting the accuracy of clock synchronization. Summary of the Invention
[0004] In view of this, the present invention aims to propose a vehicle-mounted clock synchronization method, device, system and storage medium to solve the problem that the current clock synchronization switching to the backup domain takes a long time, and a brief clock asynchrony occurs during the switching, resulting in a large time deviation before and after the switching, affecting the accuracy of clock synchronization.
[0005] According to a first aspect of the present invention, a vehicle-mounted clock synchronization method is provided, which is applied to a vehicle-mounted clock synchronization system. The system includes a master clock and a hot standby master clock. The master clock and the hot standby master clock are respectively configured with multiple working domains, and each of the working domains is configured with a physical clock. The method includes: In response to the master clock and the hot standby master clock being started, using the physical clock of the current working domain for clock synchronization; Detecting that the clock state of the current working domain is a fault state, determining a target working domain to be switched according to a preset working domain priority order; wherein the preset working domain priority order includes that the priority of the master clock working domain is higher than the priority of the hot standby master clock working domain; Obtaining a first switching time difference between the physical clocks of the current working domain and the target working domain, and if the first switching time difference satisfies a preset error, switching the current working domain to the target working domain, and using the physical clock of the target working domain for clock synchronization; When it is monitored that the high-priority working domain corresponding to the target working domain has returned to normal, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
[0006] Optionally, in response to the master clock and the hot standby master clock being started, using the physical clock of the current working domain to perform clock synchronization includes: In response to the master clock and the hot standby master clock being started, initializing the master clock and the hot standby master clock; According to the preset working domain priority order, the working domain with the highest priority among the master clock and the hot backup clock is determined as the current working domain; The physical clock of the current working domain is synchronized to the terminal node of the vehicle-mounted clock synchronization system.
[0007] Optionally, the vehicle-mounted clock synchronization system includes a time-sensitive network switch, and the monitoring that the clock state of the current working domain is a fault state determines the target working domain to be switched according to a preset working domain priority order, including: Monitor a clock corresponding to the current working domain and a time-sensitive network switch to determine a clock state of the current working domain; detecting that the clock state of the current working domain is a fault state, and determining a working domain of a lower priority corresponding to the current working domain according to a preset working domain priority order; wherein the lower priority working domain includes at least one working domain having a lower priority than the current working domain; A working domain with a lower priority corresponding to the current working domain is determined as a target working domain to be switched.
[0008] Optionally, monitoring a clock corresponding to the current working domain and a time-sensitive network switch to determine a clock state of the current working domain includes: Monitoring the transmission link and clock jitter of the synchronization message in the clock corresponding to the current working domain and the time-sensitive network switch; Recording the number of times the synchronization message is lost in the transmission link and the clock jitter value; If the number of times the synchronization message is lost within a preset time period exceeds a preset number or the clock jitter value is greater than a preset threshold, the clock state of the current working domain is a fault state.
[0009] Optionally, obtaining a first switching time difference between the physical clocks of the current working domain and the target working domain, and switching the current working domain to the target working domain when the first switching time difference satisfies a preset error, and using the physical clock of the target working domain for clock synchronization includes: Obtaining timestamps of the physical clocks of the current working domain and the target working domain, and calculating a first switching time difference between the physical clocks of the current working domain and the target working domain based on the timestamps; Comparing the first switching time difference with a preset error value to obtain a comparison result; If the comparison result shows that the first switching time difference satisfies a preset error, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for clock synchronization.
[0010] Optionally, after comparing the first switching time difference with a preset error value to obtain a comparison result, the method further includes: If the comparison result shows that the first switching time difference does not meet a preset error, determining a next working domain of a second priority corresponding to the target working domain according to a preset working domain priority order; Obtain a third switching time difference between the physical clocks of the current working domain and the next working domain. When the third switching time difference satisfies a preset error, switch the current working domain to the next working domain, and use the physical clock of the next working domain for clock synchronization.
[0011] Optionally, the monitoring that the high-priority working domain corresponding to the target working domain has returned to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain satisfies a preset error, switching the target working domain back to the high-priority working domain, and using the physical clock of the high-priority working domain for clock synchronization includes: Regularly monitoring a high-priority working domain corresponding to the target working domain to determine a current clock state of the high-priority working domain; wherein the high-priority working domain includes at least one working domain having a priority higher than that of the target working domain; monitoring that the high-priority working domain returns to a normal state, and obtaining a second switching time difference between the physical clocks of the target working domain and the high-priority working domain; When the second switching time difference satisfies a preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
[0012] According to a second aspect of the present invention, a vehicle-mounted clock synchronization device is provided, which is applied to a vehicle-mounted clock synchronization system. The system includes a master clock and a hot standby master clock. The master clock and the hot standby master clock are respectively configured with multiple working domains, each of which is configured with a physical clock. The device includes: A first synchronization module is configured to perform clock synchronization using a physical clock of a current working domain in response to the master clock and the hot standby master clock being started; A working domain monitoring module is configured to detect that the clock state of the current working domain is a fault state, and determine a target working domain to be switched according to a preset working domain priority order; wherein the preset working domain priority order includes that the priority of the master clock working domain is higher than the priority of the hot standby master clock working domain; a switching working domain module, configured to obtain a first switching time difference between the physical clocks of the current working domain and the target working domain, and when the first switching time difference satisfies a preset error, switch the current working domain to the target working domain, and use the physical clock of the target working domain for clock synchronization; The second synchronization module is used to monitor that the high-priority working domain corresponding to the target working domain has returned to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switch the target working domain back to the high-priority working domain, and use the physical clock of the high-priority working domain for clock synchronization.
[0013] According to a third aspect of the present invention, a vehicle-mounted clock synchronization system is provided for executing the above-mentioned vehicle-mounted clock synchronization method. The system includes a master clock, a hot standby master clock, a time-sensitive network switch, and a terminal node: The master clock and the hot standby master clock are respectively configured with a plurality of working domains, and each of the working domains is configured with a physical clock; The time-sensitive network switch is connected to the master clock, the hot standby master clock and the terminal node; The on-board clock synchronization system starts in response to the master clock and the hot standby master clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, and switches the current working domain to the target working domain when the first switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization.
[0014] According to another aspect of the present invention, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the vehicle-mounted clock synchronization method described above are implemented.
[0015] The vehicle-mounted clock synchronization method provided by an embodiment of the present invention starts up in response to the master clock and the hot standby master clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, switches the current working domain to the target working domain when the switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization. The embodiment of the present invention uses a redundant design of a master clock and a hot standby master clock, and each domain is allocated a separate physical clock. Each domain is simultaneously performing a high-precision time synchronization process. When a fault occurs in the current domain, the switching time difference is immediately judged based on the clock status of the domain to be switched. After the required error is met, the domain is directly switched to for clock synchronization, avoiding clock jumps caused by large time deviations before and after switching, achieving a seamless switching effect, improving the accuracy and reliability of clock synchronization, and monitoring the clock status of the high-priority working domain after switching. After the high-priority fault working domain is restored, it is promptly switched back to the high-priority working domain for clock synchronization, thereby achieving high-precision, high-reliability and automated clock synchronization.
[0016] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings: Figure 1 This is a flowchart of the steps of a vehicle-mounted clock synchronization method provided by an embodiment of the present invention; Figure 2 yes Figure 1 Flowchart of step 101 in the vehicle clock synchronization method provided by an embodiment of the present invention; Figure 3 yes Figure 1 Flowchart of step 102 in the vehicle clock synchronization method provided by an embodiment of the present invention; Figure 4 yes Figure 1 Flowchart of step 103 in the vehicle clock synchronization method provided by an embodiment of the present invention; Figure 5 yes Figure 1 Flowchart of step 104 in the vehicle clock synchronization method provided by an embodiment of the present invention; Figure 6 This is a structural diagram of a vehicle-mounted clock synchronization device provided by an embodiment of the present invention; Figure 7 The diagram is a structural diagram of a vehicle-mounted clock synchronization device system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, each embodiment of the present invention will be described in detail below with reference to the accompanying drawings. However, it will be understood by those skilled in the art that in each embodiment of the present invention, many technical details are provided to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in this application can be implemented. The division of the following embodiments is for convenience of description and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined with each other and referenced to each other under the premise that there is no contradiction.
[0019] Reference Figure 1, shows a flowchart of the steps of a vehicle-mounted clock synchronization method provided by an embodiment of the present invention, which is applied to a vehicle-mounted clock synchronization system. The system includes a master clock and a hot standby master clock. The master clock and the hot standby master clock are respectively configured with multiple working domains, and each of the working domains is configured with a physical clock. The method may include: Step 101: In response to the master clock and the hot standby master clock being started, clock synchronization is performed using the physical clock of the current working domain.
[0020] In an embodiment of the present invention, in order to solve the problem that in the current clock synchronization method, when a fault is detected and switched to a backup domain, the clock needs to go through a process of going from an unlocked state to a clock adjustment state and finally reaching a stable state, which takes a long time. The system will experience a brief clock asynchrony during the switching period, resulting in a large time deviation before and after the switching, which affects the accuracy of clock synchronization. This embodiment adopts a ring network topology structure, allocates a separate physical clock to each domain, and each domain is simultaneously performing a high-precision time synchronization process. When the current domain synchronization fails, the clock status information of the domain to be switched to can be immediately obtained and the switching time difference analysis and evaluation can be performed. If the requirements are met, the clock can be directly switched to the domain for clock synchronization, thereby achieving a seamless switching effect, improving the accuracy and reliability of clock synchronization, and realizing high-precision, high-reliability and automated clock synchronization.
[0021] It should be noted that, referring to Figure 7, shows an on-vehicle clock synchronization system applied in an embodiment of the present invention, the system includes a master clock and a hot standby master clock, the master clock and the hot standby master clock are respectively configured with multiple working domains, each working domain is configured with a physical clock, specifically, a ring network topology is adopted, two redundant master clocks are set in the system, one master clock GM and the other hot standby master clock GM, the working domains corresponding to the master clock include the master clock working domain Domain 0 and the master clock backup domain Domain1, the working domains corresponding to the hot standby master clock include the hot standby master clock working domain Domain 2 and the hot standby master clock backup domain Domain3, the system also includes redundant synchronization paths based on the master clock and located in two different domains, namely domain 0 synchronization path and domain 1 synchronization path, and redundant synchronization paths based on the hot standby master clock and located in two different domains, namely domain 2 synchronization path and domain 3 synchronization path. All nodes in the ring synchronization system topology include 4 TSN switches, 2 GMs, and 2 terminal nodes. Four physical clocks are used on these nodes to correspond to four different domains for clock synchronization. The four physical clocks are driven by the operating system and reflected in the application layer of the operating system as devices / dev / ptp0, / dev / ptp1, / dev / ptp2, and / dev / ptp3, which are applied to domain 0, domain 1, domain 2, and domain 3, respectively. Among them, the priority of the four working domains is: domain 0>domain 1>domain 2>domain 3.
[0022] In this embodiment, the on-board clock synchronization system responds to the activation of the master clock and the hot standby master clock by using the physical clock of the current working domain for clock synchronization. The redundant design of the master clock and the hot standby master clock ensures that the system can maintain clock synchronization even if the master clock fails. Based on the preset working domain priority order, the highest priority and available working domain of the master clock and the hot standby master clock is selected as the current working domain. By default, the highest priority working domain of the master clock and the hot standby clock is selected as the current working domain. The physical clock of the current working domain is used for clock synchronization and is synchronized to the terminal node of the on-board clock synchronization system. That is, the master clock sends a Sync message to the terminal node, and the terminal node receives the Sync message and adjusts the local clock according to the timestamp in the message. It should be noted that the Sync message is a key message in PTP (Precision Time Protocol) or gPTP (Generalized Precision Time Protocol) and is used by the master clock to send time synchronization information to the slave clock.
[0023] Step 102, monitor that the clock state of the current working domain is a fault state, and determine the target working domain to be switched according to the preset working domain priority order; wherein the preset working domain priority order includes that the priority of the main clock working domain is higher than the priority of the hot standby main clock working domain.
[0024] In an embodiment of the present invention, the on-board clock synchronization monitors that the clock state of the current working domain is in a fault state, and determines the target working domain to be switched according to the preset working domain priority order. In order to ensure the normal operation of the clock-synchronized working domain, it is necessary to monitor the clock corresponding to the current working domain and the time-sensitive network switch to determine the clock state of the current working domain, wherein the time-sensitive network switch is connected to the master clock, the hot standby master clock and the terminal node, and is used to forward time-sensitive data and support the TSN protocol. By monitoring the status of the clock and the TSN switch in real time, it is timely discovered whether the clock state of the current working domain is faulty. When the clock state of the current working domain is monitored to be in a fault state, the current working domain is determined to have a sub-priority working domain according to the preset working domain priority order, wherein the sub-priority working domain includes at least one working domain with a priority lower than the priority of the current working domain. That is, when the current working domain fails, the next available working domain is selected according to the priority order, the physical clock state of the sub-priority working domain is checked, and the sub-priority working domain is determined as the target working domain to be switched.
[0025] It should be noted that the preset working domain priority order includes the priority of the main clock working domain being higher than the priority of the hot standby main clock working domain. The priority order of the working domains is from high to low: main clock working domain Domain 0, main clock backup domain Domain 1, hot standby main clock working domain Domain 2, and hot standby main clock backup domain Domain 3. For example, if the current working domain is Domain 0, when the clock status of the current working domain Domain 0 is a fault state, according to the working domain priority order, the working domain with a priority lower than the current working domain Domain 0, namely the main clock backup domain Domain 1, is determined as the target working domain to be switched, and so on. They will not be elaborated here.
[0026] Step 103: Obtain a first switching time difference between the physical clocks of the current working domain and the target working domain. When the first switching time difference satisfies a preset error, switch the current working domain to the target working domain and use the physical clock of the target working domain for clock synchronization.
[0027] In an embodiment of the present invention, after determining the target working domain, it is necessary to judge the switching conditions. Specifically, the vehicle-mounted clock synchronization system obtains the first switching time difference between the physical clocks of the current working domain and the target working domain. When the first switching time difference meets the preset error, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for clock synchronization.
[0028] Specifically, the timestamps of the physical clocks of the current working domain and the target working domain can be obtained, and the first switching time difference between the physical clocks of the current working domain and the target working domain can be calculated based on the timestamps. By obtaining the timestamps of the physical clocks and calculating the switching time difference, the accuracy of the error calculation is ensured, and the first switching time difference between the current working domain and the target working domain is compared with the preset error value to obtain a comparison result. When the comparison result is that the first switching time difference meets the preset error, that is, if the comparison result is that the first switching time difference is less than the preset error, the switching operation can be performed to switch the current working domain to the target working domain, and synchronized using the physical clock of the target working domain. By performing the switching when the first switching time difference meets the preset error, the high precision of the switching process is ensured, and the strict switching time difference condition judgment can achieve high-precision clock synchronization.
[0029] Step 104: When it is monitored that the high-priority working domain corresponding to the target working domain has returned to normal, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
[0030] In an embodiment of the present invention, in order to ensure the accuracy of clock synchronization classification, clock synchronization is performed in a working domain with a higher priority. Therefore, in the process of switching the working domain, the high-priority working domain corresponding to the target working domain is monitored periodically. The high-priority working domain refers to at least one working domain with a priority higher than the priority of the target working domain. The priority order is determined according to the working domain currently performing synchronization and the preset working domain. If the clock status of the high-priority working domain returns to normal, it is determined again whether the high-priority working domain can be used as the working domain to be switched.
[0031] Specifically, if it is monitored that the high-priority working domain corresponding to the target working domain has returned to normal, the second switching time difference between the physical clocks of the target working domain and the high-priority working domain is further determined, and a strict switching time difference condition judgment is performed. When the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
[0032] The vehicle-mounted clock synchronization method provided by an embodiment of the present invention responds to the start-up of the master clock and the hot standby master clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, switches the current working domain to the target working domain when the first switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization. The embodiment of the present invention uses a redundant design of a master clock and a hot standby master clock, and each domain is allocated a separate physical clock. Each domain is simultaneously performing a high-precision time synchronization process. When a fault occurs in the current domain, the switching time difference is immediately judged based on the clock status of the domain to be switched. After the required error is met, the domain is directly switched to for clock synchronization, avoiding clock jumps caused by large time deviations before and after switching, achieving a seamless switching effect, improving the accuracy and reliability of clock synchronization, and monitoring the clock status of the high-priority working domain after switching. After the high-priority fault working domain is restored, it is promptly switched back to the high-priority working domain for clock synchronization, thereby achieving high-precision, high-reliability and automated clock synchronization.
[0033] Further, refer to Figure 2 , showing Figure 1 A flowchart of step 101 of a vehicle-mounted clock synchronization method is provided. This method is substantially the same as the vehicle-mounted clock synchronization method provided in the first embodiment of the present invention. Step 101 may include: Step 1011, in response to the master clock and the hot standby master clock being started, initializing the master clock and the hot standby master clock; Step 1012: According to the preset priority order of the working domains, the working domain with the highest priority among the master clock and the hot backup clock is determined as the current working domain; Step 1013: synchronize the physical clock of the current working domain to the terminal node of the vehicle-mounted clock synchronization system.
[0034] In an embodiment of the present invention, the on-board clock synchronization system initializes the master clock and the hot standby master clock in response to the master clock and the hot standby master clock being started. The master clock initialization refers to loading its configuration file after the master clock is started, initializing the hardware resources of the master clock (such as the hardware clock and port, etc.), thereby starting the synchronization protocol stack of the master clock and starting to send Sync messages. The configuration file includes information such as the clock source, priority, and domain configuration. The synchronization protocol stack can use PTP or gPTP, etc. Similarly, the hot standby master clock initialization refers to loading its configuration file after the hot standby master clock is started, initializing the hardware resources of the hot standby master clock, starting the synchronization protocol stack of the hot standby master clock, and entering the standby state, that is, the hot standby master clock does not actively send Sync messages. This embodiment ensures that the system can maintain clock synchronization when the master clock fails through the redundant design of the master clock and the hot standby master clock.
[0035] Specifically, based on a preset working domain priority order, the working domain with the highest priority among the master clock and the hot standby master clock is determined as the current working domain. The working domains corresponding to the master clock include master clock working domain Domain 0 and master clock backup domain Domain 1, and the working domains corresponding to the hot standby master clock include hot standby master clock working domain Domain 2 and hot standby master clock backup domain Domain 3. The predefined working domain priority order includes the master clock working domain having a higher priority than the hot standby master clock working domain. Specifically, the working domain priority order, from highest to lowest, is master clock working domain Domain 0, master clock backup domain Domain 1, hot standby master clock working domain Domain 2, and hot standby master clock backup domain Domain 3. In this embodiment, the predefined priority order is traversed, and the first available working domain is selected as the current working domain. By default, the working domain with the highest priority among the master clock and the hot standby clock is selected as the current working domain.
[0036] In this embodiment, the physical clock status of each working domain is checked. The physical clock status includes whether it is available or synchronized to an external clock source. The physical clock of the current working domain is synchronized to the terminal node of the vehicle clock synchronization system. The current timestamp is obtained from the physical clock of the current working domain (such as / dev / ptp0). The master clock sends a Sync message containing the current timestamp to the terminal node. The terminal node receives the Sync message and adjusts the local clock according to the timestamp in the message. Through the physical clock and Sync message, high-precision clock synchronization of the terminal node is achieved.
[0037] The embodiment of the present invention ensures that the system gives priority to high-priority working domains by presetting the priority order of each working domain, thereby improving the accuracy and reliability of clock synchronization, and can automatically select the second-priority working domain when the high-priority working domain is unavailable.
[0038] Further, refer to Figure 3 , showing Figure 1 A flowchart of step 102 of a vehicle-mounted clock synchronization method is provided. This method is substantially the same as the vehicle-mounted clock synchronization method provided in the first embodiment of the present invention. The vehicle-mounted clock synchronization system includes a time-sensitive network switch. Step 102 may include: Step 1021: Monitor the clock corresponding to the current working domain and the time-sensitive network switch to determine the clock status of the current working domain; Step 1022: Detecting that the clock state of the current working domain is a fault state, determining a working domain of a lower priority corresponding to the current working domain according to a preset working domain priority order; wherein the lower priority working domain includes at least one working domain having a lower priority than the current working domain; Step 1023: Determine the working domain with the next lower priority corresponding to the current working domain as the target working domain to be switched.
[0039] In an embodiment of the present invention, the clock corresponding to the current working domain and the time-sensitive network switch are monitored to determine the clock status of the current working domain. The time-sensitive network switch is a key device in the time-sensitive network (TSN), used to forward time-sensitive data and support the TSN protocol. Specifically, the clock status of the current working domain can be determined by monitoring the synchronization message reception and clock jitter deviation of the current working domain through the PTP / gPTP protocol stack, or by monitoring the status of the TSN switch, such as whether it is operating normally and whether there is packet loss, through the link state detection protocol. If the clock status or TSN switch status is abnormal, the clock status of the current working domain is determined to be a faulty state. By monitoring the status of the clock and TSN switch in real time, the accuracy of fault detection is improved, ensuring that the system can detect faults in a timely manner.
[0040] Specifically, the system detects that the clock status of the current working domain is a faulty state, and determines the sub-priority working domain corresponding to the current working domain according to the preset working domain priority order, wherein the sub-priority working domain refers to at least one working domain with a priority lower than the priority of the current working domain. When the current working domain fails, the next available working domain is selected according to the priority order, the physical clock status of the sub-priority working domain is checked, and the sub-priority working domain is determined as the target working domain to be switched.
[0041] The embodiment of the present invention monitors the clock status of the working domain and promptly selects a high-priority working domain for domain switching when the current working domain fails, thereby improving the accuracy and reliability of clock synchronization. When the current working domain fails, the system can quickly switch to a backup working domain to ensure the continuity of clock synchronization and achieve high-reliability, high-precision and automated clock synchronization.
[0042] Specifically, step 1021 monitors the clock corresponding to the current working domain and the time-sensitive network switch to determine the clock status of the current working domain, which may include the following steps: Sub-step 01: Monitor the clock corresponding to the current working domain and the transmission link of the synchronization message in the time-sensitive network switch and the clock jitter; Sub-step 02: Record the number of synchronization message losses in the transmission link and the clock jitter value; Sub-step 03: If the number of synchronization message losses within the preset time period exceeds the preset number or the clock jitter value is greater than the preset threshold, the clock state of the current working domain is a fault state.
[0043] It should be noted that in the above steps, the system monitors the transmission link and clock jitter of the synchronization message in the corresponding clock of the current working domain and the time-sensitive network switch to determine the clock status of the current working domain. Specifically, through the PTP / gPTP protocol stack, the transmission status of the Sync message in the transmission link is monitored, such as whether it is sent or received on time, whether there is packet loss, etc. The clock jitter is monitored by calculating the change rate of the clock deviation. Specifically, the system records the transmission status and clock jitter value of synchronization messages, counts the number of Sync message losses within a preset duration, and counts the clock jitter value within the preset duration. The system then stores the number of Sync message losses and the clock jitter value in a system log or database. If the number of Sync message losses within the preset duration exceeds a preset number or the clock jitter value exceeds a preset threshold, the clock status of the current working domain is considered faulty. Based on actual needs, a preset value for the number of Sync message losses (e.g., SyncReceiptTimeout = 3) and a preset threshold for the clock jitter value (e.g., 1 microsecond) are set. If the number of Sync message losses exceeds the preset value, a fault state is determined. If the clock jitter value exceeds the preset threshold, a fault state is determined. Based on the judgment result, the clock status of the current working domain is updated.
[0044] The embodiment of the present invention ensures that the system can promptly detect abnormalities and faults in the working domain by monitoring the transmission link and clock jitter of the synchronization message in real time, so as to quickly respond and trigger a switching mechanism when a fault is detected.
[0045] Further, refer to Figure 4 , showing Figure 1 A flowchart of step 103 of a vehicle-mounted clock synchronization method is provided. This method is substantially the same as the vehicle-mounted clock synchronization method provided in the first embodiment of the present invention. Step 103 may include: Step 1031: Obtain the timestamps of the physical clocks of the current working domain and the target working domain, and calculate the first switching time difference between the physical clocks of the current working domain and the target working domain based on the timestamps; Step 1032, comparing the first switching time difference with a preset error value to obtain a comparison result; Step 1033: If the comparison result shows that the first switching time difference satisfies the preset error, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for clock synchronization.
[0046] In an embodiment of the present invention, the system obtains the timestamps of the physical clocks of the current working domain and the target working domain, and calculates the first switching time difference between the physical clocks of the current working domain and the target working domain based on the timestamps. Specifically, the current timestamp (T_current) can be obtained from the physical clock of the current working domain (such as / dev / ptp0), and the current timestamp (T_target) can be obtained from the physical clock of the target working domain (such as / dev / ptp1). The timestamps are calculated to obtain the first time difference between the current working domain and the target working domain, and the switching time difference between the physical clocks is obtained. By obtaining the timestamps of the physical clocks and calculating the switching time difference, the accuracy of the error calculation is ensured.
[0047] Specifically, the first switching time difference is compared with a preset error value to obtain a comparison result, wherein an error value is preset (such as 1 microsecond), and the first switching time difference is compared with the preset error value to determine whether the first switching time difference is less than or equal to the preset error value to obtain a comparison result: when the comparison result is that the first switching time difference satisfies the preset error, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for clock synchronization, that is, if the comparison result is that the first switching time difference satisfies the preset error, the switching operation is performed, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for synchronization, the current working domain status of the system is updated, and the switching operation is recorded.
[0048] The embodiment of the present invention ensures the high accuracy of the switching process by executing the switching when the switching time difference between the working domains meets the preset error. By using the timestamps of the physical clocks of each working domain and calculating the switching time difference, strict switching condition judgment is performed to achieve high-precision, high-reliability and automated clock synchronization switching.
[0049] In some embodiments, after comparing the first switching time difference with a preset error value and obtaining the comparison result, step 1032 may further include: If the comparison result shows that the first switching time difference does not meet a preset error, determining a next working domain of a second priority corresponding to the target working domain according to a preset working domain priority order; Obtain a third switching time difference between the physical clocks of the current working domain and the next working domain. When the third switching time difference satisfies a preset error, switch the current working domain to the next working domain, and use the physical clock of the next working domain for clock synchronization.
[0050] It should be noted that, in this embodiment, when the comparison result is that the first switching time difference does not meet the preset error, that is, the switching error of the target working domain exceeds the preset error range, then the target working domain is unavailable. Therefore, according to the preset working domain priority order, the next working domain with the second priority corresponding to the target working domain is determined. The next working domain with the second priority corresponding to the target working domain is the next working domain with a priority lower than the target working domain, that is, according to the preset working domain priority order, the next working domain with a priority lower than the unavailable target working domain is traversed, and the physical clock status of the next working domain is checked to obtain the third switching time difference between the physical clocks of the current working domain and the next working domain. When the third switching time difference between the current working domain and the next working domain meets the preset error, it indicates that the next working domain meets the switching condition, the current working domain is switched to the next working domain, and the physical clock of the next working domain is used for clock synchronization.
[0051] Specifically, the calculation method of the third switching time difference is the same as that of the first switching time difference. The current timestamp is obtained from the physical clock of the current working domain (such as / dev / ptp1), and the current timestamp is obtained from the physical clock of the next working domain (such as / dev / ptp2). The timestamp is calculated to obtain the time difference between the current working domain and the next working domain, and it is judged whether the third switching time difference meets the preset error. If the third switching time difference is less than or equal to the preset error value, the switching operation is executed, the current working domain is switched to the next working domain, and the physical clock of the next working domain is used for synchronization. The current working domain status of the system is updated, and the switching operation is recorded.
[0052] In an embodiment of the present invention, when the current target working domain is unavailable or the switching time difference does not meet the preset error, the next available working domain is quickly selected to ensure the continuity of clock synchronization. When the switching time difference does not meet the preset error, the second priority working domain is automatically selected to avoid system failure due to a single point failure. When the switching time difference meets the preset error, the switching is performed to avoid time jumps.
[0053] Further, refer to Figure 5 , showing Figure 1 A flowchart of step 104 of a vehicle-mounted clock synchronization method is provided. This method is substantially the same as the vehicle-mounted clock synchronization method provided in the first embodiment of the present invention. Step 104 may include: Step 1041: Monitor the timing of the high-priority working domain corresponding to the target working domain to determine the current clock state of the high-priority working domain; wherein the high-priority working domain includes at least one working domain having a higher priority than the target working domain; Step 1042: Detecting that the high-priority working domain has returned to a normal state, obtaining a second switching time difference between the physical clocks of the target working domain and the high-priority working domain; Step 1043 : When the second switching time difference satisfies a preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
[0054] In an embodiment of the present invention, the system periodically monitors the high-priority working domain corresponding to the target working domain to determine the current clock state of the high-priority working domain, wherein the high-priority working domain refers to at least one working domain whose priority is higher than that of the target working domain. According to the preset working domain priority order, all working domains whose priority is higher than that of the target working domain are determined, and the clock state of the high-priority working domain (such as the reception status of the synchronization message, the clock deviation, etc.) is monitored periodically (such as every 1 second) to determine the clock state of the high-priority working domain. If the clock state of the high-priority working domain returns to normal (such as the reception of the synchronization message is normal and the clock deviation is within the allowable range), it is determined again whether the high-priority working domain can be used as the working domain to be switched.
[0055] Specifically, the calculation method of the second switching time difference is the same as the calculation process of the first switching time difference and the third switching time difference. The current timestamp is obtained from the physical clock of the target working domain (such as / dev / ptp3), and the current timestamp is obtained from the physical clock of the high-priority working domain (such as / dev / ptp0). The time difference between the target working domain and the high-priority working domain is calculated to obtain the second switching time difference. When the second switching time difference meets the preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization. The current working domain status of the system is updated, and the switching operation is recorded.
[0056] The embodiment of the present invention periodically monitors the clock status of the high-priority working domain, promptly discovers the recovery of the high-priority fault working domain, calculates the switching time difference and determines whether it meets the preset error, ensures that the system is synchronized in the high-priority working domain, and realizes high-precision, high-reliability and automated clock synchronization.
[0057] Reference Figure 6 , shows a schematic structural diagram of a vehicle-mounted clock synchronization device provided by an embodiment of the present invention, which is applied to a vehicle-mounted clock synchronization system. The system includes a master clock and a hot standby master clock. The master clock and the hot standby master clock are respectively configured with multiple working domains, each of which is configured with a physical clock. The device includes: A first synchronization module 201 is configured to perform clock synchronization using the physical clock of the current working domain in response to the master clock and the hot standby master clock starting up; The working domain monitoring module 202 is configured to detect that the clock state of the current working domain is a fault state, and determine a target working domain to be switched according to a preset working domain priority order; wherein the preset working domain priority order includes a master clock working domain having a higher priority than a hot standby master clock working domain; The switching working domain module 203 is configured to obtain a first switching time difference between the physical clocks of the current working domain and the target working domain, and when the first switching time difference satisfies a preset error, switch the current working domain to the target working domain and use the physical clock of the target working domain for clock synchronization; The second synchronization module 204 is used to monitor that the high-priority working domain corresponding to the target working domain has returned to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switch the target working domain back to the high-priority working domain, and use the physical clock of the high-priority working domain for clock synchronization.
[0058] Furthermore, the first synchronization module 201 includes: an initial submodule, configured to initialize the master clock and the hot standby master clock in response to the master clock and the hot standby master clock being started; A first determining submodule is configured to determine, according to a preset working domain priority order, the working domain with the highest priority among the master clock and the hot backup clock as the current working domain; The first synchronization submodule is used to synchronize the physical clock of the current working domain to the terminal node of the vehicle-mounted clock synchronization system.
[0059] Furthermore, the vehicle-mounted clock synchronization system includes a time-sensitive network switch, and the monitoring work domain module 202 includes: A first monitoring submodule is configured to monitor a clock corresponding to the current working domain and a time-sensitive network switch to determine a clock state of the current working domain; a second determining submodule, configured to detect that the clock state of the current working domain is a fault state, and determine, according to a preset working domain priority order, a working domain of a sub-priority corresponding to the current working domain; wherein the sub-priority working domain includes at least one working domain having a priority lower than that of the current working domain; The third determining submodule is configured to determine a working domain of a lower priority corresponding to the current working domain as a target working domain to be switched.
[0060] Furthermore, the first monitoring submodule includes: A monitoring unit, configured to monitor the transmission link and clock jitter of the synchronization message in the clock corresponding to the current working domain and the time-sensitive network switch; a recording unit, configured to record the number of times the synchronization message is lost in the transmission link and a clock jitter value; The judgment unit is used to determine that the clock state of the current working domain is a fault state if the number of times the synchronization message is lost within a preset time period exceeds a preset number or the clock jitter value is greater than a preset threshold.
[0061] Furthermore, the switching working domain module 203 includes: A first acquisition submodule is configured to acquire timestamps of the physical clocks of the current working domain and the target working domain, and calculate a first switching time difference between the physical clocks of the current working domain and the target working domain based on the timestamps; a comparison submodule, configured to compare the first switching time difference with a preset error value to obtain a comparison result; The first switching submodule is configured to switch the current working domain to the target working domain and perform clock synchronization using the physical clock of the target working domain if the comparison result shows that the first switching time difference satisfies a preset error.
[0062] Furthermore, the switching working domain module 203 further includes: A fourth determining submodule is configured to determine, if the comparison result shows that the first switching time difference does not satisfy a preset error, a next working domain of a second priority corresponding to the target working domain according to a preset working domain priority order; The second switching submodule is used to obtain a third switching time difference between the physical clocks of the current working domain and the next working domain. When the third switching time difference meets the preset error, the current working domain is switched to the next working domain, and the physical clock of the next working domain is used for clock synchronization.
[0063] Furthermore, the second synchronization module 204 includes: a second monitoring submodule, configured to monitor the timing of a high-priority working domain corresponding to the target working domain to determine a current clock state of the high-priority working domain; wherein the high-priority working domain includes at least one working domain having a priority higher than that of the target working domain; A second acquisition submodule is configured to, upon monitoring that the high-priority working domain has returned to a normal state, acquire a second switching time difference between the physical clocks of the target working domain and the high-priority working domain; The third switching submodule is configured to switch the target working domain back to the high-priority working domain when the second switching time difference satisfies a preset error, and adopt the physical clock of the high-priority working domain for clock synchronization.
[0064] The vehicle-mounted clock synchronization device provided by an embodiment of the present invention starts up in response to the main clock and the hot standby main clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, switches the current working domain to the target working domain when the first switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization. The embodiment of the present invention uses a redundant design of a master clock and a hot standby master clock, and each domain is allocated a separate physical clock. Each domain is simultaneously performing a high-precision time synchronization process. When a fault occurs in the current domain, the switching time difference is immediately judged based on the clock status of the domain to be switched. After the required error is met, the domain is directly switched to for clock synchronization, avoiding clock jumps caused by large time deviations before and after switching, achieving a seamless switching effect, improving the accuracy and reliability of clock synchronization, and monitoring the clock status of the high-priority working domain after switching. After the high-priority fault working domain is restored, it is promptly switched back to the high-priority working domain for clock synchronization, thereby achieving high-precision, high-reliability and automated clock synchronization.
[0065] Reference Figure 7 Based on the same inventive concept, a third aspect of an embodiment of the present application provides an in-vehicle clock synchronization system for executing the above-mentioned in-vehicle clock synchronization method. The system includes a master clock, a hot standby master clock, a time-sensitive network switch, and a terminal node: The master clock and the hot standby master clock are respectively configured with a plurality of working domains, and each of the working domains is configured with a physical clock; The time-sensitive network switch is connected to the master clock, the hot standby master clock and the terminal node; The on-board clock synchronization system starts in response to the master clock and the hot standby master clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, and switches the current working domain to the target working domain when the first switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization.
[0066] As for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0067] In another embodiment provided by the present invention, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the vehicle-mounted clock synchronization method described in any of the above embodiments is implemented.
[0068] It should be noted that the embodiments of the present invention are described with reference to the methods and apparatuses according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by the computer program instructions of the vehicle-mounted clock synchronization system. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0069] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0070] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0071] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0072] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0073] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A vehicle-mounted clock synchronization method, characterized in that: Applied to a vehicle-mounted clock synchronization system, the system includes a master clock and a hot standby master clock, the master clock and the hot standby master clock are respectively configured with multiple working domains, each of the working domains is configured with a physical clock, the method includes: In response to the master clock and the hot standby master clock being started, using the physical clock of the current working domain for clock synchronization; Detecting that the clock state of the current working domain is a fault state, determining a target working domain to be switched according to a preset working domain priority order; wherein the preset working domain priority order includes that the priority of the master clock working domain is higher than the priority of the hot standby master clock working domain; Obtaining a first switching time difference between the physical clocks of the current working domain and the target working domain, and if the first switching time difference satisfies a preset error, switching the current working domain to the target working domain, and using the physical clock of the target working domain for clock synchronization; When it is monitored that the high-priority working domain corresponding to the target working domain has returned to normal, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
2. The method according to claim 1, characterized in that In response to the master clock and the hot standby master clock being started, using the physical clock of the current working domain to perform clock synchronization includes: In response to the master clock and the hot standby master clock being started, initializing the master clock and the hot standby master clock; According to the preset working domain priority order, the working domain with the highest priority among the master clock and the hot backup clock is determined as the current working domain; The physical clock of the current working domain is synchronized to the terminal node of the vehicle-mounted clock synchronization system.
3. The method according to claim 1, characterized in that The vehicle-mounted clock synchronization system includes a time-sensitive network switch, wherein the monitoring detects that the clock state of the current working domain is a fault state, and determines a target working domain to be switched according to a preset working domain priority order, including: Monitor a clock corresponding to the current working domain and a time-sensitive network switch to determine a clock state of the current working domain; detecting that the clock state of the current working domain is a fault state, and determining a working domain of a lower priority corresponding to the current working domain according to a preset working domain priority order; wherein the lower priority working domain includes at least one working domain having a lower priority than the current working domain; A working domain with a lower priority corresponding to the current working domain is determined as a target working domain to be switched.
4. The method according to claim 3, characterized in that The monitoring of the clock corresponding to the current working domain and the time-sensitive network switch to determine the clock state of the current working domain includes: Monitoring the transmission link and clock jitter of the synchronization message in the clock corresponding to the current working domain and the time-sensitive network switch; Recording the number of times the synchronization message is lost in the transmission link and the clock jitter value; If the number of times the synchronization message is lost within a preset time period exceeds a preset number or the clock jitter value is greater than a preset threshold, the clock state of the current working domain is a fault state.
5. The method according to claim 1, wherein The acquiring a first switching time difference between the physical clocks of the current working domain and the target working domain, switching the current working domain to the target working domain when the first switching time difference satisfies a preset error, and performing clock synchronization using the physical clock of the target working domain, includes: Obtaining timestamps of the physical clocks of the current working domain and the target working domain, and calculating a first switching time difference between the physical clocks of the current working domain and the target working domain based on the timestamps; Comparing the first switching time difference with a preset error value to obtain a comparison result; If the comparison result shows that the first switching time difference satisfies a preset error, the current working domain is switched to the target working domain, and the physical clock of the target working domain is used for clock synchronization.
6. The method according to claim 5, characterized in that After comparing the first switching time difference with the preset error value to obtain a comparison result, the method further includes: If the comparison result shows that the first switching time difference does not meet a preset error, determining a next working domain of a second priority corresponding to the target working domain according to a preset working domain priority order; Obtain a third switching time difference between the physical clocks of the current working domain and the next working domain. When the third switching time difference satisfies a preset error, switch the current working domain to the next working domain, and use the physical clock of the next working domain for clock synchronization.
7. The method according to claim 1, characterized in that The method includes: monitoring that the high-priority working domain corresponding to the target working domain has returned to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets a preset error, switching the target working domain back to the high-priority working domain, and using the physical clock of the high-priority working domain for clock synchronization, including: Regularly monitoring a high-priority working domain corresponding to the target working domain to determine a current clock state of the high-priority working domain; wherein the high-priority working domain includes at least one working domain having a priority higher than that of the target working domain; monitoring that the high-priority working domain returns to a normal state, and obtaining a second switching time difference between the physical clocks of the target working domain and the high-priority working domain; When the second switching time difference satisfies a preset error, the target working domain is switched back to the high-priority working domain, and the physical clock of the high-priority working domain is used for clock synchronization.
8. A vehicle-mounted clock synchronization device, characterized in that: Applied to a vehicle-mounted clock synchronization system, the system includes a master clock and a hot standby master clock, the master clock and the hot standby master clock are respectively configured with multiple working domains, each of the working domains is configured with a physical clock, and the device includes: A first synchronization module is configured to perform clock synchronization using a physical clock of a current working domain in response to the master clock and the hot standby master clock being started; A working domain monitoring module is configured to detect that the clock state of the current working domain is a fault state, and determine a target working domain to be switched according to a preset working domain priority order; wherein the preset working domain priority order includes that the priority of the master clock working domain is higher than the priority of the hot standby master clock working domain; a switching working domain module, configured to obtain a first switching time difference between the physical clocks of the current working domain and the target working domain, and when the first switching time difference satisfies a preset error, switch the current working domain to the target working domain, and use the physical clock of the target working domain for clock synchronization; The second synchronization module is used to monitor that the high-priority working domain corresponding to the target working domain has returned to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switch the target working domain back to the high-priority working domain, and use the physical clock of the high-priority working domain for clock synchronization.
9. A vehicle-mounted clock synchronization system, characterized in that: The system is used to perform the vehicle-mounted clock synchronization method according to any one of claims 1 to 7, and includes a master clock, a hot standby master clock, a time-sensitive network switch, and a terminal node: The master clock and the hot standby master clock are respectively configured with a plurality of working domains, and each of the working domains is configured with a physical clock; The time-sensitive network switch is connected to the master clock, the hot standby master clock and the terminal node; The on-board clock synchronization system starts in response to the master clock and the hot standby master clock, uses the physical clock of the current working domain for clock synchronization, monitors that the clock state of the current working domain is a fault state, determines the target working domain to be switched according to the preset working domain priority order, obtains the first switching time difference between the physical clocks of the current working domain and the target working domain, and switches the current working domain to the target working domain when the first switching time difference meets the preset error, and uses the physical clock of the target working domain for clock synchronization, monitors that the high-priority working domain corresponding to the target working domain is restored to a normal state, and the second switching time difference between the physical clocks of the target working domain and the high-priority working domain meets the preset error, switches the target working domain back to the high-priority working domain, and uses the physical clock of the high-priority working domain for clock synchronization.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the vehicle-mounted clock synchronization method according to any one of claims 1 to 7 is implemented.