Disclosure of Invention
The invention aims to overcome the defect that the configuration information of a communication module and a GNSS module is inconsistent when the communication module and the GNSS module are in asynchronous power failure and restarting in the prior art, and provides a method and a system for synchronizing the configuration information of a master module and a slave module.
The invention solves the technical problems by the following technical scheme:
the first aspect of the present invention provides a method for synchronizing configuration information of a master module and a slave module, where the master module includes a file system, and the method for synchronizing configuration information includes:
restarting the master module when the master module is powered down and the slave module is normal;
the main module acquires latest configuration information from the file system; the latest configuration information is the synchronous configuration information of the latest stored master module and the latest stored slave module in the file system before the master module is powered off;
and synchronously configuring the configuration information of the main module according to the latest configuration information.
Preferably, before the step of restarting the master module when the master module is powered down and the slave module is normal, the method for synchronizing configuration information further includes:
and the master module stores the current synchronous configuration information of the master module and the slave module to the file system every other timing period.
Preferably, after the step of storing the current synchronization configuration information of the master module and the slave module to the file system at intervals of a timing period, the synchronization method of the configuration information further includes:
storing first default configuration information to the file system; the first default configuration information is configuration information corresponding to the default configuration information of the slave module;
restarting the slave module when the slave module is powered down and the master module is normal;
configuring configuration information of the slave module according to the first default configuration information;
and after the master module detects that the slave module is restarted, the configuration information of the master module is synchronously configured according to the first default configuration information.
Preferably, after the step of storing the current synchronization configuration information of the master module and the slave module to the file system at intervals of a timing period, the synchronization method of the configuration information further includes:
storing second default configuration information to the file system; the second default configuration information is configuration information corresponding to default configuration information of the master module and the slave module;
restarting the master module and the slave module when the master module and the slave module synchronously lose power;
and synchronously configuring the configuration information of the master module and the slave module according to the second default configuration information.
Preferably, the master module is a communication module, and the slave module is a GNSS module;
and/or the configuration information includes at least one of a serial port baud rate, a positioning update rate of the GNSS, a navigation mode, and an NMEA (national marine electronics association) sentence output mode.
The invention provides a synchronization system of configuration information of a master module and a slave module, wherein the synchronization system of the configuration information comprises a master module and a slave module, the master module comprises a file system, and the master module further comprises a first restarting unit, an obtaining unit and a first configuration unit;
the first restarting unit is used for restarting the master module when the master module is powered down and the slave module is normal;
the acquisition unit is used for acquiring latest configuration information from the file system; the latest configuration information is the synchronous configuration information of the latest stored master module and the latest stored slave module in the file system before the master module is powered off;
the first configuration unit is configured to synchronously configure configuration information of the main module according to the latest configuration information.
Preferably, the main module further comprises a storage unit;
the storage unit is used for storing the current synchronous configuration information of the master module and the slave module to the file system every other timing period.
Preferably, the slave module includes a second restarting unit and a second configuration unit; the main module further comprises a detection unit;
the storage unit is further used for storing first default configuration information to the file system; the first default configuration information is configuration information corresponding to the default configuration information of the slave module;
the second restarting unit is used for restarting the slave module when the slave module is powered down and the master module is normal;
the second configuration unit is used for configuring configuration information of the slave module according to the first default configuration information;
the detection unit is used for detecting that the slave module is restarted and then calling the first configuration unit;
the first configuration unit is configured to synchronously configure configuration information of the main module according to the first default configuration information.
Preferably, the storage unit is further configured to store second default configuration information to the file system; the second default configuration information is configuration information corresponding to default configuration information of the master module and the slave module;
when the master module and the slave module synchronously lose power, the first restarting unit is used for restarting the master module and the second restarting unit is used for restarting the slave module;
the first configuration unit is used for synchronously configuring the configuration information of the master module according to the second default configuration information, and the second configuration unit is used for synchronously configuring the configuration information of the slave module according to the second default configuration information.
Preferably, the master module is a communication module, and the slave module is a GNSS module;
and/or, the configuration information comprises at least one of serial port baud rate, positioning update rate of GNSS, navigation mode and NMEA sentence output mode.
The invention has the positive progress effects that:
according to the method and the system for synchronizing the configuration information of the master module and the slave module, when the master module or the slave module asynchronously fails or synchronously fails and restarts, the latest configuration information is obtained from a file system through the master module, and the configuration information of the master module is synchronously configured according to the latest configuration information; or configuring the configuration information of the slave module according to the default configuration information of the slave module, and synchronously configuring the configuration information of the master module according to the default configuration information of the slave module after the master module detects that the slave module is restarted; or the configuration information of the master module and the slave module is synchronously configured according to the default configuration information, so that the synchronization of the configuration information of the master module and the slave module and the normal communication of the master module and the slave module are ensured.
Detailed Description
The invention is further illustrated by means of the following examples, which are not intended to limit the scope of the invention.
Example 1
The embodiment provides a method for synchronizing configuration information of a master module and a slave module, wherein the master module comprises a file system.
In this embodiment, when the master module and the slave module are in an abnormal working state, the first case is that only the master module is powered down and the slave module works normally; the second case is that only the slave is powered down and the master is working normally; the second case is that the master and slave synchronously power down.
When the first abnormal situation occurs between the master module and the slave module, as shown in fig. 1, the method for synchronizing the configuration information includes:
step 101, when the master module is powered down and the slave module is normal, restarting the master module.
Step 102, the main module obtains a latest configuration information from the file system; the latest configuration information is the latest stored synchronous configuration information of the master module and the slave module in the file system before the power of the master module is lost.
In this embodiment, before the master module is powered down (i.e., when both the master module and the slave module are in a normal working state), the configuration information of the master module and the slave module are completely consistent. When the main module is powered down and the slave module is normal, the configuration information of the slave module is consistent with the latest configuration information in the file system before the main module is powered down.
And step 103, synchronously configuring the configuration information of the main module according to the latest configuration information.
Specifically, the master module reinitializes the master module according to the latest configuration information so as to keep the configuration information of the master module and the slave module synchronous.
Prior to step 101, the synchronization method of the configuration information further includes:
step 100, the master module stores the current synchronous configuration information of the master module and the slave module to the file system every other timing period.
Specifically, when the master module and the slave module are both in a normal working state (i.e. the master module and the slave module are powered normally and can send and receive data normally), the master module stores the current synchronous configuration information of the master module and the slave module into the file system every other timing period, and then enters the next timing period.
In this embodiment, the master module and the slave module are connected through a serial port and perform data transmission.
The main module further comprises a timer, each period of the main module is counted by the timer, and the counted period can be generated by a clock of the system in real time or can be set manually. The storage mode of the current synchronous configuration information of the master module and the slave module can be, but is not limited to, the storage mode of a file system.
When the second abnormal situation occurs between the master module and the slave module, as shown in fig. 2, afterstep 100, the method for synchronizing configuration information further includes:
step 101', storing the first default configuration information to a file system; the first default configuration information is configuration information corresponding to default configuration information of the slave module.
Step 102', when the slave is powered down and the master is normal, the slave is restarted.
Step 103', the configuration information of the slave module is configured according to the first default configuration information.
Step 104', the master module synchronously configures the configuration information of the master module according to the first default configuration information after detecting that the slave module is restarted.
Specifically, when the slave module is powered down and then the configuration information of the slave module is restarted and configured according to the default configuration information of the slave module, and at this time, after the master module detects that the power supply of the slave module is very restarted, the master module resets the configuration information of the master module according to the default configuration information of the slave module, so that the master module and the configuration information of the slave module keep synchronous.
When the master module and the slave module have a third abnormal situation, as shown in fig. 3, afterstep 100, the method for synchronizing configuration information further includes:
step 101", storing the second default configuration information to the file system; the second default configuration information is configuration information corresponding to default configuration information of the master module and the slave module.
In this embodiment, the default configuration information of the master module is the same as the default configuration information of the slave module.
Step 102", when the master module and the slave module are powered down synchronously, the master module and the slave module are restarted.
Step 103", the configuration information of the master module and the slave module are synchronously configured according to the second default configuration information.
Specifically, when the master module and the slave module are completely powered down at the same time, the master module and the slave module are both restarted by configuration according to default configuration information so as to keep the master module and the slave module in synchronization with the configuration information.
In this embodiment, when the abnormality of the master module and the slave module is not resolved, in order to protect the master module and the slave module, the master module and the slave module are forcibly powered off simultaneously by using the synchronization method of the configuration information of fig. 3.
In this embodiment, the master module is a communication module, and the slave module is a GNSS module; and the communication module and the GNSS module perform data transmission through a serial port. The master module and the slave module may be other modules that can perform data interaction, which is not limited herein.
In this embodiment, the configuration information includes at least one of a serial port baud rate, a positioning update rate of the GNSS, a navigation mode, and an NMEA sentence output mode.
In this embodiment, when the master module or the slave module asynchronously fails or synchronously fails and restarts, the latest configuration information is obtained from the file system through the master module, and the configuration information of the master module is synchronously configured according to the latest configuration information; or configuring the configuration information of the slave module according to the default configuration information of the slave module, and synchronously configuring the configuration information of the master module according to the default configuration information of the slave module after the master module detects that the slave module is restarted; or the configuration information of the master module and the slave module is synchronously configured according to the default configuration information, so that the synchronization of the configuration information of the master module and the slave module and the normal communication of the master module and the slave module are ensured.
Example 2
The present embodiment provides a synchronization system for configuration information of a master module and a slave module, and as shown in fig. 4, the synchronization system for configuration information includes a master module 1 and aslave module 2. As shown in fig. 5, the main module 1 includes afile system 11, a storage unit 12, afirst restart unit 13, anacquisition unit 14, afirst configuration unit 15, adetection unit 16, and atimer 17. As shown in fig. 6, theslave module 2 includes asecond restart unit 21 and asecond configuration unit 22.
In this embodiment, when the master module 1 and theslave module 2 are in an abnormal working state, the following three conditions are classified, where the first condition is that only the master module 1 is powered down and theslave module 2 works normally; the second case is that only theslave module 2 is powered down and the master module 1 works normally; the second case is that the master 1 and theslave 2 are powered down synchronously.
When the first abnormal situation occurs between the master module 1 and theslave module 2.
The first restartingunit 13 is configured to restart the master module 1 when the master module 1 is powered down and theslave module 2 is normal.
The obtainingunit 14 is configured to obtain a latest configuration information from thefile system 11; the latest configuration information is the synchronization configuration information of the master module 1 and theslave module 2 stored latest in thefile system 11 before the master module 1 is powered down.
In this embodiment, before the master module 1 is powered down (i.e., when both the master module 1 and theslave module 2 are in a normal operating state), the configuration information of the master module 1 and theslave module 2 are completely consistent. When the master module 1 is powered down and theslave module 2 is normal, the configuration information of theslave module 2 is consistent with the latest configuration information in thefile system 11 before the master module 1 is powered down.
Thefirst configuration unit 15 is configured to synchronously configure configuration information of the main module 1 according to the latest configuration information.
Specifically, the master module 1 reinitializes the master module 1 according to the latest configuration information so that the master module 1 and the configuration information of theslave module 2 remain synchronized.
In the case that the master module 1 and theslave module 2 operate normally, the storage unit 12 is configured to store the current synchronization configuration information of the master module 1 and theslave module 2 to thefile system 11 every other timing period.
Specifically, when the master module 1 and theslave module 2 are both in a normal working state (i.e. the master module 1 and theslave module 2 are powered normally and can send and receive data normally), the storage unit 12 is configured to store the current synchronous configuration information of the master module 1 and theslave module 2 to thefile system 11 every one timing period, and then enter the next timing period.
In this embodiment, the master module 1 and theslave module 2 are connected through a serial port and perform data transmission.
Thetimer 17 is used to count each cycle of the main module 1, and the counted cycle may be generated by the clock of the system in real time or may be set manually. The storage manner of the current synchronization configuration information of the master module 1 and theslave module 2 may be, but is not limited to, a storage manner of a file system.
The storage unit 12 is further configured to store the first default configuration information to thefile system 11; the first default configuration information is configuration information corresponding to the default configuration information of theslave module 2. When the second abnormal situation occurs between the master module 1 and theslave module 2.
The second restartingunit 21 is configured to restart theslave module 2 when theslave module 2 is powered down and the master module 1 is normal.
Thesecond configuration unit 22 is configured to configure configuration information of theslave module 2 according to the first default configuration information.
The detectingunit 16 is configured to detect that thefirst configuration unit 15 is invoked after restarting theslave module 2.
Thefirst configuration unit 15 is configured to synchronously configure configuration information of the main module 1 according to the first default configuration information.
Specifically, when theslave module 2 is powered down and the configuration information of theslave module 2 is restarted according to the default configuration information of theslave module 2, and at this time, after the master module 1 detects that theslave module 2 is powered up and is restarted, the master module 1 resets its configuration information according to the default configuration information of theslave module 2, so that the master module 1 and the configuration information of theslave module 2 remain synchronous.
The storage unit 12 is further configured to store second default configuration information to thefile system 11; the second default configuration information is configuration information corresponding to the default configuration information of the master module 1 and theslave module 2. When the master module 1 and theslave module 2 have a third abnormal condition.
In this embodiment, the default configuration information of the master module is the same as the default configuration information of the slave module.
When the master module 1 and theslave module 2 are powered down synchronously, the first restartingunit 13 is used for restarting the master module 1 and the second restartingunit 21 is used for restarting theslave module 2.
Thefirst configuration unit 15 is configured to synchronously configure configuration information of the master module 1 according to the second default configuration information and thesecond configuration unit 22 is configured to synchronously configure configuration information of theslave module 2 according to the second default configuration information.
Specifically, when the master module 1 and theslave module 2 are completely powered down at the same time, the master module 1 and theslave module 2 are both configured with default configuration information for restarting, so as to keep the master module 1 and theslave module 2 in synchronization with the configuration information.
In this embodiment, when the abnormality of the master module 1 and theslave module 2 is not resolved, the synchronization system using the third configuration information forces the master module 1 and theslave module 2 to be powered off simultaneously in order to protect the master module 1 and theslave module 2.
In this embodiment, the master module 1 is a communication module, and theslave module 2 is a GNSS module; and the communication module and the GNSS module perform data transmission through a serial port. The master module 1 and theslave module 2 may be other modules that can perform data interaction, which is not specifically limited herein.
In this embodiment, the configuration information includes at least one of a serial port baud rate, a positioning update rate of the GNSS, a navigation mode, and an NMEA sentence output mode.
In this embodiment, when the master module or the slave module asynchronously fails or synchronously fails and restarts, the latest configuration information is obtained from the file system through the master module, and the configuration information of the master module is synchronously configured according to the latest configuration information; or configuring the configuration information of the slave module according to the default configuration information of the slave module, and synchronously configuring the configuration information of the master module according to the default configuration information of the slave module after the master module detects that the slave module is restarted; or the configuration information of the master module and the slave module is synchronously configured according to the default configuration information, so that the synchronization of the configuration information of the master module and the slave module and the normal communication of the master module and the slave module are ensured.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the principles and spirit of the invention, but such changes and modifications fall within the scope of the invention.