Clock detection method and device, equipment, storage medium and program product
By obtaining and analyzing the time points and clock deviations of time synchronization messages in the vehicle time synchronization system, and detecting clock failures of terminal nodes, upstream nodes and master clock nodes, the problem of locating clock synchronization anomalies in the gPTP clock synchronization system is solved and improved Improves troubleshooting efficiency and system reliability.
Patent Information
- Application Number
- CN202410901909.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-09-10
AI Technical Summary
In a vehicle time synchronization system based on generalized clock synchronization protocol (gPTP) for clock synchronization, the cause of abnormal clock synchronization cannot be effectively located, making troubleshooting difficult.
By obtaining the time points at which the terminal node, upstream node and main clock node send and receive time synchronization messages at different time points, the clock deviation and time difference are calculated to determine whether a clock failure occurs on the target node and detect the clock failure node.
Effectively locating and detecting nodes that cause clock synchronization abnormalities solves the problem in the existing technology of being unable to accurately locate the cause of the fault, and improves the reliability and troubleshooting efficiency of the clock synchronization system in the vehicle.
Smart Images

Figure CN118631379A
Abstract
Description
Technical Field
[0001] The present application relates to the field of automobile technology, and in particular to a clock detection method, device, equipment, storage medium and program product. Background Art
[0002] With the development of intelligent driving, all sensors in the vehicle need to collect data based on a unified clock to obtain more accurate fusion data. Currently, most of the nodes (including transit nodes (such as switches) and terminal nodes) included in a certain time synchronization system in the vehicle are based on the generalized precision time protocol (gPTP) for clock synchronization.
[0003] However, in the above method, when the clocks of various nodes of a time synchronization system are actually synchronized based on gPTP, if a node fails, the time synchronization system will experience clock synchronization anomalies. Therefore, how to locate the cause of the clock synchronization anomaly becomes an urgent problem to be solved. Summary of the invention
[0004] The present application provides a clock detection method, device, equipment, storage medium and program product to at least solve the problem of how to locate the cause of clock synchronization abnormality when performing clock synchronization of each node in a time synchronization system based on gPTP in the related art. The technical solution of the present application is as follows:
[0005] According to a first aspect of the present application, a clock detection method is provided, comprising: obtaining a first time point and a second time point; the first time point and the second time point include: at least one of the time points at which the upstream node of the terminal node sends a time synchronization message to the terminal node at two different time points, the time points at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the time points at which the master clock node sends time information at two different time points; the time synchronization message is used to synchronize the clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node for synchronizing the clocks of the terminal node and the upstream node; based on the first time point and the second time point, determining whether a clock failure occurs in the target node; the target node includes: at least one of the upstream node, the terminal node, and the master clock node.
[0006] According to the above technical means, the present application can determine the nodes with clock failures in the terminal nodes, upstream nodes and master clock nodes based on the time points when the upstream node of the terminal node sends time synchronization messages to the terminal node at two different time points, the time points when the terminal node receives the time synchronization messages sent by the upstream node to the terminal node at two different time points, and the time points when the master clock node sends time information at two different time points. That is, if a clock failure occurs in a node and the clock jumps, the time point when the node sends information will change abnormally. Therefore, it is possible to determine whether the node has a clock failure based on the time point when the node sends information. It solves the problem in the prior art that when the clocks of various nodes of a time synchronization system are synchronized based on gPTP, the cause of the clock synchronization abnormality cannot be located. Thus, the node with clock failure is detected to locate the cause of the clock synchronization abnormality.
[0007] In one possible implementation, determining whether a clock failure occurs at a target node is based on a first time point and a second time point, including: determining whether a clock failure occurs at an upstream node based on the first time point and the second time point when the first time point and the second time point are time points at which an upstream node sends a time synchronization message to a terminal node at two different time points, and a clock deviation between the terminal node and a master clock node is greater than a first threshold.
[0008] According to the above technical means, the present application can determine whether the clock failure occurs in the upstream node. That is, if the clock deviation between the terminal node and the main clock node is large, it means that the clock failure occurs in the upstream node or the terminal node. If the clock failure occurs in the upstream node and the clock jump occurs, the time point at which the upstream node sends the message will change abnormally. Therefore, it is possible to determine whether the upstream node is faulty based on the time point at which the upstream node sends the message. Thus, it is possible to detect whether the clock failure occurs in the upstream node.
[0009] In one possible implementation, based on a first time point and a second time point, determining whether a clock failure occurs at an upstream node includes: determining the difference between the second time point and the first time point as a first time difference; and determining that a clock failure occurs at the upstream node when the first time difference is greater than a second threshold, and the second threshold is greater than the time interval for the upstream node to send a time synchronization message to the terminal node.
[0010] According to the above technical means, the present application can determine that a clock failure occurs in the upstream node when the difference between the second time point and the first time point is greater than the second threshold. That is, when the clock failure does not occur in the upstream node, the difference is equal to the time interval for the upstream node to send a time synchronization message to the terminal node. If the difference is greater than the time interval, it means that a clock failure occurs in the upstream node. Thus, the detection of a clock failure in the upstream node is achieved.
[0011] In one possible implementation, determining whether a clock failure occurs at a target node is based on a first time point and a second time point, including: determining whether a clock failure occurs at a terminal node based on the first time point and the second time point when the first time point and the second time point are time points at which the terminal node receives a time synchronization message sent by an upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0012] According to the above technical means, the present application can determine whether a terminal node has a clock failure. That is, if the clock deviation between the terminal node and the master clock node is large, it means that a clock failure has occurred in the upstream node or the terminal node. If a clock failure occurs in the terminal node and a clock jump occurs, the time point at which the terminal node receives the message will change abnormally. Therefore, it is possible to determine whether the terminal node has a fault based on the time point at which the terminal node receives the message. Thus, it is possible to detect whether a clock failure has occurred in the terminal node.
[0013] In one possible implementation, based on a first time point and a second time point, determining whether a clock failure occurs at a terminal node includes: determining the difference between the second time point and the first time point as a second time difference; and determining that a clock failure occurs at the terminal node when the second time difference is greater than a third threshold, the third threshold being greater than the time interval for the terminal node to receive a time synchronization message sent by an upstream node to the terminal node.
[0014] According to the above technical means, the present application can determine that a clock failure occurs in the terminal node when the difference between the second time point and the first time point is greater than the third threshold. That is, when the terminal node does not have a clock failure, the difference is equal to the time interval for the terminal node to receive the time synchronization message. If the difference is greater than the time interval, it means that a clock failure occurs in the terminal node. Thus, the detection of a clock failure in the terminal node is achieved.
[0015] In one possible implementation, based on a first time point and a second time point, determining whether a clock failure occurs at a target node includes: when the first time point and the second time point are time points at which a master clock node sends time information at two different time points, determining the difference between the second time point and the first time point as a third time difference; and when the third time difference is greater than a fourth threshold, determining that a clock failure occurs at the master clock node, and the fourth threshold is greater than the time interval for the master clock node to send time information.
[0016] According to the above technical means, the present application can determine whether a clock failure occurs in the master clock node. That is, if a clock failure occurs in the master clock node and a clock jump occurs, the time point at which the master clock node sends information will change abnormally, and when the master clock node does not have a clock failure, the difference between the second time point and the first time point is equal to the time interval for the master clock to send time information. If the difference is greater than the time interval, it means that a clock failure occurs in the master clock node. Thus, it is possible to detect whether a clock failure occurs in an upstream node.
[0017] According to the second aspect provided by the present application, a clock detection device is provided, including a transmission module and a determination module; the transmission module is used to obtain a first time point and a second time point; the first time point and the second time point include: a time point when the upstream node of the terminal node sends a time synchronization message to the terminal node at two different time points, a time point when the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and at least one of the time points when the master clock node sends time information at two different time points; the time synchronization message is used to synchronize the clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node for synchronizing the clocks of the terminal node and the upstream node; the determination module is used to determine whether a clock failure occurs in the target node based on the first time point and the second time point; the target node includes: at least one of the upstream node, the terminal node, and the master clock node.
[0018] In one possible implementation, the determination module is also used to determine whether a clock failure occurs in the upstream node based on the first time point and the second time point, when the first time point and the second time point are the time points when the upstream node sends a time synchronization message to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0019] In one possible implementation, the determination module is also used to determine the difference between the second time point and the first time point as the first time difference; the determination module is also used to determine that a clock failure has occurred in the upstream node when the first time difference is greater than a second threshold, and the second threshold is greater than the time interval for the upstream node to send a time synchronization message to the terminal node.
[0020] In one possible implementation, the determination module is also used to determine whether a clock failure occurs at the terminal node based on the first time point and the second time point, when the first time point and the second time point are time points at which the terminal node receives a time synchronization message sent by an upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0021] In one possible implementation, the determination module is also used to determine the difference between the second time point and the first time point as the second time difference; the determination module is also used to determine that a clock failure has occurred in the terminal node when the second time difference is greater than a third threshold, and the third threshold is greater than the time interval for the terminal node to receive a time synchronization message sent by the upstream node to the terminal node.
[0022] In a possible implementation, the determination module is also used to determine the difference between the second time point and the first time point as a third time difference when the first time point and the second time point are the time points when the master clock node sends time information at two different time points; the determination module is also used to determine that a clock failure has occurred in the master clock node when the third time difference is greater than a fourth threshold, and the fourth threshold is greater than the time interval for the master clock node to send time information.
[0023] According to the third aspect provided by the present application, an electronic device is provided, comprising: a processor; a memory for storing processor executable instructions; wherein the processor is configured to execute instructions to implement the method of the above-mentioned first aspect and any possible implementation manner thereof.
[0024] According to the fourth aspect provided by the present application, a computer-readable storage medium is provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method in the above-mentioned first aspect and any possible implementation method thereof.
[0025] According to the fifth aspect provided by the present application, a computer program product is provided, the computer program product comprising computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method of the above-mentioned first aspect and any possible implementation manner thereof.
[0026] Therefore, the above technical features of the present application have the following beneficial effects:
[0027] (1) The present application can determine the nodes with clock failures in the terminal nodes, upstream nodes and master clock nodes based on the time points when the upstream node of the terminal node sends time synchronization messages to the terminal node at two different time points, the time points when the terminal node receives the time synchronization messages sent by the upstream node to the terminal node at two different time points, and the time points when the master clock node sends time information at two different time points. That is, if a clock failure occurs in a node and a clock jump occurs, the time point when the node sends information will change abnormally. Therefore, it is possible to determine whether a clock failure occurs in the node based on the time point when the node sends information. This solves the problem in the prior art that when the clocks of various nodes of a time synchronization system are synchronized based on gPTP, the cause of the clock synchronization abnormality cannot be located. Thus, the node with clock failure is detected to locate the cause of the clock synchronization abnormality.
[0028] (2) The present application can determine whether a clock failure occurs in an upstream node. That is, if the clock deviation between the terminal node and the master clock node is large, it indicates that a clock failure occurs in the upstream node or the terminal node. If a clock failure occurs in the upstream node and a clock jump occurs, the time point at which the upstream node sends a message will change abnormally. Therefore, it is possible to determine whether the upstream node is faulty based on the time point at which the upstream node sends a message. Thus, it is possible to detect whether a clock failure occurs in an upstream node.
[0029] (3) The present application can determine that a clock failure occurs in the upstream node when the difference between the second time point and the first time point is greater than a second threshold. That is, when the clock failure does not occur in the upstream node, the difference is equal to the time interval for the upstream node to send a time synchronization message to the terminal node. If the difference is greater than the time interval, it means that a clock failure occurs in the upstream node. Thus, the detection of a clock failure in the upstream node is achieved.
[0030] (4) The present application can determine whether a terminal node has a clock failure. That is, if the clock deviation between the terminal node and the master clock node is large, it means that a clock failure has occurred in the upstream node or the terminal node. If a clock failure occurs in the terminal node and a clock jump occurs, the time point at which the terminal node receives the message will change abnormally. Therefore, it is possible to determine whether the terminal node has a fault based on the time point at which the terminal node receives the message. Thus, it is possible to detect whether a terminal node has a clock failure.
[0031] (5) The present application can determine that a clock failure occurs in the terminal node when the difference between the second time point and the first time point is greater than a third threshold. That is, when the terminal node does not have a clock failure, the difference is equal to the time interval for the terminal node to receive the time synchronization message. If the difference is greater than the time interval, it means that a clock failure occurs in the terminal node. Thus, detection of a clock failure in the terminal node is achieved.
[0032] (6) The present application can determine whether a clock failure occurs in the master clock node. That is, if a clock failure occurs in the master clock node and a clock jump occurs, the time point at which the master clock node sends information will change abnormally, and when the master clock node does not have a clock failure, the difference between the second time point and the first time point is equal to the time interval for the master clock to send time information. If the difference is greater than the time interval, it means that a clock failure occurs in the master clock node. Thus, it is possible to detect whether a clock failure occurs in an upstream node.
[0033] It should be noted that the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here.
[0034] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0036] Figure 1 is a structural schematic diagram of a clock detection system according to an exemplary embodiment;
[0037] Figure 2 is a flow chart showing a clock detection method according to an exemplary embodiment;
[0038] Figure 3 is a flow chart showing another clock detection method according to an exemplary embodiment;
[0039] Figure 4 is a flow chart showing another clock detection method according to an exemplary embodiment;
[0040] Figure 5 is a flow chart showing another clock detection method according to an exemplary embodiment;
[0041] Figure 6 is a flow chart showing a method of detecting a node clock failure according to an exemplary embodiment;
[0042] Figure 7 is a block diagram of a clock detection device according to an exemplary embodiment;
[0043] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0044] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0045] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0046] At present, most of the nodes in a certain time synchronization system in a vehicle are based on gPTP for clock synchronization, and each node needs to support gPTP. However, when applied to the whole vehicle, time synchronization anomalies often occur in each node, but the system cannot determine the abnormal node (the node with the fault), making it difficult to troubleshoot the cause of the fault, further affecting the relevant functions of the vehicle.
[0047] In response to the problem that the cause of time synchronization failure cannot be accurately located in the vehicle field, the present application provides a clock detection method, in which each node in the time synchronization system reports the time information to the detection node, and then the detection node judges the time information reported by each node to determine the node where the failure occurs.
[0048] For ease of understanding, the clock detection method provided in the present application is specifically introduced below with reference to the accompanying drawings.
[0049] A clock detection method provided in an embodiment of the present application can be applicable to a clock detection system. Figure 1 FIG. 1 is a schematic diagram showing a structure of a clock detection system according to an exemplary embodiment. Figure 1 As shown, the clock detection system 10 includes: an electronic device 11 and a time synchronization system 12. The time synchronization system 12 specifically includes: a master clock node 121, an upstream node 122 and a terminal node 123. The electronic device 11 includes a detection module.
[0050] The detection module of the electronic device 11 is used to obtain the time points when the upstream node 122 of the terminal node 123 sends time synchronization messages to the terminal node 123 at two different time points, the time points when the terminal node 123 receives the time synchronization messages sent by the upstream node 122 to the terminal node 123 at two different time points, and the time points when the master clock node 121 sends time information at two different time points, and determine whether a clock failure occurs in the target node based on the first time point and the second time point.
[0051] The master clock node 121 is used to send first time information (i.e., the time information in this application) to the electronic device 11; the terminal node 123 is used to send second time information to the electronic device 11, including the time points at which the upstream node 122 of the terminal node 123 sends time synchronization messages to the terminal node 123 at two different time points and the time points at which the terminal node 123 receives the time synchronization messages sent by the upstream node 122 to the terminal node 123 at two different time points.
[0052] It should be noted that the electronic device 11 can be any node with a log recording function among the master clock node 121, the upstream node 122 and the terminal node 123. The upstream node 122 is a transit node (such as a switch (i.e., a switch node)), and the switch node only has the function of forwarding data and cannot report its own time information to the electronic device 11 through the link protocol.
[0053] Figure 2 is a flowchart of a clock detection method according to an exemplary embodiment, which is applied to electronic devices such as Figure 2 As shown, the clock detection method includes the following steps:
[0054] S201. Obtain a first time point and a second time point.
[0055] Among them, the first time point and the second time point include: at least one of the time points at which the upstream node of the terminal node sends a time synchronization message to the terminal node at two different time points, the time point at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the time point at which the master clock node sends time information at two different time points; the time synchronization message is used to synchronize the clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node that synchronizes the clocks of the terminal node and the upstream node.
[0056] Optionally, the time synchronization message sent by the upstream node of the terminal node to the terminal node may include an original timestamp, which is the precise Origin Time stamp (i.e., the timestamp of the master clock node) field and the correction Field (i.e., the delay of all upstream nodes before the terminal node except the master clock node) field specified by the Precision Time Protocol (PTP) standard. The timestamp of the master clock node includes the time point when the master clock node sends the time synchronization message. The original timestamp includes the time point when the upstream node of the terminal node sends the time synchronization message to the terminal node.
[0057] Optionally, when a time synchronization system (the time synchronization system includes a master clock node, an upstream node, and a terminal node) performs time synchronization, the master clock node may send a time synchronization message to a downstream node of the master clock node at intervals of a first preset duration (i.e., a time interval for an upstream node to send a time synchronization message to a terminal node and a time interval for a terminal node to receive a time synchronization message sent by an upstream node to the terminal node), and the downstream node of the master clock node may be an upstream node of the terminal node. Furthermore, the upstream node of the master clock node may perform time synchronization with the master clock node based on the time synchronization message, and send a time synchronization message to the terminal node at intervals of a first preset duration.
[0058] Furthermore, the terminal node can perform time synchronization with the upstream node of the terminal node based on the time synchronization message, and record the timestamp of the terminal node, and based on the original timestamp included in the time synchronization message, calculate the clock deviation (also called clock error) between the terminal node and the master clock node through the calculation method of the offset From Master (i.e., the clock error between any node and the master clock node) parameter in the PTP standard, so as to achieve the consistency of the clocks of the nodes other than the master clock node in the time synchronization system with the master clock node. The timestamp of the terminal node includes the time point when the terminal node receives the time synchronization message sent by the upstream node to the terminal node.
[0059] Further, the terminal node can obtain second time information, which includes an original timestamp, a clock deviation between the terminal node and the master clock node, and a timestamp of the terminal node. Further, the terminal node can send the second time information to the electronic device at intervals of a first preset time length.
[0060] Optionally, the master clock node can send time information (ie, first time information) to the electronic device at every second preset time interval, the first time information includes a master clock timestamp, and the master clock timestamp includes the time point when the master clock node sends the time information to the electronic device.
[0061] Optionally, the electronic device may receive the second time information sent by the terminal node at intervals of a first preset time length. The electronic device may receive the first time information sent by the master clock node at intervals of a second preset time length.
[0062] It should be noted that the first preset duration and the second preset duration can be set according to application scenarios.
[0063] S202: Determine whether a clock failure occurs at the target node based on the first time point and the second time point.
[0064] The target node includes at least one of an upstream node, a terminal node, and a master clock node.
[0065] Optionally, the detection module of the electronic device can determine whether a clock failure occurs in the master clock node based on the first time information sent by the master clock node received in two adjacent cycles. The detection module of the electronic device can determine whether a clock failure occurs in the terminal node or the upstream node based on the second time information sent by the terminal node received in two adjacent cycles.
[0066] It should be noted that the time point when the upstream node sends the time synchronization message is the time point recorded by the clock of the upstream node. If the time interval between two adjacent cycles recorded by the clock of the upstream node is greater than the first preset time length, it means that the time point recorded by the clock of the upstream node is wrong, and the clock of the upstream node may have a clock failure and a clock jump occurs.
[0067] Similarly, the time point when the terminal node receives the time synchronization message is the time point recorded by the terminal node's clock. If the time interval between two adjacent cycles recorded by the terminal node's clock is greater than the first preset duration, it means that the time point recorded by the terminal node's clock is wrong, and the terminal node's clock may have a clock failure and a clock jump may occur.
[0068] Similarly, the time point when the master clock node sends the synchronization information is the time point recorded by the clock of the master clock node. If the time interval between two adjacent cycles recorded by the clock of the master clock node is greater than the second preset time length, it means that the time point recorded by the clock of the master clock node is wrong, and the clock of the master clock node may have a clock failure and a clock jump occurs.
[0069] Figure 3 is a flow chart of a clock detection method according to an exemplary embodiment. Figure 3 As shown, the above step S202 specifically includes the following steps:
[0070] S301. When a first time point and a second time point are time points at which an upstream node sends a time synchronization message to a terminal node at two different time points, and a clock deviation between the terminal node and a master clock node is greater than a first threshold, determine whether a clock failure occurs in the upstream node based on the first time point and the second time point.
[0071] Optionally, the detection module of the electronic device can determine whether the clock deviation between the terminal node and the main clock node included in the second time information received in two adjacent cycles is greater than a first threshold. If the clock deviation is greater than the first threshold, the detection module of the electronic device can determine that a clock failure has occurred in the upstream node or the terminal node.
[0072] Furthermore, the detection module of the electronic device may determine whether a clock failure occurs in the upstream node based on an original timestamp included in the second time information received in two adjacent cycles.
[0073] If the clock deviation is less than or equal to the first threshold, the detection module of the electronic device can determine that no clock failure occurs in the upstream node or the terminal node.
[0074] It should be noted that if the clock deviation between the terminal node and the master clock node is large, it means that a clock failure has occurred in the upstream node or the terminal node during the clock synchronization process.
[0075] In a possible implementation, when the first time point and the second time point are time points at which the upstream node sends a time synchronization message to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold, the difference between the second time point and the first time point is determined as the first time difference. Further, when the first time difference is greater than the second threshold, it is determined that a clock failure occurs in the upstream node.
[0076] The second threshold is greater than the time interval for the upstream node to send a time synchronization message to the terminal node.
[0077] Optionally, the detection module of the electronic device can subtract the time point included in the original timestamp included in the second time information received in two adjacent cycles (i.e., the time point when the upstream node of the terminal node sends the time synchronization message to the terminal node) to obtain the first time difference. Furthermore, when the absolute value of the first time difference is greater than the second threshold, the detection module of the electronic device determines that a clock failure occurs in the upstream node and records it in the log. The second threshold can be the sum of the first preset duration and the first preset value. The first preset value is a delay time that the system can accept.
[0078] When the absolute value of the first time difference is less than or equal to the second threshold, the detection module of the electronic device determines that no clock failure occurs in the upstream node.
[0079] It should be noted that the upstream node is usually a switch node, which only has the function of forwarding data and cannot directly report its own time information (i.e., the time point of the time synchronization message sent to the terminal node), so it is impossible to determine whether the upstream node has a clock failure. To address this problem, the present application obtains the time point of the time synchronization message sent by the upstream node of the terminal node to the terminal node from the terminal node to determine whether the upstream node has a clock failure.
[0080] Figure 4 is a flow chart of another clock detection method according to an exemplary embodiment. Figure 4As shown, the method in the above step S202 specifically comprises the following steps:
[0081] S401. Determine whether a clock failure occurs in the terminal node based on the first time point and the second time point, when the first time point and the second time point are the time points at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0082] Optionally, the detection module of the electronic device can determine whether the clock deviation between the terminal node and the main clock node included in the second time information received in two adjacent cycles is greater than a first threshold. If the clock deviation is greater than the first threshold, the detection module of the electronic device can determine that a clock failure has occurred in the upstream node or the terminal node.
[0083] Furthermore, the detection module of the electronic device may determine whether a clock failure occurs in the upstream node according to the timestamp of the terminal node included in the second time information received in two adjacent cycles.
[0084] If the clock deviation is less than or equal to the first threshold, the detection module of the electronic device can determine that no clock failure occurs in the upstream node or the terminal node.
[0085] It should be noted that if the clock deviation between the terminal node and the master clock node is large, it means that a clock failure has occurred in the upstream node or the terminal node during the clock synchronization process.
[0086] In a possible implementation, when the first time point and the second time point are time points at which the terminal node receives a time synchronization message sent by an upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold, the difference between the second time point and the first time point is determined as the second time difference. Further, when the second time difference is greater than a third threshold, it is determined that a clock failure occurs at the terminal node.
[0087] The third threshold is greater than a time interval for the terminal node to receive a time synchronization message sent by the upstream node to the terminal node.
[0088] Optionally, the detection module of the electronic device can subtract the time point included in the timestamp of the terminal node included in the second time information received in two adjacent cycles (i.e., the time point when the terminal node receives the time synchronization message sent by the upstream node to the terminal node) to obtain the second time difference. Furthermore, when the absolute value of the second time difference is greater than the third threshold, the detection module of the electronic device determines that a clock failure occurs in the terminal node and records it in the log. The third threshold can be the sum of the first preset duration and the second preset value. The second preset value is a delay time acceptable to the system.
[0089] When the absolute value of the second time difference is less than or equal to the third threshold, the detection module of the electronic device determines that no clock failure occurs in the terminal node.
[0090] Figure 5 is a flow chart of another clock detection method according to an exemplary embodiment. Figure 5 As shown, the method in the above step S202 specifically comprises the following steps:
[0091] S501: When a first time point and a second time point are time points at which the master clock node sends time information at two different time points, determine a difference between the second time point and the first time point as a third time difference.
[0092] S502: When the third time difference is greater than a fourth threshold, determine that a clock failure occurs in the master clock node.
[0093] The fourth threshold is greater than the time interval for the master clock node to send time information.
[0094] Optionally, the detection module of the electronic device can subtract the time point of the master clock timestamp included in the first time information received in two adjacent cycles (i.e., the time point when the master clock node sends the time information to the electronic device) to obtain a third time difference. Furthermore, when the absolute value of the third time difference is greater than the fourth threshold, the detection module of the electronic device determines that a clock failure occurs in the master clock node and records it in the log. The fourth threshold can be the sum of the second preset duration and the third preset value. The third preset value is a delay time that the system can accept.
[0095] When the absolute value of the third time difference is less than or equal to the fourth threshold, the detection module of the electronic device determines that no clock failure occurs in the master clock node.
[0096] Figure 6 is a flowchart showing a method of detecting a node clock failure according to an exemplary embodiment. Figure 6As shown, the detection module of the electronic device can receive the time information sent by each node, and determine whether any time information is the time information sent by the master clock node (i.e., the first time information in this application). If the time information is the time information sent by the master clock node, it is determined whether the absolute value of the difference between the time point corresponding to the master clock timestamp in the first time information received in the current cycle and the first time information received in the previous cycle is greater than the fourth threshold. If the absolute value of the difference between the time point corresponding to the master clock timestamp in the first time information received in the current cycle and the first time information received in the previous cycle is greater than the fourth threshold, it is determined that a clock failure occurs in the master clock node.
[0097] If the time information is not the time information sent by the master clock node, then determine whether the clock deviation between the terminal node and the master clock node in the second time information received in the current cycle is greater than the first threshold. If the clock deviation between the terminal node and the master clock node in the second time information is greater than the first threshold, then further determine whether the absolute value of the difference between the time point corresponding to the original timestamp in the second time information received in the current cycle and the second time information received in the previous cycle is greater than the second threshold. If the absolute value of the difference between the time point corresponding to the original timestamp in the second time information received in the current cycle and the second time information received in the previous cycle is greater than the second threshold, it is determined that a clock failure occurs in the upstream node of the terminal node.
[0098] If the absolute value of the difference between the time point corresponding to the original timestamp in the second time information received in the current cycle and the second time information received in the previous cycle is less than or equal to the second threshold, it is further determined whether the absolute value of the difference between the time point corresponding to the timestamp of the terminal node in the second time information received in the current cycle and the second time information received in the previous cycle is greater than the third threshold. If the absolute value of the difference between the time point corresponding to the timestamp of the terminal node in the second time information received in the previous cycle and the second time information received in the previous cycle is greater than the third threshold, it is determined that a clock failure occurs in the terminal node.
[0099] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, the clock detection device or electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0100] The embodiment of the present application can exemplarily divide the functional modules of the clock detection device or electronic device according to the above method. For example, the clock detection device or electronic device can include various functional modules corresponding to the various functional divisions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0101] Figure 7 is a block diagram of a clock detection device according to an exemplary embodiment. Figure 7 The clock detection device 130 includes: a transmission module 1301 and a determination module 1302.
[0102] Transmission module 1301 is used to obtain a first time point and a second time point; the first time point and the second time point include: at least one of the time points at which the upstream node of the terminal node sends a time synchronization message to the terminal node at two different time points, the time point at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the time point at which the master clock node sends time information at two different time points; the time synchronization message is used to synchronize the clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node that synchronizes the clocks of the terminal node and the upstream node.
[0103] The determination module 1302 is used to determine whether a clock failure occurs in a target node based on a first time point and a second time point; the target node includes: at least one of an upstream node, a terminal node, and a master clock node.
[0104] In one possible implementation, the determination module 1302 is also used to determine whether a clock failure occurs in the upstream node based on the first time point and the second time point, when the first time point and the second time point are the time points when the upstream node sends a time synchronization message to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0105] In one possible implementation, the determination module 1302 is also used to determine the difference between the second time point and the first time point as the first time difference; the determination module 1302 is also used to determine that a clock failure has occurred in the upstream node when the first time difference is greater than a second threshold, and the second threshold is greater than the time interval for the upstream node to send a time synchronization message to the terminal node.
[0106] In one possible implementation, the determination module 1302 is also used to determine whether a clock failure occurs at the terminal node based on the first time point and the second time point, when the first time point and the second time point are time points at which the terminal node receives a time synchronization message sent by an upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold.
[0107] In one possible implementation, the determination module 1302 is also used to determine the difference between the second time point and the first time point as the second time difference; the determination module 1302 is also used to determine that a clock failure has occurred in the terminal node when the second time difference is greater than a third threshold, and the third threshold is greater than the time interval for the terminal node to receive a time synchronization message sent by the upstream node to the terminal node.
[0108] In one possible implementation, the determination module 1302 is also used to determine the difference between the second time point and the first time point as a third time difference when the first time point and the second time point are the time points when the master clock node sends time information at two different time points; the determination module 1302 is also used to determine that a clock failure has occurred in the master clock node when the third time difference is greater than a fourth threshold, and the fourth threshold is greater than the time interval for the master clock node to send time information.
[0109] Figure 8 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Figure 8 As shown, the electronic device 160 includes but is not limited to: a processor 1601 and a memory 1602 .
[0110] The memory 1602 is used to store executable instructions of the processor 1601. It can be understood that the processor 1601 is configured to execute instructions to implement the clock detection method in the above embodiment.
[0111] It should be noted that those skilled in the art can understand that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Figure 8 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0112] The processor 1601 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1602, and calling data stored in the memory 1602, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1601 may include one or more processing modules. Optionally, the processor 1601 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1601.
[0113] The memory 1602 may be used to store software programs and various data. The memory 1602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one functional module (such as an acquisition unit, a determination unit, a processing unit, etc.), etc. In addition, the memory 1602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0114] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 1602 including instructions, and the above instructions can be executed by the processor 1601 of the electronic device 160 to implement the clock detection method in the above embodiment.
[0115] In actual implementation, Figure 7 The functions of the transmission module 1301 and the determination module 1302 in Figure 8 The processor 1601 in the embodiment calls the computer program stored in the memory 1602. The specific execution process can refer to the description of the clock detection method in the above embodiment, which will not be repeated here.
[0116] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0117] In an exemplary embodiment, the embodiment of the present application further provides a computer program product including one or more instructions, and the one or more instructions can be executed by the processor 1601 of the electronic device to complete the clock detection method in the above embodiment.
[0118] It should be noted that when the instructions in the above-mentioned computer-readable storage medium or one or more instructions in the computer program product are executed by the processor of the electronic device, the various processes of the above-mentioned clock detection method embodiment are implemented, and the same technical effect as the above-mentioned clock detection method can be achieved. To avoid repetition, they will not be repeated here.
[0119] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0120] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0121] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or the full classification part or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute the full classification part or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD and other media that can store program code.
[0124] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A clock detection method, characterized in that: The method comprises: Acquire a first time point and a second time point; the first time point and the second time point include: at least one of the time points at which the upstream node of the terminal node sends a time synchronization message to the terminal node at two different time points, the time points at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the time points at which the master clock node sends time information at two different time points; the time synchronization message is used to synchronize the clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node that synchronizes the clocks of the terminal node and the upstream node; Based on the first time point and the second time point, it is determined whether a clock failure occurs in a target node; the target node includes: at least one of the upstream node, the terminal node, and the master clock node.
2. The method according to claim 1, characterized in that The determining whether a clock failure occurs at the target node based on the first time point and the second time point includes: When the first time point and the second time point are the time points when the upstream node sends the time synchronization message to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold, determine whether a clock failure occurs in the upstream node based on the first time point and the second time point.
3. The method according to claim 2, characterized in that The determining, based on the first time point and the second time point, whether a clock failure occurs at the upstream node includes: determining a difference between the second time point and the first time point as a first time difference; When the first time difference is greater than a second threshold, it is determined that a clock failure occurs in the upstream node, and the second threshold is greater than a time interval for the upstream node to send a time synchronization message to the terminal node.
4. The method according to claim 1, characterized in that: The determining whether a clock failure occurs at the target node based on the first time point and the second time point includes: When the first time point and the second time point are the time points when the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and the clock deviation between the terminal node and the master clock node is greater than a first threshold, determine whether a clock failure occurs at the terminal node based on the first time point and the second time point.
5. The method according to claim 4, characterized in that The determining, based on the first time point and the second time point, whether a clock failure occurs at the terminal node includes: determining a difference between the second time point and the first time point as a second time difference; When the second time difference is greater than a third threshold, it is determined that a clock failure occurs at the terminal node, and the third threshold is greater than a time interval for the terminal node to receive the time synchronization message sent by the upstream node to the terminal node.
6. The method according to claim 1, characterized in that The determining whether a clock failure occurs at the target node based on the first time point and the second time point includes: In a case where the first time point and the second time point are time points at which the master clock node sends the time information at two different time points, determining a difference between the second time point and the first time point as a third time difference; When the third time difference is greater than a fourth threshold, it is determined that a clock failure occurs in the master clock node, and the fourth threshold is greater than the time interval for the master clock node to send the time information.
7. A clock detection device, characterized in that: It includes a transmission module and a determination module; The transmission module is used to obtain a first time point and a second time point; The first time point and the second time point include at least one of: a time point at which an upstream node of a terminal node sends a time synchronization message to the terminal node at two different time points, a time point at which the terminal node receives the time synchronization message sent by the upstream node to the terminal node at two different time points, and a time point at which a master clock node sends time information at two different time points; the time synchronization message is used to synchronize clocks of different nodes; the upstream node is located between the master clock node and the terminal node, and the master clock node is a node for synchronizing clocks of the terminal node and the upstream node; The determination module is used to determine whether a clock failure occurs in a target node based on the first time point and the second time point; the target node includes: at least one of the upstream node, the terminal node, and the master clock node.
8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: When the computer-executable instructions stored in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is capable of performing the method as claimed in any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device performs the method according to any one of claims 1 to 6.
Citation Information
Cited By
Clock synchronization method and device based on LIN protocol, and storage medium
CN122764413A
