Time synchronization methods, apparatus, electronic devices, and computer-readable storage media

By obtaining the timestamp reference values ​​of the VR all-in-one device and the PC, time synchronization is achieved, which solves the problem of the lack of correlation between the clock systems of the VR all-in-one device and the PC, ensuring accurate prediction of the user's pose information on the PC side and improving the VR experience.

CN117240426BActive Publication Date: 2026-11-17BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210641591.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-07
Publication Date
2026-11-17
Estimated Expiration
2042-06-07

AI Technical Summary

Technical Problem

The lack of coordination between the VR all-in-one device and the PC's clock systems leads to latency and increased delays, impacting the VR experience.

Method used

By acquiring the timestamp reference values ​​of two clock systems, the corresponding timestamp reference value at the same moment is determined, and then converted according to the timestamp to be processed to achieve time synchronization.

Benefits of technology

Accurately predict the pose information seen by the user on the PC side to avoid shaking and dizziness, ensuring that the VR experience is comparable to PC VR.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117240426B_ABST
    Figure CN117240426B_ABST
Patent Text Reader

Abstract

This invention discloses a time synchronization method, apparatus, electronic device, and computer-readable storage medium. The method, applied to a first electronic device, includes: acquiring a first timestamp reference value of the clock system of the first electronic device, and acquiring a second timestamp reference value of the clock system of a second electronic device communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first and second electronic devices are unrelated; acquiring a timestamp to be processed from the clock system of the first electronic device; and determining a target timestamp of the clock system of the second electronic device corresponding to the same moment as the timestamp to be processed, based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value. Using the solution of this invention, time synchronization between two unrelated clock systems can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of timestamp technology, specifically to a time synchronization method and apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] Currently, stand-alone VR headsets are gradually becoming mainstream due to their ease of use. However, because of their limited performance, stand-alone VR headsets cannot run demanding games. Furthermore, due to their later entry into the market, VR applications and games as a whole still lag significantly behind PC VR. To address these issues, stand-alone VR headsets have begun supporting PC VR games through streaming.

[0003] See Figure 1 As shown, Figure 1 This diagram illustrates the data flow of a VR all-in-one device running a PC VR game via streaming in existing technology. When a VR all-in-one device runs a PC VR game via streaming, the VR all-in-one device typically handles pose tracking, then sends the pose data to the PC for rendering the game screen. Finally, the PC sends the game screen (VR application screen) back to the VR all-in-one device for display. Because latency can severely negatively impact the VR experience, causing stuttering and dizziness, the VR all-in-one device doesn't directly display the game screen. Instead, based on the pose data used for rendering and the predicted pose information when the user sees the screen, it uses techniques like ATW (Asynchronous Timewarp) and ASW (Asynchronous Spacewarp) to adjust the image before outputting the adjusted display frames to the screen, ensuring that the image seen by the user matches their current pose as closely as possible.

[0004] See Figure 2 As shown, Figure 2 This diagram illustrates another data flow pattern for running PC VR games via streaming in existing VR all-in-one devices. During the process of transmitting the game screen back to the VR all-in-one device, bandwidth limitations necessitate image compression, resulting in image quality loss and increased latency. Therefore, one improvement is to directly connect the video signal output from the graphics card on the PC to the VR all-in-one device's display. Since the image is no longer processed by the VR all-in-one device in this case, ATW / ASW operations must be performed on the PC side. This means that the PC needs to predict the user's pose when viewing the image.

[0005] The basic principle of prediction is based on the pose at a certain moment, along with information such as velocity, acceleration, angular velocity, and angular acceleration at that time, and the time difference between the predicted target moment and the current pose moment, to calculate the pose corresponding to the predicted target moment. In the process of realizing this invention, the inventors discovered that:

[0006] Since the required pose, velocity, acceleration, angular velocity, and angular acceleration for prediction are all calculated based on the VR headset's clock system, they correspond to the VR headset's timestamp. Because the VR headset and PC use two separate, unconnected clock systems, a method is needed to convert the VR headset's timestamp to the PC's timestamp. This involves synchronizing the VR headset and PC's time. When the PC uses the converted timestamp to calculate the pose corresponding to the target time, the calculation is based on the VR headset's clock system, ensuring accurate predictions on the PC side. Summary of the Invention

[0007] Based on the above-mentioned technical problems, the main objective of this invention is to provide a time synchronization method, apparatus, electronic device, and computer-readable storage medium to solve the time synchronization problem between two unrelated clock systems.

[0008] According to a first aspect of the present invention, a time synchronization method is provided, applied to a first electronic device, comprising:

[0009] Obtain a first timestamp reference value of the clock system of the first electronic device, and obtain a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related;

[0010] Obtain the unprocessed timestamp of the clock system of the first electronic device;

[0011] Based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed is determined.

[0012] According to a second aspect of the present invention, a time synchronization device is provided, applied to a first electronic device, comprising:

[0013] The timestamp reference value acquisition unit is used to acquire a first timestamp reference value of the clock system of the first electronic device and a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related;

[0014] The pending timestamp acquisition unit is used to acquire the pending timestamp of the clock system of the first electronic device;

[0015] The target timestamp determination unit is used to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed, the first timestamp reference value and the second timestamp reference value, based on the timestamp to be processed, the first timestamp reference value and the second timestamp reference value.

[0016] According to a third aspect of the present invention, an electronic device is provided, including a memory and a processor.

[0017] The memory stores a computer program, which is loaded and executed by the processor to implement the aforementioned time synchronization method.

[0018] According to a fourth aspect of the present invention, a computer-readable storage medium is provided that stores one or more computer programs, which, when executed by a processor, implement the aforementioned time synchronization method.

[0019] The beneficial effects of the embodiments of the present invention are:

[0020] The time synchronization method, apparatus, electronic device, and computer-readable storage medium of this invention acquire a first timestamp reference value of the clock system of a first electronic device and a second timestamp reference value of the clock system of a second electronic device that is communicatively connected to the first electronic device. The first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are unrelated. During subsequent time synchronization, the unprocessed timestamp of the clock system of the first electronic device is acquired, and then the target timestamp of the clock system of the second electronic device corresponding to the same moment as the unprocessed timestamp is determined based on the unprocessed timestamp, the first timestamp reference value, and the second timestamp reference value, thereby synchronizing the clock systems of the first electronic device and the second electronic device.

[0021] The solution adopted in this invention can convert the timestamps of information such as pose on the VR all-in-one device into timestamps on the PC. This allows for accurate prediction of the pose information when the user sees the screen on the PC side, enabling correct processing of the screen and avoiding phenomena such as shaking and dizziness. This ensures that the final effect is comparable to PC VR. Attached Figure Description

[0022] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0023] Figure 1 This is a schematic diagram illustrating the data flow of a VR all-in-one device running a PC VR game via streaming in existing technology;

[0024] Figure 2 This is a schematic diagram illustrating another data flow method for running PC VR games via streaming in existing VR all-in-one devices;

[0025] Figure 3 This is a flowchart illustrating a time synchronization method provided in an embodiment of the present invention;

[0026] Figure 4 This is a signal flow diagram for determining a timestamp reference value provided in an embodiment of the present invention;

[0027] Figure 5 This is a flowchart illustrating another time synchronization method provided in an embodiment of the present invention;

[0028] Figure 6 A block diagram of a time synchronization device provided in an embodiment of the present invention;

[0029] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0030] Exemplary embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. These embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art. Although exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein.

[0031] Figure 3 This is a flowchart illustrating a time synchronization method provided in an embodiment of the present invention. See also... Figure 3The method of this invention is applied to a first electronic device and includes the following steps S310 to S330:

[0032] Step S310: Obtain the first timestamp reference value of the clock system of the first electronic device and the second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device. The first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are unrelated.

[0033] The following example illustrates how a VR all-in-one device can run a PC VR game via streaming. In this example, the VR all-in-one device is the first electronic device, and the PC is the second electronic device. The clock systems of the VR all-in-one device and the PC are two separate, unrelated clock systems.

[0034] To achieve time synchronization between these two clock systems, the core solution is to find the respective timestamps of the VR headset and the PC at a specific moment as reference values. This is the foundation for subsequent time synchronization. The accuracy of finding the timestamp reference value determines the magnitude of the time synchronization error; higher accuracy results in a smaller time synchronization error.

[0035] To determine the respective timestamp reference values ​​for two unrelated clock systems at the same time, this invention provides the following solution:

[0036] First, establish a communication connection between the first electronic device and the second electronic device;

[0037] Then, the clock system of the first electronic device is controlled to send a time synchronization flag to the clock system of the second electronic device in a blocking manner, and the sending time T-A1 of the time synchronization flag is recorded.

[0038] Receive the time synchronization mark returned by the clock system of the second electronic device and the reception time T-B1 of receiving the time synchronization mark, and record the reception time T-A2 of receiving the time synchronization mark;

[0039] If the time difference between T-A2 and T-A1 is less than the preset time threshold, it indicates that the signal transmission is very fast and the transmission time can be ignored. In this case, T-A1 and T-B1 are considered to correspond to the same time, and T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and T-B1 is determined as the timestamp reference value of the clock system of the second electronic device.

[0040] If the time difference between T-A2 and T-A1 is not less than a preset time threshold, the transmission time T-delta for the clock system of the second electronic device to receive the time synchronization mark is calculated. It is assumed that the difference between T-B1 and T-delta corresponds to the same time as T-A1. T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and the difference between T-B1 and T-delta is determined as the timestamp reference value of the clock system of the second electronic device.

[0041] Taking finding a baseline value via USB communication as an example, see [link / reference]. Figure 4 , Figure 4 This invention provides a signal flow diagram for determining a timestamp reference value, comprising the following steps:

[0042] Step S41: The first electronic device establishes a communication connection with the second electronic device via USB.

[0043] In step S42, the clock system of the first electronic device writes the time synchronization flag SyncFlag to the USB and sends it to the clock system of the second electronic device in a blocking manner.

[0044] Step S43, the first electronic device records the moment T-A1 when the USB return is written.

[0045] The first electronic device records T-A1 as the transmission time of the time synchronization flag SyncFlag. In this embodiment of the invention, the time synchronization flag SyncFlag is transmitted in a blocking manner, ensuring that the recorded time T-A1 is the successful transmission time; it will not be recorded if the transmission of the time synchronization flag SyncFlag fails or is in progress.

[0046] Step S44: After receiving the time synchronization flag SyncFlag, the second electronic device records the time T-B1 when the data packet is received;

[0047] In step S45, the second electronic device writes the time synchronization flag SyncFlag and T-B1 together into the USB and returns it to the first electronic device.

[0048] Step S46, the first electronic device records the time T-A2 when it receives SyncFlag and T-B1.

[0049] If T-A2 minus T-A1 is less than a preset time threshold, considering that USB transmission is extremely fast and the transmission time is negligible, T-A1 and T-B1 can be considered to correspond to the same moment. In this scenario, T-A1 can be determined as the timestamp reference value of the clock system of the first electronic device, and T-B1 can be determined as the timestamp reference value of the clock system of the second electronic device.

[0050] If T-A2 minus T-A1 is not less than a preset time threshold, then the transmission time from the first electronic device sending the time synchronization flag SyncFlag to the second electronic device needs to be calculated. This is equivalent to calculating the transmission time T-delta for the second electronic device to receive the time synchronization flag SyncFlag, and assuming that the difference between T-B1 and T-delta corresponds to the same time as T-A1. In this scenario, T-A1 can be determined as the timestamp reference value of the clock system of the first electronic device, and the difference between T-B1 and T-delta can be determined as the timestamp reference value of the clock system of the second electronic device.

[0051] The timestamp reference values ​​for the two unrelated clock systems determined through the above steps can meet the expected requirements in terms of time accuracy, ensuring that the subsequent timestamp conversion error is within a controllable range.

[0052] Step S320: Obtain the time stamp to be processed from the clock system of the first electronic device.

[0053] The timestamp to be processed can be, for example, the current timestamp value of the clock system of the first electronic device. Various methods can be used to obtain the current timestamp value of the clock system, and this embodiment of the invention does not limit this method.

[0054] Step S330: Based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, determine the target timestamp of the clock system of the second electronic device that corresponds to the timestamp to be processed at the same time.

[0055] In one method embodiment, step S330 specifically includes:

[0056] First, the timestamp difference is determined based on the difference between the timestamp to be processed and the first timestamp reference value. Then, the second timestamp reference value is added to the timestamp difference to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

[0057] The example of running a PC VR game via streaming using a VR all-in-one device, as described in the background technology, is still used. Step S330 involves subtracting the current timestamp value of the VR all-in-one device (obtained in step S320) from the base timestamp value of the VR all-in-one device (obtained in step S310) to determine the timestamp difference deltaT. Then, the PC's target timestamp is obtained by adding this timestamp difference deltaT to the PC's base timestamp value obtained in step S310. Since the PC's target timestamp corresponds to the same moment as the VR all-in-one device's processing timestamp, time synchronization between the VR all-in-one device's timestamp and the PC's timestamp is achieved, ensuring accurate pose prediction on the PC side.

[0058] Considering that in two uncorrelated clock systems, the actual time corresponding to the same timestamp difference deltaT may differ due to the difference in timing speed, this embodiment of the invention also provides another time synchronization method to correct the impact of this difference. Figure 5 This is a flowchart illustrating another time synchronization method provided in an embodiment of the present invention. See [link / reference]. Figure 5 The method of this embodiment includes the following steps S510 to S560:

[0059] Step S510: Obtain the first timestamp reference value of the clock system of the first electronic device and the second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device. The first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related.

[0060] Step S520: Obtain the first backup timestamp reference value of the clock system of the first electronic device and obtain the second backup timestamp reference value of the clock system of the second electronic device, wherein the first backup timestamp reference value and the second backup timestamp reference value correspond to another same moment;

[0061] Step S530: Determine the first timestamp reference difference based on the difference between the first timestamp reference value and the first backup timestamp reference value of the first electronic device, and determine the second timestamp reference difference based on the difference between the second timestamp reference value and the second backup timestamp reference value of the second electronic device.

[0062] Step S540: Divide the first timestamp reference difference value by the second timestamp reference difference value to determine the ratio of the timing speed of the clock system of the first electronic device and the clock system of the second electronic device.

[0063] Step S550: Obtain the time stamp to be processed of the clock system of the first electronic device, and divide the difference between the time stamp to be processed and the first time stamp reference value by the proportional relationship of the timing speed to determine the time stamp difference;

[0064] Step S560: Add the second timestamp reference value to the timestamp difference to obtain the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

[0065] It should be noted that step S550 can also be: dividing the difference between the timestamp to be processed and the first backup timestamp reference value by the proportional relationship of timing speed to determine the timestamp difference. Therefore, step S560 will be modified accordingly to: adding the timestamp difference to the second backup timestamp reference value to obtain the target timestamp of the clock system of the second electronic device at the same moment as the timestamp to be processed.

[0066] This invention provides an embodiment of the time synchronization method. It obtains the timestamp reference values ​​of two clock systems at two different times, calculates the timestamp reference difference between them, and then divides these two timestamp reference differences to obtain the proportional relationship between the timing speeds of the two clock systems. Subsequently, during time synchronization, the timestamp difference deltaT1 obtained by subtracting one of the timestamp reference values ​​from the timestamp to be processed of the first electronic device's clock system is first converted into the timestamp difference deltaT2 of the second electronic device's clock system using the proportional relationship between timing speeds. Then, the timestamp difference deltaT2 is added to the corresponding timestamp reference value of the second electronic device's clock system to obtain the target timestamp of the second electronic device's clock system. This target timestamp of the second electronic device's clock system corresponds to the same time as the timestamp to be processed of the first electronic device's clock system, thereby synchronizing the clock systems of the first and second electronic devices.

[0067] Similar to the aforementioned time synchronization method, this embodiment of the invention also provides a time synchronization device. Figure 6 This is a block diagram of a time synchronization device provided in an embodiment of the present invention. See also: Figure 6 The time synchronization device 600 of this invention is applied to a first electronic device and includes:

[0068] The timestamp reference value acquisition unit 610 is used to acquire a first timestamp reference value of the clock system of the first electronic device and a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related.

[0069] The pending timestamp acquisition unit 620 is used to acquire the pending timestamp of the clock system of the first electronic device;

[0070] The target timestamp determination unit 630 is used to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed, based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value.

[0071] In one device embodiment, the timestamp reference value acquisition unit 610 is specifically used for:

[0072] The first electronic device sends a time synchronization mark to the clock system of the second electronic device in a blocking manner, and records the sending time T-A1 of the time synchronization mark;

[0073] Receive the time synchronization mark returned by the clock system of the second electronic device and the receiving time T-B1 of receiving the time synchronization mark, and record the receiving time T-A2 of receiving the time synchronization mark;

[0074] If the time difference between T-A2 and T-A1 is less than the preset time threshold, then T-A1 and T-B1 are considered to correspond to the same moment, and T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and T-B1 is determined as the timestamp reference value of the clock system of the second electronic device.

[0075] If the time difference between T-A2 and T-A1 is not less than a preset time threshold, the transmission time T-delta for the clock system of the second electronic device to receive the time synchronization mark is calculated. It is assumed that the difference between T-B1 and T-delta corresponds to the same time as T-A1. T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and the difference between T-B1 and T-delta is determined as the timestamp reference value of the clock system of the second electronic device.

[0076] In one device embodiment, the target timestamp determination unit 630 is specifically used for:

[0077] The timestamp difference is determined based on the difference between the timestamp to be processed and the first timestamp baseline value;

[0078] The second timestamp reference value is added to the timestamp difference to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

[0079] Considering that in two unrelated clock systems, due to the difference in timing speed, the actual time corresponding to the same timestamp difference deltaT will be different.

[0080] To correct the impact of this difference, in one device embodiment, the timestamp reference value acquisition unit 610 is further configured to: acquire a first backup timestamp reference value of the clock system of the first electronic device, and acquire a second backup timestamp reference value of the clock system of the second electronic device, wherein the first backup timestamp reference value and the second backup timestamp reference value correspond to another same moment;

[0081] Correspondingly, the target timestamp determination unit 630 is specifically used for:

[0082] The first timestamp reference difference is determined based on the difference between the first timestamp reference value and the first backup timestamp reference value of the first electronic device, and the second timestamp reference difference is determined based on the difference between the second timestamp reference value and the second backup timestamp reference value of the second electronic device.

[0083] Divide the first timestamp reference difference by the second timestamp reference difference to determine the ratio of the timing speed of the clock system of the first electronic device and the clock system of the second electronic device.

[0084] The difference between the timestamp to be processed and the first timestamp reference value is divided by the proportional relationship of the timing speed to determine the timestamp difference;

[0085] Adding the second timestamp base value to the timestamp difference yields the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

[0086] The implementation process of each unit module in the time synchronization device described in the embodiments of the present invention can be found in the method embodiments, and will not be repeated here.

[0087] Similar to the aforementioned time synchronization method, this invention also provides an electronic device. See [link to related documentation]. Figure 7 The electronic device 700 provided in this embodiment of the invention includes a memory 710 and a processor 720. The memory 710 may be RAM, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk storage device. The memory 710 stores a computer program, which is loaded and executed by the processor 720 to implement the aforementioned time synchronization method.

[0088] At the hardware level, the electronic device 700 may optionally include: a display panel 730, an interface module 740, a communication module 750, etc. The memory 710, processor 720, display panel 730, interface module 740, and communication module 750 can be interconnected via an internal bus. This internal bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0089] This invention also proposes a computer-readable storage medium that stores one or more computer programs. When executed by a processor, these programs implement the aforementioned time synchronization method and are specifically used to perform the following:

[0090] The system obtains a first timestamp reference value of the clock system of the first electronic device and a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are unrelated.

[0091] Obtain the pending timestamp of the clock system of the first electronic device;

[0092] Based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, the target timestamp of the clock system of the second electronic device corresponding to the timestamp to be processed at the same time is determined.

[0093] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer program instructions.

[0094] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0095] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The functional steps specified in one or more boxes.

[0096] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, a network interface, and memory. Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0097] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0098] The above are merely embodiments of the present invention and are not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.

Claims

1. A time synchronization method, applied to a first electronic device, comprising: Obtain a first timestamp reference value of the clock system of the first electronic device, and obtain a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related; Obtain the unprocessed timestamp of the clock system of the first electronic device; Based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed is determined; The step of obtaining a first timestamp reference value of the clock system of the first electronic device and obtaining a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device includes: The first electronic device sends a time synchronization flag to the clock system of the second electronic device in a blocking manner, and records the sending time T-A1 of sending the time synchronization flag; Receive the time synchronization mark returned by the clock system of the second electronic device and the reception time T-B1 of receiving the time synchronization mark, and record the reception time T-A2 of receiving the time synchronization mark; If the time difference between T-A2 and T-A1 is less than a preset time threshold, then T-A1 and T-B1 are considered to correspond to the same time, and T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and T-B1 is determined as the timestamp reference value of the clock system of the second electronic device. If the time difference between T-A2 and T-A1 is not less than a preset time threshold, the transmission time T-delta for the clock system of the second electronic device to receive the time synchronization mark is calculated, and it is assumed that the difference between T-B1 and T-delta corresponds to the same time as T-A1. T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and the difference between T-B1 and T-delta is determined as the timestamp reference value of the clock system of the second electronic device.

2. The method of claim 1, wherein, The step of determining the target timestamp of the clock system of the second electronic device corresponding to the same moment as the timestamp to be processed, based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, includes: The timestamp difference is determined based on the difference between the timestamp to be processed and the first timestamp reference value; The second timestamp reference value is added to the timestamp difference to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

3. The method of claim 1, wherein, The method further includes: Obtain a first backup timestamp reference value of the clock system of the first electronic device, and obtain a second backup timestamp reference value of the clock system of the second electronic device, wherein the first backup timestamp reference value and the second backup timestamp reference value correspond to another same moment; The step of determining the target timestamp of the clock system of the second electronic device corresponding to the same moment as the timestamp to be processed, based on the timestamp to be processed, the first timestamp reference value, and the second timestamp reference value, includes: The first timestamp reference difference is determined based on the difference between the first timestamp reference value and the first backup timestamp reference value of the first electronic device, and the second timestamp reference difference is determined based on the difference between the second timestamp reference value and the second backup timestamp reference value of the second electronic device. Divide the first timestamp reference difference value by the second timestamp reference difference value to determine the ratio of the timing speed of the clock system of the first electronic device and the clock system of the second electronic device; The difference between the timestamp to be processed and the first timestamp reference value is divided by the proportional relationship of the timing speed to determine the timestamp difference; The second timestamp reference value is added to the timestamp difference to obtain the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

4. A time synchronization device, applied to a first electronic device, comprising: The timestamp reference value acquisition unit is used to acquire a first timestamp reference value of the clock system of the first electronic device and a second timestamp reference value of the clock system of the second electronic device that is communicatively connected to the first electronic device, wherein the first timestamp reference value and the second timestamp reference value correspond to the same moment, and the clock systems of the first electronic device and the second electronic device are not related; The pending timestamp acquisition unit is used to acquire the pending timestamp of the clock system of the first electronic device; The target timestamp determination unit is used to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed, the first timestamp reference value and the second timestamp reference value, based on the timestamp to be processed, the first timestamp reference value and the second timestamp reference value; Specifically, the timestamp reference value acquisition unit is used for: The first electronic device sends a time synchronization flag to the clock system of the second electronic device in a blocking manner, and records the sending time T-A1 of sending the time synchronization flag; Receive the time synchronization mark returned by the clock system of the second electronic device and the reception time T-B1 of receiving the time synchronization mark, and record the reception time T-A2 of receiving the time synchronization mark; If the time difference between T-A2 and T-A1 is less than a preset time threshold, then T-A1 and T-B1 are considered to correspond to the same time, and T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and T-B1 is determined as the timestamp reference value of the clock system of the second electronic device. If the time difference between T-A2 and T-A1 is not less than a preset time threshold, the transmission time T-delta for the clock system of the second electronic device to receive the time synchronization mark is calculated, and it is assumed that the difference between T-B1 and T-delta corresponds to the same time as T-A1. T-A1 is determined as the timestamp reference value of the clock system of the first electronic device, and the difference between T-B1 and T-delta is determined as the timestamp reference value of the clock system of the second electronic device.

5. The apparatus of claim 4, wherein, The target timestamp determination unit is specifically used for: The timestamp difference is determined based on the difference between the timestamp to be processed and the first timestamp reference value; The second timestamp reference value is added to the timestamp difference to determine the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

6. The apparatus of claim 4, wherein, The timestamp reference value acquisition unit is further configured to: acquire a first backup timestamp reference value of the clock system of the first electronic device, and acquire a second backup timestamp reference value of the clock system of the second electronic device, wherein the first backup timestamp reference value and the second backup timestamp reference value correspond to another same moment; The target timestamp determination unit is specifically used for: The first timestamp reference difference is determined based on the difference between the first timestamp reference value and the first backup timestamp reference value of the first electronic device, and the second timestamp reference difference is determined based on the difference between the second timestamp reference value and the second backup timestamp reference value of the second electronic device. Divide the first timestamp reference difference value by the second timestamp reference difference value to determine the ratio of the timing speed of the clock system of the first electronic device and the clock system of the second electronic device; The difference between the timestamp to be processed and the first timestamp reference value is divided by the proportional relationship of the timing speed to determine the timestamp difference; The second timestamp reference value is added to the timestamp difference to obtain the target timestamp of the clock system of the second electronic device at the same time as the timestamp to be processed.

7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, the computer program being loaded and executed by the processor to implement the time synchronization method of any one of claims 1-3.

8. A computer-readable storage medium storing one or more computer programs that, when executed by a processor, implement the time synchronization method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Method, device and equipment for improving clock synchronization precision

    CN107749788A

  • System and Method for Time Stamp Synchronization

    US20190155327A1

  • System and Method for Time Stamp Synchronization

    US20190158203A1