Method for realizing clock synchronization based on MDIO, intelligent terminal and storage medium

文档序号:1534539 发布日期:2020-02-14 浏览:29次 中文

阅读说明:本技术 基于mdio实现时钟同步的方法、智能终端及存储介质 (Method for realizing clock synchronization based on MDIO, intelligent terminal and storage medium ) 是由 李小军 吴闽华 孟庆晓 于 2019-10-22 设计创作,主要内容包括:本发明公开了基于MDIO实现时钟同步的方法、智能终端及存储介质,所述方法包括:主控板和至少一个业务板之间通过MDIO协议连接,并通过MDIO命令进行授时;所述主控板通过预设次数读取和记录所述业务板的时间,并同时记录在读取所述业务板时间时的当前时间,计算所述主控板与所述业务板之间的传输延时;所述主控板将最后读取的当前时间和所述传输延时相加后发送给所述业务板,所述业务板设置系统时间以完成和所述主控板的时间同步。本发明通过MDIO协议实现主控板和业务板的时间同步,适用范围广,操作简单,设置方便。(The invention discloses a method for realizing clock synchronization based on MDIO, an intelligent terminal and a storage medium, wherein the method comprises the following steps: the main control board is connected with at least one service board through an MDIO protocol, and time service is carried out through an MDIO command; the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board; and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board. The invention realizes the time synchronization of the main control board and the service board through the MDIO protocol, and has the advantages of wide application range, simple operation and convenient setting.)

1. A method for realizing clock synchronization based on MDIO is characterized in that the method for realizing clock synchronization based on MDIO comprises the following steps:

the main control board is connected with at least one service board through an MDIO protocol, and time service is carried out through an MDIO command;

the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board;

and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board.

2. The method of claim 1, wherein the MDIO command comprises a synchronous read command and a time-stamped write command.

3. The method according to claim 2, wherein the main control board reads and records the time of the service board by a preset number of times, and simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the main control board and the service board, specifically comprising:

recording the current time T1 before the main control board starts to execute the synchronous read command;

the main control board reads and records the current time T2 of the service board through the synchronous read command;

when the master control board reads the time of the service board, recording the current time T3;

the main control board reads the current time T4 of the service board again through the synchronous reading command and records the current time T4;

when the master control board reads the time of the service board, recording the current time T5;

and calculating the transmission delay Td between the main control board and the service board.

4. The method of claim 3, wherein the propagation delay Td is [ (T5-T1) - (T4-T2) ]/2.

5. The method according to claim 4, wherein the main control board adds the last read current time and the transmission delay and sends the added current time to the service board, and the service board sets a system time to complete time synchronization with the main control board, and specifically includes:

the main control board adds the last read current time T6 and the transmission delay Td to obtain a system time Tc, and sends the system time Tc to the service board for writing operation time service;

and the service board sets the system time Tc as the current time, and the service board completes the time synchronization with the main control board.

6. The method of claim 5, wherein the system time Tc is T6+ Td.

7. The method of claim 1, wherein the transmission delay is a time taken by the main control board to transmit a command.

8. The method of claim 1, wherein the main control board performs time synchronization according to addresses of different service boards.

9. An intelligent terminal, characterized in that, intelligent terminal includes: a memory, a processor and a program stored on the memory and executable on the processor for implementing clock synchronization based on MDIO, wherein the program for implementing clock synchronization based on MDIO implements the steps of the method for implementing clock synchronization based on MDIO as claimed in any one of claims 1 to 8 when executed by the processor.

10. A storage medium storing a program for implementing clock synchronization based on MDIO, wherein the program for implementing clock synchronization based on MDIO implements the steps of the method for implementing clock synchronization based on MDIO according to any one of claims 1 to 8 when executed by a processor.

Technical Field

The invention relates to the technical field of computer application, in particular to a method for realizing clock synchronization based on MDIO, an intelligent terminal and a storage medium.

Background

In most network products, the time of the single board on the whole network equipment or the whole machine frame is required to be set to be the same, and the time significance can be shown only by accurate time; in the prior art, the NTP/SNTP protocol (network clock synchronization protocol) is generally used to acquire time, and the PTP protocol of 1588 (precision clock synchronization protocol standard of network measurement and control system, which can achieve precise synchronization of an ethernet-based distributed system by periodically correcting and synchronizing clocks of all nodes in a network through a synchronization signal) is generally implemented based on ethernet/IP.

Accordingly, the prior art is yet to be improved and developed.

Disclosure of Invention

The invention mainly aims to provide a method for realizing clock synchronization based on MDIO, an intelligent terminal and a storage medium, and aims to overcome the defects in the prior art.

In order to achieve the above object, the present invention provides a method for implementing clock synchronization based on MDIO, which includes the following steps:

the main control board is connected with at least one service board through an MDIO protocol, and time service is carried out through an MDIO command;

the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board;

and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board.

Optionally, the method for implementing clock synchronization based on MDIO includes a synchronous read command and a time service write command.

Optionally, the method for implementing clock synchronization based on MDIO, where the main control board reads and records the time of the service board by a preset number of times, and simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the main control board and the service board, specifically includes:

recording the current time T1 before the main control board starts to execute the synchronous read command;

the main control board reads and records the current time T2 of the service board through the synchronous read command;

when the master control board reads the time of the service board, recording the current time T3;

the main control board reads the current time T4 of the service board again through the synchronous reading command and records the current time T4;

when the master control board reads the time of the service board, recording the current time T5;

and calculating the transmission delay Td between the main control board and the service board.

Optionally, in the method for implementing clock synchronization based on MDIO, the transmission delay Td is [ (T5-T1) - (T4-T2) ]/2.

Optionally, the method for implementing clock synchronization based on MDIO, where the main control board adds a last read current time to the transmission delay and sends the added current time to the service board, and the service board sets a system time to complete time synchronization with the main control board, specifically includes:

the main control board adds the last read current time T6 and the transmission delay Td to obtain a system time Tc, and sends the system time Tc to the service board for writing operation time service;

and the service board sets the system time Tc as the current time, and the service board completes the time synchronization with the main control board.

Optionally, the method for implementing clock synchronization based on MDIO includes that the system time Tc is T6+ Td.

Optionally, the method for implementing clock synchronization based on MDIO includes the step of transmitting a command to the main control board by using the transmission delay.

Optionally, the method for implementing clock synchronization based on MDIO includes that the main control board performs time synchronization according to addresses of different service boards.

In addition, to achieve the above object, the present invention further provides an intelligent terminal, wherein the intelligent terminal includes: the clock synchronization method comprises a memory, a processor and a program which is stored on the memory and can run on the processor and realizes clock synchronization based on MDIO, wherein when the program is executed by the processor, the steps of the clock synchronization method based on MDIO are realized.

In addition, in order to achieve the above object, the present invention further provides a storage medium, where the storage medium stores a program for implementing clock synchronization based on MDIO, and when the program for implementing clock synchronization based on MDIO is executed by a processor, the steps of the method for implementing clock synchronization based on MDIO are implemented.

In the invention, the main control board is connected with at least one service board through an MDIO protocol and time service is carried out through an MDIO command; the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board; and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board. The invention realizes the time synchronization of the main control board and the service board through the MDIO protocol, and has the advantages of wide application range, simple operation and convenient setting.

Drawings

FIG. 1 is a flow chart of a preferred embodiment of a method for implementing clock synchronization based on MDIO;

FIG. 2 is a schematic diagram of interaction between a main control board and a service board in the preferred embodiment of the method for implementing clock synchronization based on MDIO of the present invention;

fig. 3 is a schematic operating environment diagram of an intelligent terminal according to a preferred embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

As shown in fig. 1 and 2, the method for implementing clock synchronization based on MDIO according to the preferred embodiment of the present invention includes the following steps:

step S10, connecting the main control board and the at least one service board via an MDIO (Management Data Input/Output) protocol, and performing time service via an MDIO command;

step S20, the main control board reads and records the time of the service board through preset times, and simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the main control board and the service board;

and step S30, the main control board adds the last read current time and the transmission delay and sends the sum to the service board, and the service board sets the system time to complete the time synchronization with the main control board.

Specifically, in a device (e.g., a certain intelligent terminal), a control unit for controlling other service boards is generally made into a board called a main control board, which provides a configuration function, a management function, and the like for a user; the service board is a single board for implementing a certain service, such as GPON, ADSL, etc.

The MDIO command comprises a synchronous read command and a time service write command.

The preset times can be 4 times, 6 times and 8 times, so that the calculated average time delay between the plates is closer to the actual time delay, the more the times are, the more the time is accurate, but the longer the time is spent in the setting process, and therefore, the invention is preferably 4 times.

Further, when the preset number of times is 4, before the main control board starts executing the synchronous read command, recording a current time T1; the main control board reads and records the current time T2 of the service board through the synchronous read command; when the master control board reads the time of the service board, recording the current time T3; the main control board reads the current time T4 of the service board again through the synchronous reading command and records the current time T4; when the master control board reads the time of the service board, recording the current time T5; calculating a transmission delay Td between the main control board and the service board, which is t (delay) in fig. 2.

And the transmission delay Td is [ (T5-T1) - (T4-T2) ]/2.

The transmission delay is the time taken by the main control board to transmit the command, namely the time taken by the main control board to transmit the command to the service board.

The main control board carries out time synchronization according to the addresses of different service boards, each service board has its own address, a plurality of service boards can be provided, and when one main control board completes time service synchronization to one service board, time service synchronization is continuously carried out according to the address of the next service board.

The main control board adds the last read current time T6 and the transmission delay Td to obtain a system time Tc, which is T (current) in fig. 2, and sends the system time Tc to the service board for write operation time service; and the service board sets the system time Tc as the current time, and the service board completes the time synchronization with the main control board.

Wherein the system time Tc is T6+ Td.

Further, the MDIO protocol between the main control board and the service board adopts a one-to-many protocol model and follows the following 2 command formats (synchronous read command and time service write command); the master control board synchronizes the time of the master control board to all the service boards respectively through the following commands.

Figure BDA0002242483550000061

Figure BDA0002242483550000071

According to the above protocol, the address bit of the MDIO slave device to be noticed is only 5 bits, so theoretically, only 32 slave devices can be expanded at most, the register is also only 5 bits, and only 32 registers are provided, but the first 16 registers generally follow the unified standard and have fixed meanings, and the last 16 registers can be customized according to the needs of manufacturers; each register is 16 bits.

The method for implementing clock synchronization of multiple devices through MDIO is described as an example.

Supposing that three service boards need to synchronize the system time of the main control board; assuming that three service boards are respectively a service board a, a service board B and a service board C, and their respective slave device addresses are respectively 0x01, 0x02 and 0x 03; register addresses 0x1a (high 16 bits), 0x1b (low 16 bits) of the MDIO slave device, which are the current time of the system, from 1 month 1 day to the current seconds in 1970; register addresses 0x1c (high 16 bits), 0x1d (low 16 bits) of the MDIO slave device, to set the current time of the system, 1 month 1 day to the current number of seconds in 1970; the initial time of the system is 1970, 1 month, 1 day 00:00: 00; the time T1 when the main control board starts executing the synchronous read command is 1970, 1 month, 1 day 00:00: 03, 3 seconds from the initial time of the system; the main control board reads the current time T2 of the service board through a synchronous command, which is 1 month 1 day 00 in 1970: 00: 17, 17 seconds from the initial time of the system and recording (the time of the service board is asynchronous with the time of the main control board, so a time point is randomly assumed); when the master control board reads the time T2 of the service board, the current time T3 of the master control board is recorded, namely 1 month, 1 day 00 in 1970: 00: 05, 5 seconds from the initial time of the system; the master control board stands horse to read the current time T4 of the service board again through the synchronous command, which is 1 month 1 day 00 in 1970: 00: 19, 19 seconds from the initial time of the system and recording; when the master control board reads the time of the service board, the current time T5 of the master control board is recorded, which is 1 month, 1 day 00 in 1970: 00: 07, 7 seconds from the initial time of the system; the time point when the master control board gives time to the service board through the time authorization write command (time service write command) is T6, 1, 00 in 1970: 00: 10.

the time service process is as follows: the main control board records the current system time T1(0x00000003), then prepares the system time of the synchronous service board A, after sending a start signal to the MDIO bus, continuously sends out a read operation code of 10, then sends out a 5-bit slave device address 0x01, and then sends out a register address 0x1a, sets the MDIO line to a high-impedance state, prepares to read the 16-bit data on the line, and stores the data on the high 16-bit of T2; at this time, the MDIO slave device obtains the control right of the MDIO after the master board sets the MDIO line to the high impedance state, and sends the data (0x0000) of the register 0x1a from the high bit to the low bit to the master board with each clock cycle.

The main control board sends out an initial signal to the MDIO bus, continuously sends out a read operation code of 10 bits, then sends out a 5-bit slave device address 0x01, and sends out a register address 0x1b, sets the MDIO line to a high-resistance state, prepares to read 16-bit data on the line, and stores the data to a low 16-bit of T2; at this time, the MDIO slave device obtains the control right of the MDIO after the master control board sets the MDIO line to the high impedance state, and sends the data (0x0011) of the register 0x1b to the master control board from the high bit to the low bit with each clock cycle.

The master control board records the received complete T2(0x00000011) time, and records the own system time of the master control board as T3(0x 00000005); after the main control board sends out an initial signal to the MDIO bus, 10 read operation codes are continuously sent out, then 5-bit slave equipment address 0x01 is sent out, then register address 0x1a is sent out, the MDIO line is set to be in a high-impedance state, 16-bit data on the line are ready to be read, and the 16-bit data are stored to the high 16-bit of T4; at this time, the MDIO slave device obtains the control right of the MDIO after the master board sets the MDIO line to the high impedance state, and sends the data (0x0000) of the register 0x1a from the high bit to the low bit to the master board with each clock cycle.

The main control board sends out an initial signal to the MDIO bus, continuously sends out a read operation code of 10 bits, then sends out a 5-bit slave device address 0x01, and sends out a register address 0x1b, sets the MDIO line to a high-resistance state, prepares to read 16-bit data on the line, and stores the data to a low 16-bit of T4; at this time, the MDIO slave device obtains the control right of the MDIO after the master control board sets the MDIO line to the high impedance state, and sends the data (0x0013) of the register 0x1b to the master control board from the high bit to the low bit with each clock cycle.

The master board records the received full T4(0x00000013) time and at this time records its own system time as T5(0x 00000007).

At this time, according to the values of the 5 data T1, T2, T3, T4 and T5, the master control board can calculate that the delay time for the master control board to send data to the service board is T (delay) ((T5-T1) - (T4-T2))/2 ═ ((0x00000007-0x00000003) - (0x00000013-0x00000011))/2 ═ 1.

At time T6 (0x0000000a, decimal 10 hexadecimal is 0x0a), the main control board adds the number of seconds at time T6 and T (delay) to obtain T (current) of 0x0000000b, and then sends a time-giving write command of data T (current) to the service board a: the MDIO bus is signaled with a start signal, a write opcode of 01 is continued, followed by a 5 bit slave address of 0x01, followed by a register address of 0x1c, followed by a clock cycle of 10, and the upper 16 bits (0x0000) of the t (current) data are sent to the service board a.

The master board sends out a start signal to the MDIO bus, continues to send out a 01 write operation code, then sends out a 5-bit slave device address 0x01, then sends out a register address 0x1d, then sends out 10 in 2 clock cycles, and then sends out the lower 16 bits (0x000b) of the t (current) data to the service board a.

After the register 0x1d of the service board a is set, the number of seconds of the system time of the current service board a from the initial time of the system is 0x0000000b, which is converted into specific time of 1 month, 1 day, 00:00:11 in 1970.

When the time of the service board A is synchronized, the main control board changes the address of the service board into 0x02, and the time service synchronization is continuously carried out to the service board B (the time service synchronization is continuously carried out to the service board C after the time service synchronization is finished).

Further, as shown in fig. 3, based on the method for implementing clock synchronization based on MDIO, the present invention also provides an intelligent terminal, which includes a processor 10, a memory 20, and a display 30. Fig. 3 shows only some of the components of the smart terminal, but it should be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.

The memory 20 may be an internal storage unit of the intelligent terminal in some embodiments, such as a hard disk or a memory of the intelligent terminal. The memory 20 may also be an external storage device of the Smart terminal in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the Smart terminal. Further, the memory 20 may also include both an internal storage unit and an external storage device of the smart terminal. The memory 20 is used for storing application software installed in the intelligent terminal and various data, such as program codes of the installed intelligent terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In an embodiment, the memory 20 stores a program 40 for implementing clock synchronization based on MDIO, and the program 40 for implementing clock synchronization based on MDIO can be executed by the processor 10, so as to implement the method for implementing clock synchronization based on MDIO in the present application.

The processor 10 may be a Central Processing Unit (CPU), a microprocessor or other data Processing chip in some embodiments, and is used to run program codes stored in the memory 20 or process data, such as executing the MDIO-based clock synchronization method.

The display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch panel, or the like in some embodiments. The display 30 is used for displaying information at the intelligent terminal and for displaying a visual user interface. The components 10-30 of the intelligent terminal communicate with each other via a system bus.

In one embodiment, when the processor 10 executes the program 40 for implementing clock synchronization based on MDIO in the memory 20, the following steps are implemented:

the main control board is connected with at least one service board through an MDIO protocol, and time service is carried out through an MDIO command;

the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board;

and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board.

The MDIO command comprises a synchronous read command and a time service write command.

The main control board reads and records the time of the service board through preset times, records the current time when the time of the service board is read, and calculates the transmission delay between the main control board and the service board, and the method specifically comprises the following steps:

recording the current time T1 before the main control board starts to execute the synchronous read command;

the main control board reads and records the current time T2 of the service board through the synchronous read command;

when the master control board reads the time of the service board, recording the current time T3;

the main control board reads the current time T4 of the service board again through the synchronous reading command and records the current time T4;

when the master control board reads the time of the service board, recording the current time T5;

and calculating the transmission delay Td between the main control board and the service board.

And the transmission delay Td is [ (T5-T1) - (T4-T2) ]/2.

The main control board adds the last read current time and the transmission delay and sends the added current time to the service board, and the service board sets system time to complete time synchronization with the main control board, which specifically comprises:

the main control board adds the last read current time T6 and the transmission delay Td to obtain a system time Tc, and sends the system time Tc to the service board for writing operation time service;

and the service board sets the system time Tc as the current time, and the service board completes the time synchronization with the main control board.

The system time Tc is T6+ Td.

The transmission delay is the time taken by the main control board to transmit the command.

And the master control board performs time synchronization according to the addresses of different service boards.

The invention further provides a storage medium, wherein the storage medium stores a program for realizing clock synchronization based on MDIO, and the program for realizing clock synchronization based on MDIO realizes the steps of the method for realizing clock synchronization based on MDIO when being executed by a processor.

In summary, the present invention provides a method, an intelligent terminal and a storage medium for implementing clock synchronization based on MDIO, where the method includes: the main control board is connected with at least one service board through an MDIO protocol, and time service is carried out through an MDIO command; the master control board reads and records the time of the service board by preset times, simultaneously records the current time when the time of the service board is read, and calculates the transmission delay between the master control board and the service board; and the main control board adds the last read current time and the transmission delay and then sends the sum to the service board, and the service board sets system time to complete time synchronization with the main control board. The invention realizes the time synchronization of the main control board and the service board through the MDIO protocol, and has the advantages of wide application range, simple operation and convenient setting.

Of course, it will be understood by those skilled in the art that all or part of the processes of the methods of the above embodiments may be implemented by a computer program instructing relevant hardware (such as a processor, a controller, etc.), and the program may be stored in a computer readable storage medium, and when executed, the program may include the processes of the above method embodiments. The storage medium may be a memory, a magnetic disk, an optical disk, etc.

It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:电子装置以及电子装置的检测方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!