USB communication synchronization control method, terminal, smart lock and media
By setting up a constantly powered terminal in the smart lock and using heartbeat packets to determine the consistency of the flag bits and adjust the master-slave mode, the problem of USB communication asynchrony in the smart lock is solved, realizing synchronous control of the video module and the screen module, and preventing black screen and system restart.
Patent Information
- Application Number
- CN202310301221.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-27
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-03-27
AI Technical Summary
In smart locks, the inconsistent startup speeds of multiple MCUs can lead to USB communication asynchrony, resulting in black screens and system restarts. This is especially true in smart locks with screens, where the camera module and screen module are geographically distant, making it easy for USB communication signals to become out of sync during function scene switching and wake-up.
By setting the master-slave mode of the communication terminal through a constant power terminal, and using heartbeat packets to determine the consistency of the flag bits, the master-slave mode is dynamically adjusted to ensure USB communication synchronization and avoid deinitialization.
This effectively solves the black screen problem caused by signal asynchrony between the video module and the screen module in smart locks, ensuring the synchronization and stability of USB communication.
Smart Images

Figure CN116010329B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of USB communication synchronization control technology, specifically to a USB communication synchronization control method, terminal, smart lock, and medium. Background Technology
[0002] USB communication is a common communication method, but in practical applications, USB communication may become out of sync.
[0003] For example, in video transmission in smart locks, the presence of multiple MCUs can lead to USB signal asynchrony during power-on and power-off due to varying startup speeds, resulting in black screens and restarts. Alternatively, since chips may be powered at different times, using USB software initialization without powering on the host can cause internal deinitialization, increasing startup time. Smart locks with screens are a typical example. Because the camera module and screen module are geographically distant, USB communication is required. However, during function switching and wake-up, USB communication asynchrony can occur, leading to black screens and system restarts. Summary of the Invention
[0004] The first objective of this invention is to provide a USB communication synchronization control method, comprising: The constantly powered terminal is communicatively connected to at least the first communication terminal and the second communication terminal, respectively, for controlling the USB communication between the first communication terminal and the second communication terminal. After the constantly powered terminal is powered on, it sets the master-slave mode of the first communication terminal and the second communication terminal and resets the flag bits of the first communication terminal and the second communication terminal. The constantly powered terminal checks whether it receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in a second time interval. If yes, it sets the flag bit of the corresponding communication terminal to the first flag; if no, it flips the flag bit of the corresponding communication terminal to the second flag. The second time interval is greater than the heartbeat packet sending interval. The constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are the same, it performs master-slave setting according to the previously set master-slave mode. If the flag bits are different, it sets the communication terminal whose flag bit has not been flipped as the master.
[0005] Furthermore, the constant power terminal compares the flag bits of the first communication terminal and the second communication terminal through a truth table, and executes the corresponding master-slave mode setting; The first communication terminal and the second communication terminal have the same initial flag bit.
[0006] Furthermore, the constant-power terminal sets the initiating communication terminal of the initial USB transaction to master mode and the executing communication terminal of the initial USB transaction to slave mode.
[0007] The second objective of this invention is to provide a USB communication synchronization control method, comprising: a first communication terminal connected to a constantly powered terminal and at least a second communication terminal via USB communication; the first communication terminal sending heartbeat packets to the constantly powered terminal at a first time interval; the first communication terminal receiving a flag value assigned by the constantly powered terminal, the flag value being assigned by the constantly powered terminal according to the following rule: whether the constantly powered terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in a second time interval; if yes, setting the flag of the corresponding communication terminal to a first identifier; if no, flipping the flag of the corresponding communication terminal to a second identifier; the second time interval being greater than the first time interval; the first communication terminal setting a master-slave mode, the master-slave mode being set by the constantly powered terminal according to the following rule: the constantly powered terminal comparing the flags of the first communication terminal and the second communication terminal; if the flags are consistent, performing master-slave setting according to the previously set master-slave mode; if the flags are inconsistent, setting the communication terminal whose flag is not flipped as the master.
[0008] A third objective of this invention is to provide a USB communication synchronization control terminal: configured as a constantly powered terminal, the constantly powered terminal being connected to at least a first communication terminal and a second communication terminal respectively, for controlling USB communication between the first communication terminal and the second communication terminal; after powering on, the constantly powered terminal sets the master-slave mode of the first communication terminal and the second communication terminal, and resets the flag bits of the first communication terminal and the second communication terminal; whether the constantly powered terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in a second time interval, if yes, the flag bit of the corresponding communication terminal is set to a first identifier, if no, the flag bit of the corresponding communication terminal is flipped to a second identifier; the constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal, and if the flag bits are consistent, performs master-slave setting according to the previously set master-slave mode, and if the flag bits are inconsistent, sets the communication terminal whose flag bit has not been flipped as the master.
[0009] A fourth objective of this invention is to provide a communication terminal: configured as a first communication terminal to communicate with a second communication terminal via USB under the control of a constantly powered terminal; the first communication terminal sends heartbeat packets to the constantly powered terminal at a first time interval; the first communication terminal receives a flag value assigned by the constantly powered terminal, the flag value being assigned by the constantly powered terminal according to the following rule: whether the constantly powered terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in a second time interval; if yes, the flag value of the corresponding communication terminal is set to a first identifier; if no, the flag value of the corresponding communication terminal is flipped to a second identifier; the second time interval is greater than the first time interval; the first communication terminal is configured in a master-slave mode, the master-slave mode being set by the constantly powered terminal according to the following rule: the constantly powered terminal compares the flag values of the first communication terminal and the second communication terminal; if the flag values are consistent, the master-slave mode is set according to the previous setting; if the flag values are inconsistent, the communication terminal whose flag value has not been flipped is set as the master.
[0010] The fifth objective of this invention is to provide a smart lock, comprising a video module and a screen module, wherein the video module and the screen module communicate via USB, and the lock further comprises a constantly powered module, which is communicatively connected to both the video module and the screen module; after the constantly powered module is powered on, it sets the master-slave mode of the video module and the screen module, and resets the flag bits of the video module and the screen module; the video module and the screen module send heartbeat packets to the constantly powered module at a first time interval; The constant-power module determines whether it has received heartbeat packets from the video module and the screen module respectively during the second time interval. If yes, it sets the first flag of the corresponding module; otherwise, it flips the flag of the corresponding module to the second flag. The second time interval is greater than the first time interval. The constant-power module compares the flags of the video module and the screen module. If the flags match, it sets the master-slave mode according to the last setting. If the flags do not match, it sets the module whose flag has not been flipped as the master.
[0011] Furthermore, the constant power module compares the flag bits of the video module and the screen module using a truth table, and executes the corresponding master-slave mode setting; The initial flag bits of the video module and the screen module are the same.
[0012] Furthermore, the constant-power module is a microwave radar sensing module, a fingerprint recognition module, or a button module.
[0013] The sixth objective of this invention is to provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the USB communication synchronization control method as described above.
[0014] By adopting the above technical solution, the present invention has the following advantages compared with the prior art: 1. This invention identifies the heartbeat status of different communication terminals by setting flag bits, and then sets the master-slave mode. This can solve the problem of signal asynchrony when multiple communication terminals are communicating via USB, and prevent USB deinitialization anomalies.
[0015] 2. This invention is applied to smart locks and effectively solves the black screen problem caused by signal asynchrony when the video module and screen module communicate via USB in smart locks. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the process of Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the process of Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the topology of Embodiment 3 of the present invention; Figure 4 This is a schematic diagram of the topology of Embodiment 4 of the present invention; Figure 5 This is a schematic diagram of the topology of Embodiment 5 of the present invention; Figure 6 This is a schematic diagram of the process of Embodiment 5 of the present invention. Detailed Implementation
[0017] The embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art. Example 1
[0018] The first aspect of this invention discloses a USB communication synchronization control method, which is executed by a constantly powered terminal to achieve USB communication synchronization control among multiple communication terminals.
[0019] Please refer to Figure 1 As shown, its control methods include: The constant power terminal is connected to at least the first communication terminal and the second communication terminal respectively, and is used to control the USB communication between the first communication terminal and the second communication terminal; After the constant power terminal is powered on, the master-slave mode of the first communication terminal and the second communication terminal is set, and the flag bits of the first communication terminal and the second communication terminal are reset. If the constant power terminal receives heartbeat packets from the first communication terminal and the second communication terminal respectively during the second time interval, if yes, the flag bit of the corresponding communication terminal is set to the first flag; if no, the flag bit of the corresponding communication terminal is flipped to the second flag. The constant power terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits match, the master-slave setting is performed according to the previous master-slave mode. If the flag bits do not match, the communication terminal whose flag bit has not been flipped is set as the master.
[0020] In this way, when the terminal continues to be powered on, USB initialization can be performed according to the set master-slave mode, preventing a black screen from occurring during USB initialization.
[0021] The terminal described in this application is a hardware input or output terminal. Such terminals have their own microprocessor and control circuits for power-on management and master-slave settings.
[0022] The constantly powered terminal is a terminal that remains powered under normal conditions and does not go into sleep mode. Its MCU is usually a low-power microcontroller, such as an STM32 or 51 microcontroller. Taking a smart lock scenario as an example, it can be a third-party constantly powered low-power module that may be attached to the smart lock, such as a microwave radar sensing module for human body detection, a fingerprint recognition module for fingerprint recognition, or a button module for button operation. These modules remain powered under normal conditions to perform their functions in real time.
[0023] The first and second communication terminals are used to perform USB communication. Each terminal can be configured with a master / slave mode. Setting it to master mode means it acts as the master device (USB Host), responsible for managing data transmission and port management on the USB bus, and interacting with other slave devices (USB Devices). Setting it to slave mode means it acts as a downstream device of the master, serving as a slave device on the USB bus and providing specific functions to the system.
[0024] The first communication terminal, the second communication terminal, and the always-powered terminal can be independent terminals in form, or they can be modules integrated into a certain device. For example, in a smart lock scenario, the first communication terminal can be a video module, the second communication terminal can be a screen module, and the always-powered terminal can be a microwave radar sensing module, a fingerprint recognition module, or a button module, etc. That is, in this case, each terminal is a different module integrated into the same device.
[0025] In a preferred embodiment, the constant power terminal uses a truth table to compare the flag bits of the first communication terminal and the second communication terminal, and executes the corresponding master-slave mode setting strategy.
[0026] Specifically, the truth table is as follows:
[0027] After power-on, the constant-power terminal resets the flag bits of the first communication terminal and the second communication terminal. At this time, the initial flag bits of the first communication terminal and the second communication terminal are the same, which can be the first flag or the second flag.
[0028] In this embodiment, the first identifier is marked with 0 and the second identifier is marked with 1. Therefore, the truth table becomes:
[0029] It is easy to understand that when the flag bits of the first communication terminal and the second communication terminal are both at the initial setting value, the previous master-slave setting refers to the master-slave mode initially set by the power-on module.
[0030] When setting the initial master-slave device mode, the constant-power terminal sets the mode according to the initiation flow of the USB transaction. The communication terminal initiating the initial USB transaction is set to master mode, and the communication terminal executing the initial USB transaction is set to slave mode. Taking a smart lock scenario as an example, initially, the USB transaction is initiated by the video module. Therefore, during initial setup, the video module is set to master mode, and the screen module is set to slave mode. Example 2
[0031] The second aspect of the present invention discloses a USB communication synchronization control method, which differs from Embodiment 1 in that the execution subject is different; the execution subject of Embodiment 2 is a communication terminal.
[0032] Please refer to Figure 2 As shown, a USB communication synchronization control method is applied to a communication terminal to enable it to communicate with another communication terminal via USB. The method includes: The first communication terminal is connected to a constantly powered terminal and is also connected via USB to at least one second communication terminal; the first communication terminal sends heartbeat packets to the constantly powered terminal at a first time interval. The first communication terminal receives a flag value assigned by the constant power terminal. The flag value is assigned by the constant power terminal according to the following rules: whether the constant power terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in the second time interval. If yes, the flag of the corresponding communication terminal is set to the first flag. If no, the flag of the corresponding communication terminal is flipped to the second flag. The second time interval is longer than the first time interval. The first communication terminal is set to master-slave mode. The master-slave mode is set by the constantly powered terminal according to the following rules: The constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are consistent, the master-slave mode is set according to the previous setting. If the flag bits are inconsistent, the communication terminal whose flag bit has not been flipped is set as the master.
[0033] The definitions of the first communication terminal, the second communication terminal, and the constantly powered terminal are the same as in Embodiment 1. For details not covered in this embodiment, please refer to the relevant terms and process descriptions in Embodiment 1. This embodiment will not elaborate further here. Example 3
[0034] A third aspect of the present invention is to provide a USB communication synchronization control terminal for implementing the method described in Embodiment 1.
[0035] Please refer to Figure 3 As shown, the present invention adopts the following technical solution: The USB communication synchronization control terminal is configured as the first communication terminal to communicate with a second communication terminal via USB under the control of a normally powered terminal. The first communication terminal sends a heartbeat packet to the constant power terminal at a first time interval; The first communication terminal receives a flag value assigned by the constant power terminal. The flag value is assigned by the constant power terminal according to the following rules: whether the constant power terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in the second time interval. If yes, the flag of the corresponding communication terminal is set to the first identifier. If no, the flag of the corresponding communication terminal is flipped to the second identifier. The second time interval is greater than the first time interval. The first communication terminal is set to master-slave mode. The master-slave mode is set by the constantly powered terminal according to the following rules: The constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are consistent, the master-slave mode is set according to the previous setting. If the flag bits are inconsistent, the communication terminal whose flag bit has not been flipped is set as the master. Example 4
[0036] A fourth aspect of the present invention is to provide a communication terminal for implementing the method described in Embodiment 2.
[0037] Please refer to Figure 4As shown, the present invention adopts the following technical solution: It is configured as a first communication terminal to communicate with a second communication terminal via USB under the control of a normally powered terminal; The first communication terminal sends heartbeat packets to the constant power terminal at a first time interval; The first communication terminal receives a flag value assigned by the constant power terminal. The flag value is assigned by the constant power terminal according to the following rules: whether the constant power terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in the second time interval. If yes, the flag of the corresponding communication terminal is set to the first identifier. If no, the flag of the corresponding communication terminal is flipped to the second identifier. The second time interval is greater than the first time interval. The first communication terminal is set to master-slave mode. The master-slave mode is set by the constantly powered terminal according to the following rules: the constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are consistent, the master-slave mode is set according to the previous setting. If the flag bits are inconsistent, the communication terminal whose flag bit has not been flipped is set as the master. Example 5
[0038] The fifth aspect of the present invention is to provide a smart lock to solve the problem of signal asynchrony that may occur when the video module and the screen module in the smart lock are far apart and USB communication is used, due to different startup times.
[0039] Please refer to Figure 5 and Figure 6 As shown, the present invention adopts the following technical solution: A smart lock includes a video module, a screen module, and a constantly powered module. The video module (also known as a camera module) communicates with the screen module via USB. The constantly powered module is connected to both the video module and the screen module to control the USB communication between them.
[0040] After the constant power module is powered on, set the master and slave modes of the video module and the screen module. Since the USB transactions are initially initiated by the video module, set the video module to master mode and the screen module to slave mode during the initial setup.
[0041] Setting it to host mode means it acts as a master device (USB Host), responsible for managing data transmission and port management on the USB bus, and interacting with other slave devices (USB Devices). Setting it to slave mode means it acts as a downstream device of the master, playing the role of a slave device (USB Device) on the USB bus, and providing specific functions to the system.
[0042] At the same time, after the constant power module is powered on, the flag bits of the video module and the screen module are reset, and the initial flag bits of the video module and the screen module are the same.
[0043] The video module and the screen module send heartbeat packets to the constant power module at a first time interval (2 seconds in this embodiment).
[0044] The constant power module determines whether it has received heartbeat packets from the video module and the screen module respectively during the second time interval (greater than the first time interval, 3 seconds in this embodiment). If yes, the first flag of the corresponding module is set; if no, the flag of the corresponding module is flipped to the second flag.
[0045] The constant power module compares the flag bits of the video module and the screen module. If the flag bits match, it sets the master and slave modes according to the last setting. If the flag bits do not match, it sets the module with the flag bits that have not been flipped as the master.
[0046] In this embodiment, the constant power module compares the flag bits of the video module and the screen module through a truth table and executes the corresponding master-slave mode setting; The truth table is as follows:
[0047] In this embodiment, the first identifier is marked with 0 and the second identifier is marked with 1. Therefore, the truth table becomes:
[0048] Among them, the constant power module is the constant power low power module in the smart lock, such as the microwave radar sensing module for human body sensing, the fingerprint recognition module for finger recognition, or the button module for button operation, etc.
[0049] This invention can effectively identify the power-on status of the video module and the screen module by setting a flag bit, and formulate a corresponding master-slave strategy, thus solving the problem of deinitialization or black screen caused by the asynchronous signals of the video module and the screen module. Example 6
[0050] The sixth objective of this invention is to provide a computer-readable storage medium. This invention adopts the following technical solution: a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the USB communication synchronization control method as described in any one of Embodiments 1-2.
[0051] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0052] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0053] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0054] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0055] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0056] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0057] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0058] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms should not be construed as necessarily referring to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0059] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A USB communication synchronization control method, characterized in that, include: The constant power terminal is connected to at least the first communication terminal and the second communication terminal respectively, and is used to control the USB communication between the first communication terminal and the second communication terminal; After the constant power terminal is powered on, the master-slave mode of the first communication terminal and the second communication terminal is set, and the flag bits of the first communication terminal and the second communication terminal are reset. If the constant-power terminal receives heartbeat packets from the first communication terminal and the second communication terminal respectively during the second time interval, and if so, the flag position of the corresponding communication terminal is set to the first flag; if not, the flag position of the corresponding communication terminal is flipped to the second flag; the second time interval is greater than the heartbeat packet transmission interval. The constant-power terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits match, the master-slave setting is performed according to the previously set master-slave mode. If the flag bits do not match, the communication terminal whose flag bit has not been flipped is set as the master.
2. The USB communication synchronization control method as described in claim 1, characterized in that: The constant-power terminal compares the flag bits of the first communication terminal and the second communication terminal through a truth table and executes the corresponding master-slave mode setting; the initial flag bits of the first communication terminal and the second communication terminal are the same.
3. The USB communication synchronization control method as described in claim 1, characterized in that: The constantly powered terminal sets the initiating communication terminal of the initial USB transaction to master mode and the executing communication terminal of the initial USB transaction to slave mode.
4. A USB communication synchronization control method, characterized in that, include: The first communication terminal is connected to a normally powered terminal and is also connected to at least one second communication terminal via USB. The first communication terminal sends heartbeat packets to the constant power terminal at a first time interval; The first communication terminal receives a flag value assigned by the constant power terminal. The flag value is assigned by the constant power terminal according to the following rules: whether the constant power terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in the second time interval. If yes, the flag of the corresponding communication terminal is set to the first identifier. If no, the flag of the corresponding communication terminal is flipped to the second identifier. The second time interval is greater than the first time interval. The first communication terminal is set to master-slave mode. The master-slave mode is set by the constantly powered terminal according to the following rules: the constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are consistent, the master-slave mode is set according to the previous setting. If the flag bits are inconsistent, the communication terminal whose flag bit has not been flipped is set as the master.
5. A USB communication synchronization control terminal, characterized in that: The device is configured as a constantly powered terminal, which is connected to at least a first communication terminal and a second communication terminal respectively, for controlling USB communication between the first communication terminal and the second communication terminal. After the constant power terminal is powered on, the master-slave mode of the first communication terminal and the second communication terminal is set, and the flag bits of the first communication terminal and the second communication terminal are reset. If the constant power terminal receives heartbeat packets from the first communication terminal and the second communication terminal respectively during the second time interval, and if so, the first flag of the corresponding communication terminal is set; otherwise, the flag of the corresponding communication terminal is flipped to the second flag. The constant-power terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits match, the master-slave setting is performed according to the previously set master-slave mode. If the flag bits do not match, the communication terminal whose flag bit has not been flipped is set as the master.
6. A communication terminal, characterized in that: It is configured as a first communication terminal to communicate with a second communication terminal via USB under the control of a normally powered terminal; The first communication terminal sends heartbeat packets to the constant power terminal at a first time interval; The first communication terminal receives a flag value assigned by the constant power terminal. The flag value is assigned by the constant power terminal according to the following rules: whether the constant power terminal receives heartbeat packets sent by the first communication terminal and the second communication terminal respectively in the second time interval. If yes, the flag of the corresponding communication terminal is set to the first identifier. If no, the flag of the corresponding communication terminal is flipped to the second identifier. The second time interval is greater than the first time interval. The first communication terminal is set to master-slave mode. The master-slave mode is set by the constantly powered terminal according to the following rules: the constantly powered terminal compares the flag bits of the first communication terminal and the second communication terminal. If the flag bits are consistent, the master-slave mode is set according to the previous setting. If the flag bits are inconsistent, the communication terminal whose flag bit has not been flipped is set as the master.
7. A smart lock, comprising a video module and a screen module, wherein the video module and the screen module communicate via USB, characterized in that: It also includes a constant-power module, which is communicatively connected to the video module and the screen module respectively; after the constant-power module is powered on, it sets the master-slave mode of the video module and the screen module, and resets the flag bits of the video module and the screen module. The video module and the screen module send heartbeat packets to the constant power module at a first time interval; During the second time interval, the constant power module determines whether it has received heartbeat packets from the video module and the screen module respectively. If yes, it sets the first flag of the corresponding module; otherwise, it flips the flag of the corresponding module to the second flag. The second time interval is longer than the first time interval. The constant power module compares the flag bits of the video module and the screen module. If the flag bits match, the master-slave setting is performed according to the previous master-slave mode. If the flag bits do not match, the module whose flag bits have not been flipped is set as the master.
8. The smart lock as described in claim 7, characterized in that: The constant power module compares the flag bits of the video module and the screen module using a truth table and executes the corresponding master-slave mode settings; the initial flag bits of the video module and the screen module are the same.
9. The smart lock as described in any one of claims 7-8, characterized in that: The constant power module is a microwave radar sensing module, a fingerprint recognition module, or a button module.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program that, when executed by a processor, implements the USB communication synchronization control method as described in any one of claims 1-4.
Citation Information
Patent Citations
Equipment switching method and device, electronic equipment and storage medium
CN113297013A
Establishment method of double-machine complete-machine-level hot standby system
CN114490152A
