Time processing method and device, computer equipment and computer readable storage medium

By obtaining candidate times from multiple candidate clock sources and correcting, the time overflow problem caused by 32-bit integer variables in vehicle OTA upgrade is solved, and the reliability and accuracy of time synchronization is improved, ensuring the success of OTA upgrade .

CN119300133AActive Publication Date: 2025-01-10CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411395348.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-01-10
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

During the OTA upgrade process, the vehicle uses 32-bit integer variable to represent time, time overflow occurs about every 49 days, causing the system to fail to achieve OTA upgrade.

Method used

By obtaining candidate times from multiple candidate clock sources, selecting the reference time according to the priority of the candidate clock source, and correcting according to the current timing format of the reference time, the timing format of the local clock source, and the timing overflow mechanism, ensuring that the target time overflows in time on time is timed The time of the local clock source is updated within the time range of the mechanism.

Benefits of technology

Improve the reliability and accuracy of time synchronization, avoid time deviations caused by mismatch in timing formats or different overflow mechanisms, and ensure the accuracy of vehicle OTA upgrades.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119300133A_ABST
    Figure CN119300133A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of vehicles, in particular to a time processing method and device, computer equipment and a computer readable storage medium. The method comprises the following steps: acquiring corresponding candidate time from candidate clock sources except a local clock source under the condition that a time updating event aiming at the local clock source corresponding to a main controller is detected; wherein each candidate clock source comprises a system clock source of a target vehicle system bearing the main controller, and an external clock source of external equipment communicating with the main controller; selecting reference time from the obtained candidate time according to the priority of each candidate clock source; correcting the reference time according to a current timing format corresponding to the reference time, a local timing format of the local clock source and a timing overflow mechanism of the local clock source to obtain target time; and updating the local time of the local clock source by adopting the target time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle technology, and in particular to a time processing method, device, computer equipment and computer-readable storage medium. Background Art

[0002] Over the Air Technology (OTA) upgrade refers to the technology of automatically downloading upgrade packages through wireless networks and remotely upgrading the vehicle's systems or applications. OTA upgrade not only provides car owners with a more convenient way to upgrade their vehicles, but also brings a smarter and more convenient car experience.

[0003] Among them, time management and data communication protocol are two key links in the OTA upgrade process. At present, the vehicle system or application uses absolute time (such as UNIX timestamp) as the reference timing clock to control the time synchronization and data transmission during the OTA upgrade process, specifically using 32-bit integer variables to store and transmit time values.

[0004] However, when using a 32-bit integer variable to represent time, its maximum value is 2^31-1 (because one bit is used to indicate positive and negative), which causes an overflow approximately every 49 days. The overflow is a time anomaly. In the case of a time anomaly, the vehicle's system or application may not be able to implement the OTA upgrade process, so improvement is urgently needed. Summary of the invention

[0005] Based on this, it is necessary to provide a time processing method, device, computer equipment and computer-readable storage medium that can achieve time synchronization in response to the above technical problems.

[0006] In a first aspect, the present application provides a time processing method, the method comprising:

[0007] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a system clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0008] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0009] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0010] The local time of the local clock source is updated using the target time.

[0011] In one of the embodiments, detecting a time update event for a local clock source corresponding to the master controller includes at least one of the following:

[0012] A space download technology OTA upgrade task for a target electronic control unit ECU is received; wherein the target ECU is an ECU managed by a main controller;

[0013] Receiving a time update instruction for a local clock source corresponding to the master controller;

[0014] A timing overflow was detected in the local clock source.

[0015] In one embodiment, the candidate clock sources include a system clock source of a target vehicle system hosting the host controller and an external clock source of an external device in communication with the host controller;

[0016] The system clock source includes an interface time source of an operating system corresponding to the target vehicle system and / or a device clock source of a hardware device deployed by the target vehicle system;

[0017] External devices include a cloud platform and / or a vehicle gateway device in a target vehicle.

[0018] In one embodiment, the reference time is corrected according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time, including:

[0019] When the current timing format corresponding to the reference time is inconsistent with the local timing format of the local clock source, the reference time is format converted according to the format conversion relationship between the current timing format and the local timing format to obtain an alternative time in the local timing format;

[0020] The timing overflow mechanism of the local clock source is used to correct the alternative time and obtain the target time.

[0021] In one embodiment, the timing overflow mechanism of the local clock source is used to correct the candidate time to obtain the target time, including:

[0022] If the candidate time exceeds the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source, the overflow upper limit time is subtracted from the candidate time to obtain the target time.

[0023] In one embodiment, the timing overflow mechanism of the local clock source is used to correct the candidate time to obtain the target time, including:

[0024] If the candidate time is less than the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source and is greater than the update duration required for the time update event, the reference time is used as the target time.

[0025] In one embodiment, the reference time includes an integer time portion and a decimal time portion; and the reference time is corrected according to a current timing format corresponding to the reference time, a local timing format of a local clock source, and a timing overflow mechanism of the local clock source to obtain a target time, including:

[0026] According to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, the integer part of the reference time is corrected to obtain the target time;

[0027] Use the target time to update the local time of the local clock source, including:

[0028] The sum of the target time and the fractional time portion is used as the updated local time of the local clock source.

[0029] In one embodiment, the method further comprises:

[0030] When a time update request is received from the controller, the updated local time corresponding to the local clock source is encrypted to obtain the encrypted time;

[0031] The encrypted time is sent to the slave controller, so that the slave controller updates the local time of the slave controller according to the encrypted time.

[0032] In a second aspect, the present application further provides a time processing device, the device comprising:

[0033] A multi-source time acquisition module, configured to acquire corresponding candidate time from candidate clock sources other than the local clock source when a time update event for a local clock source corresponding to the main controller is detected; wherein the candidate clock sources include a system clock source of a target vehicle system carrying the main controller and an external clock source of an external device communicating with the main controller;

[0034] A multi-source time selection module is used to select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0035] A time correction module, used to correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0036] The time update module is used to update the local time of the local clock source using the target time.

[0037] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0038] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a system clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0039] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0040] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0041] The local time of the local clock source is updated using the target time.

[0042] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0043] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a system clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0044] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0045] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0046] The local time of the local clock source is updated using the target time.

[0047] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0048] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a system clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0049] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0050] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0051] The local time of the local clock source is updated using the target time.

[0052] The above-mentioned time processing method, device, computer equipment and computer-readable storage medium, the present application increases the data source of time synchronization and improves the reliability of time synchronization by obtaining candidate time from multiple candidate clock sources (including clock sources and external clock sources). Even if a clock source fails or has time deviation, accurate time information can still be obtained from other clock sources. The reference time is selected according to the priority of each candidate clock source to ensure the priority and accuracy of time synchronization. The priority of the clock source can be set according to the actual situation, and a more accurate and stable clock source is used first. After obtaining the reference time, the reference time is corrected according to the current timing format of the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time. This step ensures the accuracy of time synchronization and avoids time deviations caused by mismatched timing formats or different overflow mechanisms. By adapting and correcting the time format, the local clock source can accurately reflect the reference time, enhancing the adaptability of time synchronization. Even between different devices, accurate time synchronization can be achieved, and through time synchronization, it is guaranteed that the vehicle OTA upgrade can be accurately implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions 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 related drawings can be obtained based on these drawings without paying creative work.

[0054] Figure 1 An application environment diagram of a time processing method in an embodiment;

[0055] Figure 2 A schematic diagram of a process of performing OTA upgrade in an embodiment;

[0056] Figure 3 A schematic diagram of a flow chart of a time processing method in one embodiment;

[0057] Figure 4 A schematic diagram of a process for obtaining a target time step in one embodiment;

[0058] Figure 5 is a schematic flow chart of a step of correcting a reference time in one embodiment;

[0059] Figure 6 It is a flowchart of the steps of encrypting the updated local time corresponding to the local clock source in one embodiment;

[0060] Figure 7 is a structural block diagram of a time processing device in an embodiment;

[0061] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0063] Over the Air Technology (OTA) upgrade refers to the technology of automatically downloading upgrade packages through wireless networks and remotely upgrading the vehicle's systems or applications. OTA upgrade not only provides car owners with a more convenient way to upgrade their vehicles, but also brings a smarter and more convenient car experience.

[0064] Among them, time management and data communication protocol are two key links in the OTA upgrade process. At present, the vehicle system or application uses absolute time (such as UNIX timestamp) as the reference timing clock to control the time synchronization and data transmission during the OTA upgrade process.

[0065] Among them, absolute time timing usually refers to the time accumulated continuously in a certain time unit (such as milliseconds, seconds, etc.) starting from a fixed starting point (such as system startup or a specific time point). Take the use of 32-bit integer variables as an example: 32-bit unsigned integer variables can indeed be used to store time values, but their range and precision are limited by the variable type. Specifically, the maximum value of a 32-bit unsigned integer variable is 4,294,967,295. If the time is measured in milliseconds, it can represent a maximum of about 49 days. If the time exceeds this, the variable will overflow, resulting in a timing error.

[0066] During the vehicle OTA upgrade process, if the vehicle system or application cannot correctly handle timestamp overflow (i.e. the timing error mentioned above), they may lose time synchronization with the server or other systems, resulting in confusion or failure during the upgrade process.

[0067] Based on this, the embodiment of the present application provides a time processing method, which can be applied to Figure 1 The application environment shown in FIG. 1 includes an OTA cloud platform, an OTA upgrade master control (Upgrade Master Control, UMC), an OTA upgrade agent (Over-the-Air Update Agent, UA) and an OTA slave control (User Management Component, US).

[0068] Among them, UMC is responsible for the overall control and coordination of the entire OTA upgrade process. It is usually located in the vehicle's car multimedia center (CDC) and uses the computing and storage resources of the CDC to execute the upgrade strategy.

[0069] Among them, UA: as a bridge between UMC and US, it is responsible for transmitting upgrade data and instructions. It can be integrated in the vehicle gateway (Virtual Gateway, VGW) and use the network communication capabilities of VGW to achieve efficient interaction with CDC and Electronic Control Unit (Electronic Control Unit, ECU).

[0070] Among them, US: Located in the ECU component that needs to be upgraded, responsible for receiving upgrade data and performing flash operations. It is connected to VGW through the CAN bus and receives upgrade instructions and data from UMC.

[0071] During the OTA upgrade process, if Figure 2 As shown in the figure, UMC obtains the OTA upgrade package from the remote server or cloud. The upgrade package may contain new ECU firmware, configuration files, etc. UMC stores the upgrade package in the local storage of CDC, or directly forwards it to US through UA; UMC sends the upgrade preparation instruction to US through UA, including the version information, size, checksum, etc. of the upgrade package. After receiving the instruction, US performs operations such as local storage preparation and backing up the current firmware. UMC sends the upgrade package data to US in blocks or as a whole through UA. Data transmission may use reliable communication protocols such as TCP / IP (in Ethernet communication between CDC and VGW) and CAN protocol (in communication between VGW and ECU). After receiving the complete upgrade package data, US performs firmware flashing operation. The flashing process may include steps such as firmware verification, writing to flash memory, and restarting ECU. After completing the flashing, US sends an upgrade confirmation message to UA. UA forwards the confirmation message to UMC, and UMC records the upgrade status and may perform subsequent operations, such as updating upgrade records and sending notifications. In this embodiment, an upgrade management module is provided in the CDC, and the upgrade management module includes a timing management module and a state machine management module; the state machine management module includes a sending management module and a receiving management module.

[0072] In an exemplary embodiment, Figure 3 As shown, this embodiment provides a time processing method, which is applied to Figure 1 The following is an example of the master controller in the CDC:

[0073] S301 : when a time update event for a local clock source corresponding to a master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source.

[0074] It is understandable that the local clock source is mainly used to manage the time management and synchronization inside the main controller. It is usually an oscillator integrated inside the device, such as an RC oscillator or a crystal oscillator, which is located inside the main controller and is the main controller's own clock source.

[0075] Among them, the time update event for the local clock source corresponding to the main controller mainly refers to a series of operations or conditions that affect or change the current time state of the local clock source. Optionally, the local clock source can automatically synchronize with an external high-precision clock source (such as GPS, network time server, etc.) regularly or according to specific conditions (such as time deviation reaches a certain threshold) to calibrate its own time. Users or system administrators can manually set the time of the local clock source through software interfaces, command line tools, etc.

[0076] The candidate clock sources include a system clock source of a target vehicle system carrying a main controller and an external clock source of an external device communicating with the main controller.

[0077] It is understood that the system clock source of the target vehicle system carrying the main controller refers to the clock source used to maintain the internal time synchronization of the target vehicle system. It may be a combination of one or more high-precision clock sources, used to provide a unified time reference for various parts in the system, which may be located in the center of the system or distributed on multiple nodes in the network.

[0078] In addition, the external clock source of the external device communicating with the main controller is a clock signal source introduced from the outside, located outside the device, and connected to the device through a physical connection (such as a wire, an interface, etc.), such as a network clock source.

[0079] S302: Select a reference time from the acquired candidate times according to the priority of each candidate clock source.

[0080] It is understandable that each candidate clock source is configured with a corresponding priority. The clock source priority refers to the priority value assigned to different clock sources. This value is used to guide the selection of the best clock source as the reference clock when there are multiple clock sources. The smaller the priority value, the higher the priority of the clock source. Optionally, the user can manually set the priority of the clock source through the configuration command according to actual needs. When configuring, you need to specify the name of the clock source and the corresponding priority value.

[0081] S303: Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time.

[0082] The timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism.

[0083] In this embodiment, the local timing format of the local clock source may be the above-mentioned timing format based on a 32-bit integer variable.

[0084] It is understandable that if the local clock source uses a 32-bit integer variable for timing, and the reference time uses a 64-bit integer variable, the local clock source timing overflow may occur. This is because the counting range of the 32-bit integer variable is limited. When the count value exceeds its upper limit, an overflow will occur, resulting in the inability to correctly represent a larger time value, which in turn causes the local time of the local clock source to be unable to keep pace with the reference time.

[0085] In this case, the reference time is corrected according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, and the target time can be obtained as follows: after confirming the overflow, the time difference between the reference time and the local time of the local clock source is calculated, and according to the calculated time difference, the local time (local count value) of the local clock source is corrected to make it consistent with the reference time, so that the obtained target time is adapted to the local clock source and can be synchronized with the reference time. That is, the target time must be in a format that the local clock source can recognize and process. For example, if the local clock source uses a 32-bit unsigned integer variable for timing, then the target time must also be a 32-bit unsigned integer.

[0086] S304: Use the target time to update the local time of the local clock source.

[0087] Optionally, updating the local time of the local clock source with the target time means assigning the corrected target time value to the local clock source to synchronize it with the reference time. Further, when updating the local time of the local clock source with the target time, other characteristics of the local clock source, such as timing accuracy and resolution, are also considered.

[0088] In the above time processing method, the present application increases the data source of time synchronization and improves the reliability of time synchronization by obtaining candidate time from multiple candidate clock sources (including clock sources and external clock sources). Even if a clock source fails or has time deviation, accurate time information can still be obtained from other clock sources. The reference time is selected according to the priority of each candidate clock source to ensure the priority and accuracy of time synchronization. The priority of the clock source can be set according to the actual situation, and a more accurate and stable clock source is used first. After obtaining the reference time, the reference time is corrected according to the current timing format of the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time. This step ensures the accuracy of time synchronization and avoids time deviations caused by mismatched timing formats or different overflow mechanisms. By adapting and correcting the time format, the local clock source can accurately reflect the reference time, enhancing the adaptability of time synchronization. Accurate time synchronization can be achieved even between different devices, thereby ensuring that vehicle OTA upgrades can be accurately implemented.

[0089] In an exemplary embodiment, detecting a time update event for a local clock source corresponding to the master controller includes at least one of the following:

[0090] (1) Receive an OTA upgrade task for the target electronic control unit ECU using the space download technology.

[0091] Among them, the target ECU is the ECU managed by the main controller.

[0092] It is understandable that when the main controller receives an OTA upgrade task for a certain ECU it manages, it needs to trigger a time update event in order to ensure time synchronization and accuracy during the upgrade process. This is because OTA upgrades usually involve software version updates, and the timestamp of the software version and time control during the upgrade process are crucial to ensure the success and security of the upgrade.

[0093] (2) A time update instruction for a local clock source corresponding to the main controller is received.

[0094] Optionally, the master controller may receive explicit time update instructions from the upper system, other controllers, or user interfaces. These instructions may originate from system maintenance, time calibration, or adjustment of time synchronization strategies. Upon receiving such instructions, the master controller triggers a time update event to update the time of the local clock source according to the instructions.

[0095] (3) A timing overflow is detected in the local clock source.

[0096] Optionally, the local clock source may overflow due to limited counting range, causing the time count to wrap around or reset. When the host controller detects this overflow, in order to maintain the continuity and accuracy of the time, a time update event needs to be triggered. This usually involves handling the overflow, such as increasing the counting period, resetting the counter, or taking other corrective measures.

[0097] In an exemplary embodiment, the system clock source includes an interface time source of an operating system corresponding to the target vehicle system and / or a device clock source of a hardware device deployed by the target vehicle system; the external device includes a cloud platform and / or a vehicle gateway device in the target vehicle.

[0098] It is understood that the operating system interface time source is a time interface provided by the operating system corresponding to the target vehicle system, which is usually used to obtain the current time of the system. The operating system time interface is usually based on the system clock, which is maintained by the operating system and may be synchronized with an external time source through a network time protocol (such as Network Time Protocol, NTP).

[0099] Device clock source of hardware devices: The target vehicle system may deploy various hardware devices, which may have their own clock source to provide time information. For example, some sensors or controllers may have built-in real-time clock (RTC) modules to record and provide timestamps.

[0100] Furthermore, external devices are other devices located outside the target vehicle system or inside the vehicle that communicate with the main controller and may provide time information as candidate time sources. These external devices may include:

[0101] OTA cloud platform: OTA cloud platforms usually provide accurate time services because they are based on network-based time synchronization protocols (such as NTP or PTP) for time synchronization. The main controller can obtain accurate time information by communicating with the OTA cloud platform.

[0102] Vehicle gateway device: The vehicle gateway is a bridge between the vehicle's internal network and the external network. It may integrate a time synchronization function to ensure time consistency between various devices inside the vehicle. The main controller can obtain time information from the vehicle gateway device as a candidate time source.

[0103] In this embodiment, the priority of the cloud platform is higher than the priority of the operating system, the priority of the operating system is higher than the priority of the vehicle gateway, and the priority of the vehicle gateway is higher than the priority of the hardware devices deployed by the target vehicle system.

[0104] In this embodiment, by including the cloud platform and the vehicle gateway device in the category of external devices and as candidate clock sources, the information source of time synchronization can be further enriched, and the flexibility and adaptability of time synchronization can be improved. In particular, when the vehicle communicates or exchanges data with an external network, ensuring the consistency of time is crucial to ensuring the security and accuracy of data.

[0105] In an exemplary embodiment, Figure 4 As shown, according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, the reference time is corrected to obtain the target time, including:

[0106] S401, when the current timing format corresponding to the reference time is inconsistent with the local timing format of the local clock source, the reference time is format converted according to the format conversion relationship between the current timing format and the local timing format to obtain an alternative time in the local timing format.

[0107] Optionally, when the current timing format corresponding to the reference time is inconsistent with the local timing format of the local clock source, format conversion is required first. This is because different timing formats may use different time representation methods, counting ranges or resolutions, and direct comparison or application may lead to errors. In order to convert the reference time to the local timing format, it is necessary to clarify the conversion relationship between the current timing format and the local timing format. This may involve time unit conversion, counting range adjustment, timestamp format transformation, etc. By applying the format conversion relationship, the reference time is converted to a time representation in the local timing format to obtain an alternative time. The alternative time is an equivalent representation of the reference time in the local timing format.

[0108] S402, using the timing overflow mechanism of the local clock source to correct the candidate time to obtain the target time.

[0109] It is understandable that since the local clock source may have a timing overflow phenomenon, that is, the count wraps around or resets after reaching a certain limit value, the alternative time needs to be corrected for overflow. Understanding the timing overflow mechanism of the local clock source is the key to correcting the alternative time. This includes the conditions of the overflow, how the overflow is handled (such as wrapping, resetting, etc.), and the counting behavior after the overflow. According to the timing overflow mechanism, the alternative time is adjusted as necessary to ensure that it is valid within the counting range of the local clock source and takes into account the impact of the overflow. This may involve increasing the counting period, adjusting the starting point of the timestamp, or applying a specific correction algorithm. After the overflow correction, the target time obtained is a time representation that is consistent with the reference time and valid on the local clock source.

[0110] In one implementable manner, the timing overflow mechanism of the local clock source is used to correct the alternative time to obtain the target time, including: if the alternative time exceeds the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source, then the overflow upper limit time is subtracted from the alternative time to obtain the target time.

[0111] Optionally, first clarify the timing overflow mechanism of the local clock source. Timing overflow usually occurs when the value of the counter reaches a preset upper limit, and the counter will wrap around to the starting value or reset to a certain initial state. This upper limit value is the overflow upper limit time. When the alternative time exceeds the overflow upper limit time, it means that if the time is directly applied to the local clock source, it may cause discontinuity or error in time counting. Therefore, correction is required. According to the timing overflow mechanism of the local clock source, if the alternative time exceeds the overflow upper limit time, the overflow upper limit time can be subtracted from the alternative time. The purpose of this is to "wrap around" the alternative time to a range that the counter can correctly represent. After the above correction, the time obtained is the target time. The target time is a time representation that is within the counting range of the local clock source and is consistent with the reference time (taking into account the overflow effect).

[0112] Exemplarily, the absolute value of the reference time is compared with the largest 32-bit unsigned integer (2 to the power of 32: 4,294,967,296). If it is greater (note that greater than 4,294,967,296 indicates overflow), then Y-4,294,967,296 is calculated until the absolute value of the reference time is less than 4,294,967296.

[0113] In another possible implementation, the timing overflow mechanism of the local clock source is used to correct the alternative time to obtain the target time, including: if the alternative time is less than the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source, and is greater than the update duration required for the time update event, then the reference time is used as the target time.

[0114] Among them, the update duration required for the time update event is the difference between the overflow upper limit time and the overflow lower limit time corresponding to the timing overflow mechanism; for example, the overflow lower limit time corresponding to the timing overflow mechanism is 7 days; the update duration required for the time update event is the overflow upper limit time (49 days) - the overflow lower limit time (7 days), which represents the maximum time length that can be processed without overflow.

[0115] Exemplarily, if the absolute value of the reference time is less than 4,294,967,296, it is also necessary to determine whether the absolute value of the reference time is greater than the update duration required for the time update event, and the update duration required for the time update event = 4,294,967,296-604,800,000 = 3,690,167;

[0116] The value 604,800,000 is the absolute value of the 7-day operation time, that is, 7*24*60*60*1000=604,800,000 milliseconds, which means that OTA can continuously upgrade and flash for 7 days without timeout or overflow. Generally speaking, OTA upgrade and flash will not exceed 4 hours, so this reserved value is enough to meet system requirements.

[0117] In the above example, the upper limit of overflow time is set to 49 days, and the lower limit of overflow time is set to 7 days. Therefore, the update time required for the time update event is 49 days minus 7 days, which is 42 days. This means that within the 42-day time range, the system can process any time update event without overflow.

[0118] If the candidate time is between the overflow lower limit time and the overflow upper limit time (i.e., between 7 days and 49 days) and does not exceed any other timing restrictions or constraints, then we can directly use the candidate time (after necessary format conversion) as the target time. If the candidate time exceeds the overflow upper limit time or is lower than the overflow lower limit time, then other correction logic is required to ensure that the target time is within the valid counting range.

[0119] In an exemplary embodiment, the reference time includes an integer time portion and a fractional time portion; Figure 5 As shown, according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, the reference time is corrected to obtain the target time, including:

[0120] S501, correcting the integer part of the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time.

[0121] Optionally, specify the current timing format corresponding to the reference time and the local timing format of the local clock source. The two formats may be different, for example, the reference time may be in milliseconds, while the local clock source may be in seconds or larger time units.

[0122] Further, in combination with the above S401 to S402, according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, the integer part of the reference time is corrected to obtain the target time, including:

[0123] According to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source, the integer part of the reference time is corrected to obtain the alternative time; the timing overflow mechanism of the local clock source is used to correct the alternative time to obtain the target time.

[0124] S502, using the target time to update the local time of the local clock source, including: taking the sum of the target time and the decimal time part as the updated local time of the local clock source.

[0125] Specifically, according to the integer part of the reference time and the timing format of the local clock source, the integer part of the reference time is converted into a format that the local clock source can recognize. If the integer part of the reference time exceeds the overflow upper limit or falls below the overflow lower limit of the local clock source, appropriate correction logic needs to be applied. This may include subtracting or adding a fixed value to ensure that the result is within the valid count range of the local clock source.

[0126] Exemplarily, the integer time portion of the reference time is converted to obtain the target time and recorded as the value Y, and the decimal time portion of the reference time is converted to delta milliseconds with an accuracy of 1 millisecond. Y=Y+delta is used as the updated local time of the local clock source.

[0127] In an exemplary embodiment, Figure 6 As shown, the method also includes:

[0128] S601, when a time update request initiated from a controller is obtained, encrypt the updated local time corresponding to the local clock source to obtain the encrypted time.

[0129] Among them, the slave controller can be the above-mentioned vehicle gateway or ECU.

[0130] Specifically, a time update request initiated by a slave controller is received. This means that the slave controller needs to update its local time to keep the time synchronized with the master controller or other components. After receiving the time update request, the updated local time corresponding to the local clock source is encrypted. The purpose of encryption is to protect the authenticity and integrity of the time and prevent illegal intruders from tampering with or forging time information. The encryption process may involve the use of specific encryption algorithms and keys. The security of the key is critical and must be properly kept to prevent it from being leaked to illegal intruders. After encryption, the encrypted time information, i.e., the encrypted time, is obtained. This encrypted time will be used for subsequent communication and time update processes.

[0131] S602: Send the encryption time to the slave controller, so that the slave controller updates the local time of the slave controller according to the encryption time.

[0132] Specifically, the encrypted time is sent to the slave controller. This is usually achieved through network communication or bus communication, depending on the architecture and communication protocol. After receiving the encrypted time, the slave controller decrypts the encrypted time using the corresponding decryption algorithm and key. The decrypted time is the updated local time. The slave controller updates its local time based on the decrypted time to ensure time synchronization with the master controller or other components.

[0133] During the decryption process, the slave controller will check whether the reference time in the upgrade package is consistent with the actual reference time read or whether it is within the allowable error range. If the difference between the two is large (such as 1,438,100 milliseconds in the above example, which is far more than 2 seconds), it is judged as an illegal upgrade request and the OTA upgrade fails. When the slave controller detects that the reference time does not match, it triggers the receive timeout mechanism, that is, the upgrade package is not processed, and a warning message may be sent to the user or remote server. This timeout processing mechanism can effectively prevent illegal intruders from bypassing security verification by forging the reference time.

[0134] It is understandable that since the reference time is dynamically changing and closely related to time, an illegal intruder cannot simply replay the previously captured legitimate upgrade package to pass the verification. The upgrade package contains sensitive information such as the reference time during the encryption process. Any tampering with the upgrade package will cause decryption failure, thereby preventing illegal upgrades.

[0135] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0136] Based on the same inventive concept, the embodiment of the present application also provides a time processing device for implementing the time processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more time processing device embodiments provided below can refer to the limitations on the time processing method above, and will not be repeated here.

[0137] In an exemplary embodiment, Figure 7As shown, a time processing device is provided, comprising: a multi-source time acquisition module 11, a multi-source time selection module 12, a time correction module 13 and a time update module 14; wherein:

[0138] The multi-source time acquisition module 11 is used to acquire the corresponding candidate time from each candidate clock source other than the local clock source when a time update event for the local clock source corresponding to the main controller is detected; wherein each candidate clock source includes a clock source of a target vehicle system carrying the main controller and an external clock source of an external device communicating with the main controller;

[0139] A multi-source time selection module 12, configured to select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0140] The time correction module 13 is used to correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0141] The time updating module 14 is used to update the local time of the local clock source using the target time.

[0142] In one of the embodiments, detecting a time update event for a local clock source corresponding to the master controller includes at least one of the following:

[0143] A space download technology OTA upgrade task for a target electronic control unit ECU is received; wherein the target ECU is an ECU managed by a main controller;

[0144] Receiving a time update instruction for a local clock source corresponding to the master controller;

[0145] A timing overflow was detected in the local clock source.

[0146] In one of the embodiments, the clock source includes an interface time source of an operation corresponding to the target vehicle system and / or a device clock source of a hardware device deployed by the target vehicle system;

[0147] The external device includes a cloud platform and / or a vehicle gateway device in the target vehicle. In one embodiment,

[0148] In one embodiment, the time correction module 13 is used to: when the current timing format corresponding to the reference time is inconsistent with the local timing format of the local clock source, convert the reference time according to the format conversion relationship between the current timing format and the local timing format to obtain an alternative time in the local timing format;

[0149] The timing overflow mechanism of the local clock source is used to correct the alternative time and obtain the target time.

[0150] In one embodiment, the time correction module 13 is used to: if the candidate time exceeds the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source, subtract the overflow upper limit time from the candidate time to obtain the target time.

[0151] In one embodiment, the time correction module 13 is used to: if the candidate time is less than the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source and is greater than the update duration required by the time update event, use the reference time as the target time.

[0152] In one embodiment, the time updating module 14 is used to: correct the integer part of the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time;

[0153] Use the target time to update the local time of the local clock source, including:

[0154] The sum of the target time and the fractional time portion is used as the updated local time of the local clock source.

[0155] In one of the embodiments, the device further includes an encryption module, which is used to: upon obtaining a time update request initiated from the controller, encrypt the updated local time corresponding to the local clock source to obtain the encrypted time;

[0156] The encrypted time is sent to the slave controller, so that the slave controller updates the local time of the slave controller according to the encrypted time.

[0157] Each module in the above-mentioned time processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0158] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a bus, and the communication interface is connected to the bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores operations, computer programs and databases. The internal memory provides an environment for the operation of the operations and computer programs in the non-volatile storage medium. The database of the computer device is used to store data of the time processing method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a time processing method is implemented.

[0159] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0160] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0161] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0162] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0163] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0164] The local time of the local clock source is updated using the target time.

[0165] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0166] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0167] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0168] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0169] The local time of the local clock source is updated using the target time.

[0170] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:

[0171] When a time update event for a local clock source corresponding to the master controller is detected, a corresponding candidate time is obtained from each candidate clock source other than the local clock source; wherein each candidate clock source includes a clock source of a target vehicle system carrying the master controller and an external clock source of an external device communicating with the master controller;

[0172] Select a reference time from the obtained candidate times according to the priority of each candidate clock source;

[0173] Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism;

[0174] The local time of the local clock source is updated using the target time.

[0175] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0176] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0177] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A time processing method, characterized in that: Applied to a main controller in a vehicle, the method comprises: When a time update event for a local clock source corresponding to the master controller is detected, obtaining corresponding candidate times from candidate clock sources other than the local clock source; Select a reference time from the obtained candidate times according to the priority of each candidate clock source; Correct the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within the time range corresponding to the timing overflow mechanism; The local time of the local clock source is updated using the target time.

2. The method according to claim 1, characterized in that The detecting of a time update event for a local clock source corresponding to the master controller includes at least one of the following: Receiving a space download technology OTA upgrade task for a target electronic control unit ECU; wherein the target ECU is an ECU managed by the main controller; Receiving a time update instruction for a local clock source corresponding to the master controller; A timing overflow phenomenon is detected in the local clock source.

3. The method according to claim 1, characterized in that The candidate clock sources include a system clock source of a target vehicle system carrying the master controller and an external clock source of an external device in communication with the master controller; The system clock source includes an interface time source of an operating system corresponding to the target vehicle system and / or a device clock source of a hardware device deployed by the target vehicle system; The external device includes a cloud platform and / or a vehicle gateway device in the target vehicle.

4. The method according to claim 1, characterized in that: The correcting the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time includes: When the current timing format corresponding to the reference time is inconsistent with the local timing format of the local clock source, the reference time is format converted according to the format conversion relationship between the current timing format and the local timing format to obtain an alternative time under the local timing format; The timing overflow mechanism of the local clock source is used to correct the candidate time to obtain the target time.

5. The method according to claim 4, characterized in that The adopting the timing overflow mechanism of the local clock source to correct the candidate time to obtain the target time includes: If the candidate time exceeds the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source, the overflow upper limit time is subtracted from the candidate time to obtain the target time.

6. The method according to claim 5, characterized in that The adopting the timing overflow mechanism of the local clock source to correct the candidate time to obtain the target time includes: If the candidate time is less than the overflow upper limit time corresponding to the timing overflow mechanism of the local clock source and is greater than the update duration required for the time update event, the reference time is used as the target time.

7. The method according to claim 1, characterized in that The reference time includes an integer time part and a decimal time part; the correction of the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time includes: Correcting the integer part of the reference time according to the current timing format corresponding to the reference time, the local timing format of the local clock source, and the timing overflow mechanism of the local clock source to obtain the target time; The adopting the target time to update the local time of the local clock source includes: The sum of the target time and the fractional time portion is used as the updated local time of the local clock source.

8. The method according to claim 1, characterized in that The method further comprises: When a time update request initiated from the controller is obtained, encrypting the updated local time corresponding to the local clock source to obtain encrypted time; The encrypted time is sent to the slave controller, so that the slave controller updates the local time of the slave controller according to the encrypted time.

9. A time processing device, characterized in that: A main controller configured in a vehicle, the device comprising: A multi-source time acquisition module, configured to, when a time update event for a local clock source corresponding to the main controller is detected, acquire corresponding candidate times from candidate clock sources other than the local clock source; A multi-source time selection module is used to select a reference time from the obtained candidate times according to the priority of each candidate clock source; A time correction module, configured to correct the reference time according to a current timing format corresponding to the reference time, a local timing format of the local clock source, and a timing overflow mechanism of the local clock source, to obtain a target time; wherein the timing format of the target time is consistent with the local timing format, and the time value of the target time is within a time range corresponding to the timing overflow mechanism; The time updating module is used to update the local time of the local clock source using the target time.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • IEEE 1588-based synchronization system and synchronization method thereof

    CN102104475A

  • Method and device for improving synchronization precision among multiple clocks

    CN111614428A

  • Synchronization time determination method, time synchronization device, time synchronization system and medium

    CN117675072A

  • Time correction device and method and intelligent vehicle

    CN117978317A

  • Clock synchronization method and apparatus, computer device, and storage medium

    WO2021136149A1