Time and time zone synchronization method of vehicle-mounted terminal
By obtaining the time data of the internal and external clock sources of the vehicle terminal and performing monotonic smooth synchronization, the problems of low time synchronization accuracy and error accumulation of on-board terminals are solved, and fast and stable time and time zone synchronization is achieved.
Patent Information
- Application Number
- CN202510605336.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-07-22
AI Technical Summary
The existing time synchronization method of on-board terminals has problems such as single time synchronization, high expansion difficulty, slow synchronization speed, low time synchronization accuracy and time error accumulation, and periodic smooth synchronization cannot be performed.
By obtaining the time data of internal and external clock sources, monotonic smooth synchronization is performed, and the GPS time, NTP time and NITZ time are sampled using inter-core communication and interrupt callback functions, and time zone information is obtained in combination with the TSP server to achieve automatic synchronization of system time and time zone.
It realizes fast, stable and monotonously increasing time synchronization, improves time synchronization accuracy and time calibration efficiency, and ensures the accuracy and consistency of system time and time zone information.
Smart Images

Figure CN120357990A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vehicle interaction, and in particular, to a method for synchronizing time and time zone of an in-vehicle terminal. Background Art
[0002] Currently, for the time synchronization method of in-vehicle terminals, the solution of the open-source application chrony is generally used, and time synchronization is performed through the NTP or GPS protocol. For the time synchronization method of traditional electrical architecture vehicles, a self-designed time synchronization service is also used for time synchronization.
[0003] Among them, for the time synchronization of the chrony solution, the time source is single and the expansion is difficult; for the time synchronization of the chrony solution, the time synchronization on the in-vehicle terminal is slow. Since the in-vehicle terminal is a device that is often powered off and on, at the initial stage of its startup, it needs to complete the driver loading and initialization of each module, and it takes a certain amount of time for the wireless resources to be normally used. At this time, chrony has entered the normal working stage, and it cannot quickly know whether the wireless network resources are ready. Generally, a cycle is set to poll the target time source, so the time for time synchronization will be longer, and the chrony solution cannot synchronize the internal clock source, such as the MCU clock in the Tbox.
[0004] When the self-designed time synchronization service program switches from a low-priority clock source to a high-priority clock source, the time synchronization system may have a phenomenon of system time jumping or regressing during time calibration, which cannot meet the requirement of monotonic increase. In addition, when the self-designed time synchronization service program locks the current priority clock source, it directly calibrates the system time without performing time validity judgment, which may cause the system time to be incorrect and unable to perform periodic time synchronization to correct the time of the vehicle system. In this way, the time error of the whole vehicle will gradually accumulate and increase, and the accuracy problem caused by physical reasons cannot be repaired. Summary of the Invention
[0005] To solve the above problems, the present invention provides a method for synchronizing time and time zone of an in-vehicle terminal, which synchronizes the internal time source, samples the external time source, and smooths and synchronizes the system time according to the sampling result, and synchronizes the time zone according to the positioning information, thereby solving the problems that the prior art cannot perform periodic and smooth time synchronization and the time synchronization accuracy is low.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A method for synchronizing time and time zone of an in-vehicle terminal, the in-vehicle terminal includes a plurality of internal clock sources and a plurality of external clock sources, and the method includes:
[0008] Obtain the internal time data of each internal clock source, and synchronize the system time according to all the internal time data;
[0009] Continuously sample the external time data of each external clock source, and perform monotonic smoothing synchronization on the system time according to all the external time data;
[0010] The system time is continuously synchronized with the external clock source;
[0011] Continuously query the positioning information. After obtaining the positioning information each time, obtain the time zone information according to the positioning information, and refresh the system time zone according to the time zone information.
[0012] Further, the obtaining of the internal time data of each internal clock source specifically includes:
[0013] Read the MCU system time of the MCU by using inter-core communication, and read the file system time stored in the EMMC.
[0014] Further, the synchronization of the system time according to all the internal time data is specifically implemented as follows:
[0015] Compare the MCU system time, the file system time and the system time, and take the largest time as the system time, and synchronize the MCU system time and the file system time to the system time.
[0016] Further, the external clock sources include: GPS time, NTP time, NITZ time and TSP time.
[0017] Further, the continuous sampling of the external time data of each external clock source is specifically implemented as follows:
[0018] For GPS time, send a pulse every whole second. When sending the pulse, establish an interrupt callback function. The interrupt callback function records the current timestamp T1. After delaying a preset time interval, read the time packet cached by the GPS. Take the whole second part of the time packet as T0, and record the timestamp T2 at this time. Then the GPS time is T0+(T2-T1) / 1000*1000;
[0019] For NTP time, send a request packet to the NTP server, record the sending timestamp t1 of the request packet. When the request packet arrives at the NTP server, record the arrival timestamp t2. The NTP server returns a time packet containing the current time, record the timestamp t3 of the returned response packet, receive the response packet, and record the timestamp t4 of receiving the response packet. Calculate the time difference offset = ((t2-t1)+(t3-t4)) / 2. Then the NTP time is the system time + offset;
[0020] For NITZ time, receive the NITZ packet sent by the receiving base station, intercept the NITZ packet, parse the NITZ packet of this frame to obtain the timestamp, and if the parsing is successful, use this timestamp as the NITZ time.
[0021] Further, when the GPS time, NTP time, and NITZ time are all inaccessible, request time from the TSP server. If the TSP server responds and returns time, use the returned time as the TSP time.
[0022] Further, perform monotonic smoothing synchronization on the system time according to all external time data. The specific implementation method is as follows:
[0023] S1. For the time samples obtained by sampling each external time source at the sampling period, there is:
[0024] After sampling no less than the preset number of time samples, divide the sampled time samples into a group for optimization:
[0025] The time samples in this group must be monotonically increasing. The difference between the front and back of this group of time samples must be greater than or equal to 0.5 sampling periods and less than or equal to 1.5 sampling periods. When the above conditions are not met, discard this group of time samples. Otherwise, retain this group of time samples, calculate the difference between each time sample and the system time at the time of sampling of this time sample, and obtain the difference data;
[0026] S2. Classify according to the external time source, put the difference data of each external time source into an array, calculate the range of each array. When the range of the array is greater than the range threshold, discard the data of this array. Otherwise, retain the data of this array;
[0027] S3. When the retained data comes from only one external time source, calculate the average value of all deviation data, and use the average value as the adjustment target value of the system time. When the retained data comes from multiple external clock sources, calculate the standard deviation of each array, and use the average value of the array with the smallest standard deviation as the adjustment value of the system time;
[0028] S4. If the absolute value of the adjustment value is greater than the adjustment threshold, directly add the adjustment time to the system time as the new system time. If the absolute value of the adjustment value is less than the adjustment threshold, perform smooth adjustment on the system time according to the adjustment value.
[0029] Further, the specific implementation method of performing smooth adjustment on the system time according to the adjustment value is as follows:
[0030] The system time changes according to the beat period T. Denote the adjustment value as A, the ratio of the period shortening as z, and the number of beats required for system time adjustment as n.
[0031] If the adjustment value is greater than 0, record the current beat count value N1, modify the beat period to (1 - z)*T, and resume the beat period to the original beat period T until the beat count value increases to equal N1 + n, then the time synchronization is completed;
[0032] If the adjustment value is less than 0, record the current beat count value N1, then change the beat period to (1 + z)*T, and resume the beat period to the original beat period T until the beat count value equals N1 + n, then the time synchronization is completed.
[0033] Furthermore, the system time continuously synchronizes with an external clock source;
[0034] Request time information from the external time source according to a preset period, and send three time information requests each time. If the external time source responds, sample the external time source and perform system time synchronization according to the sampling result. If the external time source does not respond, a new request will be made in the next period.
[0035] Furthermore, the specific implementation method of obtaining the time zone information according to the positioning information and refreshing the system time zone is as follows:
[0036] Establish communication with the TSP server, send the positioning information to the TSP server, the TSP server returns the time zone information according to the received positioning information, update the system time zone according to the time zone information, and update the system time zone cached by each process.
[0037] Through the above technical solutions, the present invention has the following beneficial effects: manage all available time sources, including external NTP, GPS, TSP, NITZ clock sources, and internal MCU, EMMC clock sources, to quickly and adaptively select the best external time source. At the same time, it also provides a method to obtain the user's current time zone information through its own positioning module and automatically adjust the system time zone. The present invention provides smooth, monotonically increasing, stable and most efficient time synchronization, with more available time sources and higher time calibration efficiency. At the same time, its working principle is transparent, controllable, more independent, safe and reliable. Brief Description of the Drawings
[0038] Figure 1 It is a schematic diagram of the overall process of the time and time zone synchronization method for an in-vehicle terminal of the present invention. Detailed Embodiments
[0039] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0040] To make the above objects, features, and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] See Figure 1 , a method for time and time zone synchronization of a vehicle-mounted terminal. The vehicle-mounted terminal includes a plurality of internal clock sources and a plurality of external clock sources. The method includes:
[0042] Obtain the internal time data of each internal clock source, and synchronize the system time according to all the internal time data;
[0043] Continuously sample the external time data of each external clock source, and perform monotonic smoothing synchronization on the system time according to all the external time data;
[0044] The system time is continuously synchronized with the external clock source;
[0045] Continuously query the positioning information. After obtaining the positioning information each time, obtain the time zone information according to the positioning information, and refresh the system time zone according to the time zone information.
[0046] In an optional embodiment, the obtaining of the internal time data of each internal clock source specifically includes:
[0047] Read the MCU system time of the MCU using inter-core communication, and read the file system time stored in the EMMC.
[0048] MCU (Micro Control Unit), that is, a microcontroller, refers to the integration of the computer's CPU, RAM, ROM, timer counter, and various I / O interfaces on a single chip with the emergence and development of large-scale integrated circuits, forming a chip-level chip that integrates the entire computer system. The system time of the MCU is equal to 0 when it is powered on and started. The SOC (System on Chip) of the vehicle-mounted terminal will update the system clock to it at the time of time synchronization and regularly every 30 seconds. Therefore, in the case of no power failure, the system time of the MCU will keep running normally. After the SOC is abnormally restarted, the MCU is still running normally. At this time, the SOC reads the time of the MCU to quickly restore its system time.
[0049] EMMC is a storage device integrating a controller and a storage chip, suitable for applications in fields such as mobile devices, embedded systems, and some consumer electronics products. At the time of time synchronization and at regular 30-second intervals, the time will be updated once and saved to the EMMC file. After the SOC restarts, the SOC reads the time saved in the EMMC file and can obtain the most recent system time before the SOC power-off. Specifically, by reading the file system time and CRC check value stored in the EMMC and performing CRC verification, it can be ensured that the read time is reliable.
[0050] In an alternative embodiment, the synchronization of the system time based on all internal time data is specifically implemented as follows:
[0051] Compare the MCU system time, the file system time, and the system time, and take the one with the largest time as the system time, and synchronize the MCU system time and the file system time to the system time.
[0052] Specifically, verify the MCU time and the file system time. After passing the timestamp legality check, compare it with the current system timestamp, select the maximum value among the three, and modify the times of the other two time sources to make the times of the three consistent, so that after power-on startup, the synchronization of the internal clock source can be completed first, enabling applications that rely on timestamps to run normally.
[0053] In an alternative embodiment, the external clock sources include: GPS time, NTP time, NITZ time, and TSP time.
[0054] GPS time is the time system adopted by the Global Positioning System (GPS). It uses atomic time as the time reference. The position of GPS satellites, as high-altitude observation targets, is constantly changing. Therefore, when giving the satellite's operating position, the corresponding instantaneous time must be given, so as to obtain time information for synchronization during positioning.
[0055] NTP (Network Time Protocol), that is, the Network Time Protocol, is widely used to synchronize computers to Internet time servers or other sources, such as radio or satellite receivers or telephone modem services.
[0056] NITZ (Network Identity and Time Zone), that is, network identity and time zone, is a mechanism for automatically configuring local time and date, and also provides operator information to mobile devices via wireless networks. NIT is often used to automatically update the system clock of mobile phones. The original update mechanism of Android adopts the NITZ method, which is an optional service of the operator. Briefly speaking, its basic principle is to update the time and time zone of the terminal system according to the time information actively reported by the Modem.
[0057] TSP (Telematics Service Provider), that is, the background of the vehicle telematics service provider, connects to vehicles, in-vehicle device manufacturers, and network operators at the top, and content providers at the bottom, and provides time synchronization services as the background of in-vehicle terminals.
[0058] The time sample acquisition algorithms for time synchronization are divided into two cases: active acquisition and passive acquisition.
[0059] 1) GPS and NITZ belong to passive acquisition. For GPS, when there is a 1PPS pulse, the time information of GPS is acquired after a delay. For NITZ, it needs to be acquired when sent by the base station.
[0060] 2) NTP and TSP belong to active acquisition.
[0061] In an optional embodiment, the continuous sampling of the external time data of each external clock source is specifically implemented as follows:
[0062] For GPS time, a pulse is sent every whole second. When the pulse is sent, an interrupt callback function is established. The interrupt callback function records the current timestamp T1. After a preset time interval, the time message cached by GPS is read. The whole second part of the time message is taken as T0, and the timestamp T2 at this time is recorded. Then the GPS time is T0+(T2-T1) / 1000*1000;
[0063] For NTP time, a request message is sent to the NTP server. The sending timestamp t1 of the request message is recorded. When the request message arrives at the NTP server, the arrival timestamp t2 is recorded. The NTP server returns a time message containing the current time, and the timestamp t3 of the returned response message is recorded. The response message is received, and the timestamp t4 when the response message is received is recorded. The time difference offset = ((t2-t1)+(t3-t4)) / 2 is calculated. Then the NTP time is the system time + offset;
[0064] For the NITZ time, receive the NITZ packet sent by the receiving base station, intercept the NITZ packet, parse the frame of NITZ packet to obtain the timestamp, and if the parsing is successful, use the timestamp as the NITZ time.
[0065] Specifically, the GPS receiving module (GPS Receiver) can generate a second pulse signal, whose function is to indicate the time interval of the whole second, and mark the specific moment corresponding to the UTC (Coordinated Universal Time) time given by GPS through the rising edge of PPS. And the GPS time is accurate to microseconds. Among them, the units of the timestamp T1 and the timestamp T2 are microseconds. Therefore, in actual calculation, the calculation formula of the system time is
[0066]
[0067] The NTP server includes a radio or satellite receiver or a telephone modem service. Obtain time information by requesting a message from the NTP server, and calculate the delay between the time at the NTP server end according to the delay of sending and receiving messages, so as to synchronize the time.
[0068] During the driving process of the vehicle, due to the change of position, the connected base stations are different. Therefore, when switching base stations, it is possible to receive NITZ thrown by the base station. Whether the base station supports NITZ time and time zone information is determined by the operator. The time synchronization service intercepts this frame of information and parses the timestamp in it. If the parsing is successful, this time sample value will be recorded.
[0069] In an optional embodiment, when the GPS time, NTP time, and NITZ time are all inaccessible, request time from the TSP server. If the TSP server responds and returns time, use the returned time as the TSP time.
[0070] The principle of the TSP reading the time source is the same as that of the NTP. The TSP provides a time service. When the previous several time sources are all inaccessible, the time synchronization service program of the Tbox will request time from the TSP background. If the TSP responds, this time sample value will be recorded.
[0071] In an optional embodiment, perform monotonic smooth synchronization of the system time according to all external time data. The specific implementation method is as follows:
[0072] S1. For each time sample obtained by sampling each external time source at the sampling period, there is:
[0073] After obtaining no less than the preset number of time samples by sampling, divide the sampled time samples into a group for optimization:
[0074] This set of time samples must be monotonically increasing. The difference between the front and back of this set of time samples must be greater than or equal to 0.5 sampling periods and less than or equal to 1.5 sampling periods. When the above conditions are not met, this set of time samples is discarded; otherwise, this set of time samples is retained, and the difference between each time sample and the system time at the time of sampling of this time sample is calculated to obtain difference data.
[0075] S2. Classify according to the external time source. The difference data of each external time source is put into an array, and the range of each array is calculated. When the range of the array is greater than the range threshold, the data of this array is discarded; otherwise, the data of this array is retained.
[0076] S3. When the retained data comes from only one external time source, calculate the average value of all deviation data, and use the average value as the adjustment target value of the system time. When the retained data comes from multiple external clock sources, calculate the standard deviation of each array, and use the average value of the array with the smallest standard deviation as the adjustment value of the system time.
[0077] S4. If the absolute value of the adjustment value is greater than the adjustment threshold, directly add the adjustment time to the system time as the new system time. If the absolute value of the adjustment value is less than the adjustment threshold, smooth the adjustment of the system time according to the adjustment value.
[0078] Specifically, the sampling period is set to 1 s, the range threshold is set to 1 s, and the adjustment threshold is set to 5 s. If the time values differ too much, the adjustment will take a rather long time, and it is not suitable to use the method of smooth transition. Therefore, direct modification is performed to ensure the correction efficiency.
[0079] In an optional embodiment, the smooth adjustment of the system time according to the adjustment value is specifically implemented as follows:
[0080] The system time changes according to the beat period T. Denote the adjustment value as A, the proportion of cycle shortening as z, and the number of beats required for system time adjustment as n.
[0081] If the adjustment value is greater than 0, record the current beat count value N1, modify the beat period to (1 - z)*T, and until the beat count value increases to equal N1 + n, restore the beat period to the original beat period T, and the time synchronization is completed.
[0082] If the adjustment value is less than 0, record the current beat count value N1, then change the beat period to (1 + z)*T, and until the beat count value is equal to N1 + n, restore the beat period to the original beat period T, and the time synchronization is completed.
[0083] If the adjustment value is greater than 0, it indicates that the system clock lags behind the reference clock. Then the time synchronization service will shorten the clock tick period. Assuming the average value is equal to A, the system tick period is equal to T, and the proportion of period shortening is z. Then the system time that can be increased per tick after adjustment is z*T. Then it takes n ticks to synchronize the time, and there will be such an equation: z*T*n = A, and we get n = A / (T*z).
[0084] If the adjustment value is less than 0, it indicates that the system clock is ahead of the reference clock. Similarly, the time synchronization service will extend the clock tick period. Assuming the average value is equal to A, the system tick period is equal to T, and the proportion of period extension is z. Then the system time that can be increased per tick after adjustment is z*T. Then it takes n ticks to synchronize the time, and there will be such an equation: z*T*n = A, and we get n = A / (T*z).
[0085] The proportion z can be dynamically set according to the adjustment value. For example, in the range [0, 1), z is equal to 0.1; in the range [1, 2), z is equal to 0.2; in the range [2, 3), z is equal to 0.3; in the range [3, 4), z is equal to 0.4; in the range [4, 5), z is equal to 0.5. The purpose is to enable the system clock to quickly complete the time adjustment.
[0086] After completing the time synchronization, a flag bit will be set. All SOC applications can query this flag bit to determine whether the current system time has been calibrated, so as to perform their own business logic.
[0087] In an optional embodiment, the system time continuously synchronizes with an external clock source;
[0088] Request time information from the external time source according to a preset period. Each time, send three time information requests. If the external time source responds, sample the external time source and perform system time synchronization according to the sampling result. If the external time source does not respond, the request will be made again in the next period.
[0089] Specifically, when the time synchronization service completes the time calibration, it will request time information from the time source three times at an interval of one minute. If the time source responds, sample the target and start the time synchronization adjustment algorithm for fine time adjustment to ensure that the system time can follow the external time source. If the time source does not respond, the query and adjustment will be started again in the next period, which can ensure that the system time is regularly synchronized with the actual time without interruption, and when the network environment is poor, it has no impact on time synchronization.
[0090] In an optional embodiment, the specific implementation method of obtaining the time zone information according to the positioning information and refreshing the system time zone is as follows:
[0091] Establish communication with the TSP server, send location information to the TSP server, and the TSP server returns time zone information based on the received location information. Update the system time zone according to the time zone information and update the system time zone cached by each process.
[0092] After the time zone synchronization service is started, obtain the information of the positioning module through the internal inter-process communication interface, establish communication with the TSP background through the secure TLS interface, and obtain the time zone information of the current user. Since the time zone database may be adjusted due to geopolitics or time, the TSP background updates the global geographical location time zone database according to the latest release, so that all terminal devices can obtain the time zone information corresponding to the latest geographical location, which is convenient for unified management. After the time synchronization service obtains the time zone information, it will immediately update the system time zone information. It should be noted that the time zone information of each application process is cached in the system when the software is started. Therefore, when the system time zone changes, the cached time zone information of each process needs to be updated.
[0093] In an optional embodiment, request time zone information according to a preset time zone update period and update the system time zone.
[0094] Since the geographical location range of each time zone is relatively large for users, the cycle time of this request for TSP time zone synchronization does not need to be very frequent, which can also reduce the processing task of the TSP server request. Therefore, the time zone update period is set to 2 hours.
[0095] The embodiments disclosed in this specification are only an illustration of the unilateral features of the present invention. The protection scope of the present invention is not limited to this embodiment, and any other functionally equivalent embodiments fall within the protection scope of the present invention. For those skilled in the art, various corresponding changes and deformations can be made according to the technical solutions and concepts described above, and all these changes and deformations should fall within the protection scope of the claims of the present invention.
Claims
1. A time and time zone synchronization method for a vehicle-mounted terminal, characterized in that, The vehicle-mounted terminal includes several internal clock sources and several external clock sources, and the method includes: Obtain the internal time data of each internal clock source, and synchronize the system time according to all the internal time data; Continuously sample the external time data of each external clock source, and perform monotonic smoothing synchronization on the system time according to all the external time data; The system time is continuously synchronized with the external clock source; Continuously query the positioning information. After obtaining the positioning information each time, obtain the time zone information according to the positioning information, and refresh the system time zone according to the time zone information.
2. The time and time zone synchronization method of an in-vehicle terminal according to claim 1, characterized in that, The obtaining of the internal time data of each internal clock source specifically includes: Read the MCU system time of the MCU by using inter-core communication, and read the file system time stored in the EMMC.
3. A method for synchronizing time and time zone of an in-vehicle terminal according to claim 2, characterized in that, The synchronization of the system time according to all the internal time data is specifically implemented as follows: Compare the MCU system time, the file system time and the system time, and take the one with the largest time as the system time, and synchronize the MCU system time and the file system time to the system time.
4. A time and time zone synchronization method for a vehicle-mounted terminal according to claim 1, characterized in that, The external clock sources include: GPS time, NTP time, NITZ time and TSP time.
5. A method for synchronizing time and time zone of an in-vehicle terminal according to claim 4, characterized in that, The continuous sampling of the external time data of each external clock source is specifically implemented as follows: For GPS time, send a pulse every whole second. When sending the pulse, establish an interrupt callback function. The interrupt callback function records the current timestamp T1. After delaying a preset time interval, read the time packet cached by the GPS, and take the whole second part of the time packet as T0, and record the timestamp T2 at this time. Then the GPS time is T0+(T2-T1); For NTP time, send a request packet to the NTP server, record the sending timestamp t1 of the request packet. When the request packet arrives at the NTP server, record the arrival timestamp t2. The NTP server returns a time packet containing the current time, record the timestamp t3 of the returned response packet, receive the response packet, and record the timestamp t4 when receiving the response packet. Calculate the time difference offset = ((t2-t1)+(t3-t4)) / 2. Then the NTP time is the system time + offset; For NITZ time, receive the NITZ packet sent by the base station, intercept the NITZ packet, parse the frame of the NITZ packet to obtain the timestamp, and if the parsing is successful, use the timestamp as the NITZ time.
6. A method for synchronizing time and time zone of an in-vehicle terminal according to claim 5, characterized in that, When the GPS time, NTP time and NITZ time are all inaccessible, request the time from the TSP server. If the TSP server responds and returns the time, use the returned time as the TSP time.
7. A time and time zone synchronization method for an in-vehicle terminal according to claim 1, characterized in that The monotonic smoothing synchronization of the system time according to all the external time data is specifically implemented as follows: S1. For the time samples obtained by sampling each external time source at the sampling period, there is: After sampling not less than the preset number of time samples, divide the sampled time samples into a group for optimization: This set of time samples must be monotonically increasing. The difference between the front and back of this set of time samples must be greater than or equal to 0.5 sampling periods and less than or equal to 1.5 sampling periods. When the above conditions are not met, this set of time samples is discarded; otherwise, this set of time samples is retained, and the difference between each time sample and the system time at the time of sampling of this time sample is calculated to obtain difference data; S2. Classify according to the external time source. The difference data of each external time source is put into an array, and the range of each array is calculated. When the range of the array is greater than the range threshold, the data of this array is discarded; otherwise, the data of this array is retained; S3. When the retained data comes from only one external time source, calculate the average value of all the deviation data, and use the average value as the adjustment target value of the system time. When the retained data comes from multiple external clock sources, calculate the standard deviation of each array, and use the average value of the array with the smallest standard deviation as the adjustment value of the system time; S4. If the absolute value of the adjustment value is greater than the adjustment threshold, directly add the adjustment time to the system time as the new system time. If the absolute value of the adjustment value is less than the adjustment threshold, smooth the adjustment of the system time according to the adjustment value.
8. A method for synchronizing time and time zone of an in-vehicle terminal according to claim 7, characterized in that, The specific implementation method of smoothing the adjustment of the system time according to the adjustment value is as follows: The system time changes according to the beat period T. Denote the adjustment value as A, the ratio of the period shortening as z, and the number of beats required for system time adjustment as n. If the adjustment value is greater than 0, record the current beat count value N1, modify the beat period to (1 - z)*T, until the beat count value increases to N1 + n, then restore the beat period to the original beat period T, and the time synchronization is completed; If the adjustment value is less than 0, record the current beat count value N1, then change the beat period to (1 + z)*T, until the beat count value is equal to N1 + n, then restore the beat period to the original beat period T, and the time synchronization is completed.
9. A time and time zone synchronization method for a vehicle-mounted terminal according to claim 1, characterized in that, The system time continues to be synchronized with the external clock source; Request time information from the external time source according to the preset period, and send three time information requests each time. If the external time source responds, sample the external time source and perform system time synchronization according to the sampling result. If the external time source does not respond, the request will be made again in the next period.
10. A method for synchronizing time and time zone of an in-vehicle terminal according to claim 1, characterized in that, The specific implementation method of obtaining the time zone information according to the positioning information and refreshing the system time zone is as follows: Establish communication with the TSP server, send the positioning information to the TSP server, the TSP server returns the time zone information according to the received positioning information, update the system time zone according to the time zone information, and update the system time zone cached by each process.
Citation Information
Patent Citations
Master-slave equipment time synchronization method
CN111970080A
Vehicle-mounted T-BOX time synchronization method, electronic equipment and storage medium
CN119676277A
A method, an equipment and a system for the network clock synchronization
WO2009076908A1