Time synchronization method, central gateway system, equipment and storage medium
By using the signal switching mechanism between the microprocessor and the microcontroller in the central gateway system, the problem of unreliable time synchronization caused by the failure of the microprocessor or microcontroller is solved, and the reliability and stability of the time synchronization node are achieved. promote.
Patent Information
- Application Number
- CN202410899422.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-01
AI Technical Summary
In existing time synchronization methods, faults in the microprocessor or microcontroller may cause unreliable time synchronization, reducing system reliability.
By using the signal switching mechanism between the microprocessor and the microcontroller in the central gateway system, the microprocessor and the microcontroller determine the occupancy status of the external time source and switch to the time synchronization master when the microcontroller fails. Nodes obtain time information from external time sources for synchronization, which improves the reliability of time synchronization.
It realizes the switching of the time synchronization master node between the microcontroller and the microprocessor, improves the reliability and stability of the time synchronization node, and ensures that the system can still synchronize time normally when the microcontroller fails.
Smart Images

Figure CN118740307A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of vehicle time synchronization technology, and in particular to a time synchronization method, a central gateway system, a device and a storage medium. Background Art
[0002] In the prior art, a microprocessor (Microprocessor Unit, MPU) or a microcontroller (Microcontroller Unit, MCU) is generally used as a time synchronization master node to output a time synchronization signal and time to the outside, thereby synchronizing the time. However, due to the possibility of failure of the microprocessor or microcontroller, the above method may result in failure of time synchronization, thereby reducing reliability. Summary of the invention
[0003] The embodiments of the present application provide a time synchronization method, a central gateway system, a device and a storage medium to solve the problem of low reliability of existing time synchronization methods.
[0004] In a first aspect, an embodiment of the present application provides a time synchronization method, which is applied to a central gateway system, wherein the central gateway system includes a microcontroller and a microprocessor, and the method includes:
[0005] In the Nth cycle after the central gateway is powered on, before the first set time, the microprocessor determines whether a second signal is received, wherein the second signal is a signal output by the microcontroller when operating normally as a time synchronization master node;
[0006] If the second signal is not received, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority;
[0007] If the second signal is received, and the first signal received at the first set time is a first level signal, the microprocessor maintains the setting of the time synchronization slave node, wherein the first signal is a first level signal sent by the microcontroller as a time synchronization master node;
[0008] If the second signal is received, and the first signal received at the first set time is a second level signal, the microprocessor switches itself from the time synchronization slave node to the time synchronization master node by adjusting the time synchronization priority;
[0009] Wherein, within the N-1 cycle, the microprocessor is a time synchronization slave node, the microcontroller is a time synchronization master node, and N is an integer greater than 1.
[0010] In a possible implementation manner, when the microprocessor serves as a time synchronization slave node, the method further includes:
[0011] At a second set time in the current cycle, the microprocessor obtains first alignment time information from an external time source, wherein the first set time is earlier than the second set time;
[0012] The microprocessor adjusts an internal time of the microprocessor based on the first alignment time information.
[0013] In a possible implementation manner, when the microprocessor serves as a time synchronization master node, the method further includes:
[0014] At a third set time in the current cycle, the microprocessor sends a third signal of the first level signal to the microcontroller, so that after the microcontroller receives the third signal, it obtains second alignment time information from the external time source at the second set time, and adjusts the internal time of the microcontroller based on the second alignment time information;
[0015] The third set time is earlier than the second set time.
[0016] In a possible implementation, the central gateway system further includes a switch;
[0017] In the case where the microprocessor serves as a time synchronization master node, the method further comprises:
[0018] The microcontroller obtains time information from an external time source and outputs the time information through the switch.
[0019] In a possible implementation, the method further includes:
[0020] In a first cycle after the central gateway is powered on and before a first set time, the microprocessor receives a second signal sent by the microcontroller;
[0021] At the first setting time, the microprocessor receives the first signal sent by the microcontroller, and sets itself as a time synchronization slave node when determining that the first signal is a first level signal.
[0022] In a possible implementation, the external time source includes a global navigation satellite system and a real-time clock, and when the microprocessor serves as a time synchronization master node, the method further includes:
[0023] During the current cycle, the microprocessor determines the signal strength of the central gateway system communication;
[0024] When the signal strength is greater than a set threshold, the microprocessor obtains time information from the global navigation satellite system, otherwise it obtains time information from the real-time clock.
[0025] In a second aspect, an embodiment of the present application provides a central gateway system, including a microprocessor and a microcontroller;
[0026] In the Nth cycle after the central gateway system is powered on, before the first set time, the microprocessor determines whether a second signal is received, wherein the second signal is a signal output by the microcontroller when operating normally as a time synchronization master node;
[0027] If the second signal is not received, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority;
[0028] If the second signal is received, and the first signal received at the first set time is a first level signal, the microprocessor maintains the setting of the time synchronization slave node, wherein the first signal is a first level signal sent by the microcontroller as a time synchronization master node;
[0029] If the second signal is received, and the first signal received at the first set time is a second level signal, the microprocessor switches itself from the time synchronization slave node to the time synchronization master node by adjusting the time synchronization priority;
[0030] Wherein, within the N-1 cycle, the microprocessor is a time synchronization slave node, the microcontroller is a time synchronization master node, and N is an integer greater than 1.
[0031] In a possible implementation manner, when the microprocessor serves as a time synchronization slave node, the microprocessor is further configured to:
[0032] At a second set time in the current cycle, the microprocessor obtains alignment time information from an external time source, wherein the first set time is earlier than the second set time;
[0033] The microprocessor adjusts an internal time of the microprocessor based on the alignment time information.
[0034] In a possible implementation manner, when the microprocessor serves as a time synchronization master node, the microprocessor is further configured to:
[0035] At a third set time in the current cycle, the microprocessor sends a third signal of the first level signal to the microcontroller, so that after the microcontroller receives the third signal, it obtains second alignment time information from the external time source at the second set time, and adjusts the internal time of the microcontroller based on the second alignment time information;
[0036] The third set time is earlier than the second set time.
[0037] In a possible implementation, the central gateway system further includes a switch;
[0038] When the microprocessor serves as a time synchronization master node, the microprocessor is further configured to:
[0039] The microcontroller obtains time information from an external time source and outputs the time information through the switch.
[0040] In one possible implementation, the microprocessor is further used for:
[0041] In a first cycle after the central gateway system is powered on and before a first set time, the microprocessor receives a second signal sent by the microcontroller;
[0042] At the first setting time, the microprocessor receives the first signal sent by the microcontroller, and sets itself as a time synchronization slave node when determining that the first signal is a first level signal.
[0043] In a possible implementation, the external time source includes a global navigation satellite system and a real-time clock. When the microprocessor serves as a time synchronization master node, the microprocessor is further configured to:
[0044] During the current cycle, the microprocessor determines the signal strength of the central gateway system communication;
[0045] When the signal strength is greater than a set threshold, the microprocessor obtains time information from the global navigation satellite system, otherwise it obtains time information from the real-time clock.
[0046] In a third aspect, an embodiment of the present application provides an execution device, including:
[0047] A memory for storing program instructions;
[0048] The processor is used to obtain the program instructions in the memory and execute the method described in the first aspect and different implementation methods according to the obtained program instructions.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by the computer, the method described in the first aspect and different implementation methods is implemented.
[0050] The beneficial effects of this application are as follows:
[0051] In the present application, different signals are used between the microprocessor and the microcontroller to determine whether the external time source is occupied. When the external time source is occupied by the microcontroller, the microcontroller acts as a time synchronization master node, and the microprocessor acts as a time synchronization slave node. When the microcontroller is determined to be faulty according to the signal, the microprocessor, as the time synchronization master node, obtains time information from the external time source to synchronize the time. This method implements the switching of the time synchronization master node between the microcontroller and the microprocessor, thereby improving the reliability of the time synchronization node. In addition, in the present application, after the time synchronization slave node obtains the time information from the time synchronization master node, it also obtains the alignment time information from the external time source, thereby realizing the time synchronization of the time slave node.
[0052] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 A schematic diagram of a central gateway system provided in an embodiment of the present application;
[0055] Figure 2 A flow chart of a time synchronization method provided in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of a microprocessor provided in an embodiment of the present application as a time synchronization slave node;
[0057] Figure 4 A schematic diagram of a microprocessor provided in an embodiment of the present application as a time synchronization master node;
[0058] Figure 5 A structural diagram of an execution device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0060] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0061] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0062] In order to facilitate understanding of the solution proposed in this application, the technical terms involved in this application are explained below.
[0063] Time synchronization: accepts external time reference and outputs time synchronization signal and time to the outside. In this application, it refers to IEEE802.1 AS Ethernet-based time synchronization protocol.
[0064] The time synchronization global master node, GrandMaster, outputs time synchronization signals and time to the outside world.
[0065] The time synchronization slave node, Slave, does not output time synchronization signals and time to the outside.
[0066] Ethernet-based time synchronization technology has been widely used in vehicle networks. The central gateway serves as the GrandMaster of time synchronization. The central gateway consists of an internal MCU and MPU, where the MCU is used for applications with high real-time requirements and the MPU is used to process applications with high computing power. In general, a microprocessor or microcontroller is used alone as a time synchronization master node to output time synchronization signals and time to the outside world, thereby synchronizing the time. However, due to the possibility of failure of the microprocessor or microcontroller, the above method may result in the inability to synchronize the time during a failure, thereby reducing reliability.
[0067] Based on the above problems, the embodiments of the present application provide a time synchronization method, a central gateway system, a device and a storage medium. The central gateway system includes a microprocessor and a microcontroller. The processor and the microcontroller determine whether the external time source is occupied through different signals. When the external time source is occupied by the microcontroller, the microcontroller acts as a time synchronization master node, and the microprocessor acts as a time synchronization slave node. When the microcontroller is determined to be faulty according to the signal, the microprocessor, as the time synchronization master node, obtains time information from the external time source to synchronize the time. This method realizes the switching of the time synchronization master node between the microcontroller and the microprocessor, and improves the reliability of the time synchronization node.
[0068] In order to better understand the solution proposed in this application, Figure 1 As shown, Figure 1 The application scenario diagram of the time synchronization method proposed in the present application is exemplarily shown, and the time synchronization method proposed in the present application is applied to a central gateway system. The central gateway system 100 may be composed of a microprocessor MPU 101, a microcontroller MCU 102, and a switch 103. In some embodiments, the central gateway system 100 further includes an external time source 104.
[0069] In the present application, the external time source 104 includes a global navigation satellite system (GNSS) and a real-time clock (RTC). GNSS and RTC are connected to the MCU and MPU respectively through two multi-way selector switches, and MCU102 and MPU101 control the channels of the multi-way selector switches by enabling selection. Among them, the communication mode of GNSS is the serial communication interface standard (RS232), and the communication interface of RTC is IIC (IICBus integrated circuit bus).
[0070] In some embodiments, MCU102 and MPU101 are connected via three hard wires, namely Line_A, Line_B and Heart. When the central gateway 100 is powered on, Line_A and Line_B are pulled high by default, when MCU102 is started, Line_B is pulled low, and when MPU is started, Line_A is pulled low.
[0071] In some scenarios, MCU102 can determine whether the external time source is idle through Line_A. Specifically, when Line_A is at a high logic level, it means that MPU101 releases the external time source. At this time, the external time source is in an idle state and the MCU can access it. The MCU accesses the external time source while pulling down Line_B. When Line_A is at a low logic level, it means that MPU101 is occupying the external time source, that is, MPU101 is the time synchronization master node, and MCU102 cannot access the external time source.
[0072] In some scenarios, MPU101 can determine whether the external time source is idle through Line_B. Specifically, when Line_B is at a high logic level, it means that MCU102 releases the external time source. At this time, the external time source is in an idle state and MPU101 can access it. MPU101 accesses the external time source while pulling down Line_A. When Line_B is at a low logic level, it means that MCU102 is occupying the external time source, that is, MCU102 is acting as the time synchronization master node, and MPU101 cannot access the external time source.
[0073] In some embodiments, after the MCU 102 is successfully started, it can output a periodic pulse signal through the Heart hard line, and the MPU 101 can monitor the periodic pulse signal of the Heart hard line in real time to determine whether the MCU 102 is successfully started.
[0074] In some embodiments, when MPU101 can normally monitor the periodic pulse signal transmitted through the Heart hard line, and Line_B is at a low logic level, MPU101 is set as the time synchronization slave node Slave; when MPU101 cannot monitor the periodic pulse signal transmitted through the Heart hard line, or detects the periodic pulse signal, but Line_B is at a high logic level, MPU101 considers that MCU102 has failed at this time, and MPU101 switches to the time synchronization master node GrandMaster. If MCU102 recovers from the fault state and starts to send periodic pulse signals through the Heart hard line and access the external time source normally, MPU switches to Slave.
[0075] In some embodiments, MCU102 occupies an external time source through hard line Line_B at period t1. When an external time source is occupied by MPU101 in the mth period, a random time is selected between (m*t1) and (m*t1+t1*10%) to obtain time information from the external time source and adjust the internal time of MCU102.
[0076] In some other embodiments, MPU101 occupies an external time source through hard line Line_A at period t1. When there is external time occupied by MCU102 in the mth period, a random time is selected between (m*t1) and (m*t1+t1*10%) to obtain time information from the external time source and adjust the internal time of MCU102.
[0077] In some embodiments, the time synchronization master node preferentially uses the time information of GNSS. When GNSS fails, RTC is used as an external time source. In some scenarios, the signal strength of the central gateway system communication can be used to determine whether to obtain time information from GNSS or RTC.
[0078] In some scenarios, MPU101 is connected to the Eth3 interface of switch 103. When MPU101 acts as the time synchronization master node, the time information obtained from the external time source is input into switch 103 through the Eth3 interface, and switch 103 outputs the time information through the Eth1 interface. In other scenarios, MCU102 is connected to the Eth2 interface of switch 103. When MCU102 acts as the time synchronization master node, the time information obtained from the external time source is input into switch 103 through the Eth2 interface, and switch 103 outputs the time information through the Eth1 interface.
[0079] In some embodiments, the central gateway system 100 may include more components. Figure 1 It is not shown and this application does not make any specific limitation on this.
[0080] refer to Figure 2 As shown, Figure 2 The flowchart of a time synchronization method provided by the present application is exemplarily shown. The method can be executed by a central gateway system, and specifically can be executed by a microprocessor in the central gateway system. The method flow is as follows:
[0081] 201. Within the Nth cycle after the central gateway system is powered on and before the first set time, the microprocessor determines whether a second signal is received.
[0082] The second signal is a signal output by the microcontroller when it operates normally as a time synchronization master node. Figure 1In the N-1 period, the microprocessor is the time synchronization slave node, the microcontroller is the time synchronization master node, and N is an integer greater than 1.
[0083] As an example, in the third cycle after the central gateway system is powered on, with 1 second as a cycle, then in the cycle of 2-3 seconds, assuming that the first moment is 2.5 seconds, the microprocessor determines whether the second signal is received within 2-2.5 seconds, that is, the periodic pulse signal transmitted through the Heart hard line when the microcontroller is operating normally.
[0084] 202. If the second signal is not received, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority.
[0085] In some scenarios, if the microprocessor does not receive the second signal before the first set time in the Nth cycle, it indicates that the microcontroller may fail. Since the microprocessor is a time synchronization slave node in the N-1th cycle, in order to ensure that time information can be obtained from an external time source, in the Nth cycle, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority.
[0086] Specifically, in the N-1th cycle, the corresponding time synchronization priority when the microprocessor acts as a time synchronization slave node is 100, and the corresponding time synchronization priority when the microcontroller acts as a time synchronization master node is 200. In the Nth cycle, when the microprocessor does not receive the second signal, it is determined that the microcontroller fails, and the microprocessor can adjust its own time synchronization priority from 100 to 300. At this time, the time synchronization priority of the microprocessor is higher than the time synchronization priority of the microcontroller, and the microprocessor switches from the time synchronization slave node to the time synchronization master node.
[0087] 203. If the second signal is received and the first signal received at the first set time is a first level signal, the microprocessor maintains the setting of the time synchronization slave node.
[0088] The first signal is a first level signal sent when the microcontroller acts as a time synchronization master node. Specifically, when the microcontroller acts as a time synchronization master node, the first level signal sent through the hard line Line_B is a low logic level signal, that is, the first signal is a low level signal.
[0089] like Figure 3As shown, taking the case where the period is 1 second, N is 3 and the first setting time is 2.5 seconds as an example, if the second signal is received before 2.5 seconds and the first level signal is received at 2.5 seconds, it is determined that the microcontroller occupies the external time source as the time synchronization master node at 2.5 seconds, and the microprocessor maintains the setting of the time synchronization slave node. Continuing with the above example, when the microcontroller is determined as the time master node, the time synchronization priority of the microprocessor is maintained at 100.
[0090] 204. If the second signal is received and the first signal received at the first set time is a second level signal, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority.
[0091] In some embodiments, if the first signal received by the microprocessor at the first set time is a second level signal, that is, the first signal received by the microprocessor is a high logic level signal received through the hard line Line_A, it is determined that the microcontroller does not occupy the external time source at the first set time, and the microprocessor switches itself from the time synchronization slave node to the time synchronization master node by adjusting the time synchronization priority.
[0092] like Figure 4 As shown, taking a period of 1 second, N of 3 and a first set time of 2.5 seconds as an example, if a second signal is received before 2.5 seconds and a second level signal is received at 2.5 seconds, it is determined that the microcontroller does not occupy the external time source at 2.5 seconds, and the microprocessor adjusts the time synchronization priority to a priority higher than that of the microcontroller to achieve switching from the time synchronization slave node to the time synchronization master node.
[0093] In some embodiments, when the microprocessor acts as the time synchronization master node in the Nth cycle, if the second signal is received in the N+1th cycle, the time synchronization priority is adjusted, and the adjusted time synchronization priority is lower than the time synchronization priority of the microcontroller. For example, when the microprocessor acts as the time synchronization master node in the Nth cycle, the corresponding time synchronization priority is 300, while the time synchronization priority of the microcontroller is 200. In the N+1th cycle, when the microprocessor receives the second signal, the time synchronization priority is adjusted, that is, the time synchronization priority is adjusted from 300 to 100, and the adjusted time synchronization priority is lower than the time synchronization priority of the microcontroller.
[0094] In some instances, when the microprocessor serves as a time synchronization master node, the microcontroller can obtain time information from an external time source and output the time information through a switch so that other devices can update the time according to the time information.
[0095] In some embodiments, when the microprocessor acts as a time synchronization slave node, at a second set moment in the current cycle, the microprocessor obtains first alignment time information from an external time source, wherein the first set moment is earlier than the second set moment. Further, the microprocessor adjusts the internal time of the microprocessor based on the alignment time information. As an example, when the microprocessor acts as a time synchronization slave node, the current cycle is the third cycle and the first set moment is the 2.5th second. When it is determined that the microprocessor is a time synchronization slave node in the current cycle, the microprocessor can obtain the first alignment time information from the external time source at the 2.8th second in the current cycle, and adjust the internal time of the microprocessor based on the alignment time information.
[0096] In some embodiments, when the microprocessor serves as a time synchronization master node, the microprocessor may send a third signal of a first level signal to the microcontroller at a third set time in the current cycle, so that after the microcontroller receives the third signal, it obtains second alignment time information from an external time source at a second set time, and adjusts the internal time of the microcontroller based on the second alignment time information. The third set time is earlier than the second set time. In some scenarios, when the microprocessor does not receive the second signal, or receives the second signal but the received first signal is a second level signal, it may obtain time information from an external time source as a time synchronization master node at the third set time. The third set time may be the same as the first set time, or may be later than the first set time and earlier than the second set time.
[0097] As an example, take the current cycle as the third cycle and the second set time as the 2.8th second. When the microprocessor is determined to be the time synchronization master node at the 2.5th second, a first level signal can be sent to the microcontroller within the 2.5th-2.8th second. Specifically, when the microprocessor accesses an external time source as the time synchronization master node, the third signal sent through the hard line Line_B is a low logic level signal to notify the microcontroller that the microprocessor is the time synchronization master node in the current cycle, and the microcontroller needs to be the time synchronization slave node, and obtain the second alignment time information from the external time source at the second set time (i.e., the 2.8th second) and adjust the internal time of the microcontroller.
[0098] In some embodiments, within a first cycle after the central gateway system is powered on, before a first set time, the microprocessor receives a second signal sent by the microcontroller. At the first set time, the microprocessor receives a first signal sent by the microcontroller, and when determining that the first signal is a first level signal, sets itself as a time synchronization slave node.
[0099] As an example, in the first cycle after the central gateway is powered on, the microcontroller is started and used as the time synchronization master node by default. Taking the first set time as 0.5 seconds after the central gateway is powered on as an example, before 0.5 seconds, if the microcontroller is operating normally, it sends a second signal to the microprocessor, and sends a first signal of a first level signal to the microprocessor while accessing the external time source at the first set time. At this time, the microprocessor determines that the microcontroller as the time synchronization master node has accessed the external time source at the first set time based on the received second signal and the first signal of the first level signal, and then the microprocessor sets itself as the time synchronization slave node.
[0100] In some embodiments, the external time source includes a global navigation satellite system and a real-time clock. When the microprocessor serves as a time synchronization master node, the microprocessor determines the signal strength of the central gateway communication in the current cycle. When the signal strength is greater than a set threshold, the microprocessor obtains time information from the global navigation satellite system, otherwise it obtains time information from the real-time clock.
[0101] In some scenarios, when the signal strength is greater than the set threshold, the time synchronization master node obtains time information from the global navigation satellite system, and the time synchronization slave node also obtains alignment time information from the global navigation satellite system. In other scenarios, when the signal strength is less than or equal to the set threshold, the time synchronization master node obtains time information from the real-time clock, and the time synchronization slave node obtains alignment time information from the real-time clock.
[0102] In this application, when the central gateway system is powered on, the microcontroller is used as the time synchronization master node of the central gateway system by default, and the microprocessor is used as the time synchronization slave node. When the microcontroller fails, the microprocessor automatically switches to the time synchronization master node to ensure the normal operation of the time synchronization function of the central gateway system.
[0103] In the present application, the microcontroller and microprocessor communicate with an external time source through time-sharing, thereby obtaining current time information, enabling rapid borrowing and returning of the time synchronization master node between the microcontroller and microprocessor, thereby improving the reliability and stability of the time synchronization master node.
[0104] Based on the same technical concept, see Figure 5 As shown, the embodiment of the present application provides an execution device 500, which can execute any step in the above time synchronization method. To avoid repetition, it is not repeated here. The device 500 includes a memory 501 and a processor 502.
[0105] The memory 501 is used to store program instructions;
[0106] The processor 502 is used to call the program instructions stored in the memory and execute the various steps of the above time synchronization method according to the obtained program.
[0107] In the embodiment of the present application, the processor 502 may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0108] The memory 501 is a non-volatile computer-readable storage medium, which can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 501 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (RandomAccess Memory, RAM), a static random access memory (Static RandomAccess Memory, SRAM), a programmable read-only memory (Programmable Read Only Memory, PROM), a read-only memory (Read Only Memory, ROM), an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 501 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 501 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0109] Based on the same technical concept, an embodiment of the present application provides a vehicle, which includes the above-mentioned central gateway system or execution device, so that the vehicle implements each step of the above-mentioned time synchronization method.
[0110] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed on a computer, the computer executes each step of the above-mentioned time synchronization method.
[0111] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0112] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. 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 computer program instructions. 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 device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. 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.
[0113] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0114] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0115] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A time synchronization method, characterized in that: Applied to a central gateway system, the central gateway system includes a microcontroller and a microprocessor, and the method includes: In the Nth cycle after the central gateway system is powered on, before the first set time, the microprocessor determines whether a second signal is received, wherein the second signal is a signal output by the microcontroller when operating normally as a time synchronization master node; If the second signal is not received, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority; If the second signal is received, and the first signal received at the first set time is a first level signal, the microprocessor maintains the setting of the time synchronization slave node, wherein the first signal is a first level signal sent by the microcontroller as a time synchronization master node; If the second signal is received, and the first signal received at the first set time is a second level signal, the microprocessor switches itself from the time synchronization slave node to the time synchronization master node by adjusting the time synchronization priority; Wherein, within the N-1 cycle, the microprocessor is a time synchronization slave node, the microcontroller is a time synchronization master node, and N is an integer greater than 1.
2. The method according to claim 1, characterized in that In the case where the microprocessor serves as a time synchronization slave node, the method further comprises: At a second set time in the current cycle, the microprocessor obtains first alignment time information from an external time source, wherein the first set time is earlier than the second set time; The microprocessor adjusts an internal time of the microprocessor based on the first alignment time information.
3. The method according to claim 2, characterized in that In the case where the microprocessor serves as a time synchronization master node, the method further comprises: At a third set time in the current cycle, the microprocessor sends a third signal of the first level signal to the microcontroller, so that after the microcontroller receives the third signal, it obtains second alignment time information from the external time source at the second set time, and adjusts the internal time of the microcontroller based on the second alignment time information; The third set time is earlier than the second set time.
4. The method according to claim 1, characterized in that The central gateway system also includes a switch; In the case where the microprocessor serves as a time synchronization master node, the method further comprises: The microcontroller obtains time information from an external time source and outputs the time information through the switch.
5. The method according to claim 1, characterized in that The method further comprises: In a first cycle after the central gateway system is powered on and before a first set time, the microprocessor receives a second signal sent by the microcontroller; At the first setting time, the microprocessor receives the first signal sent by the microcontroller, and sets itself as a time synchronization slave node when determining that the first signal is a first level signal.
6. The method according to any one of claims 1 to 5, characterized in that: The external time source includes a global navigation satellite system and a real-time clock. When the microprocessor serves as a time synchronization master node, the method further includes: During the current cycle, the microprocessor determines the signal strength of the central gateway system communication; When the signal strength is greater than a set threshold, the microprocessor obtains time information from the global navigation satellite system, otherwise it obtains time information from the real-time clock.
7. A central gateway system, characterized in that: Includes microprocessors and microcontrollers; In the Nth cycle after the central gateway system is powered on, before the first set time, the microprocessor determines whether a second signal is received, wherein the second signal is a signal output by the microcontroller when operating normally as a time synchronization master node; If the second signal is not received, the microprocessor switches itself from a time synchronization slave node to a time synchronization master node by adjusting the time synchronization priority; If the second signal is received, and the first signal received at the first set time is a first level signal, the microprocessor maintains the setting of the time synchronization slave node, wherein the first signal is a first level signal sent by the microcontroller as a time synchronization master node; If the second signal is received, and the first signal received at the first set time is a second level signal, the microprocessor switches itself from the time synchronization slave node to the time synchronization master node by adjusting the time synchronization priority; Wherein, within the N-1 cycle, the microprocessor is a time synchronization slave node, the microcontroller is a time synchronization master node, and N is an integer greater than 1.
8. The central gateway system as claimed in claim 7, characterized in that: When the microprocessor serves as a time synchronization slave node, the microprocessor is further configured to: At a second set time in the current cycle, the microprocessor obtains alignment time information from an external time source, wherein the first set time is earlier than the second set time; The microprocessor adjusts an internal time of the microprocessor based on the alignment time information.
9. An execution device, characterized in that: include: A memory for storing program instructions; A processor, configured to obtain program instructions in the memory and execute the method according to any one of claims 1 to 6 according to the obtained program instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by the computer, the method according to any one of claims 1 to 6 is implemented.
