Summary of the invention
Based on this, it is necessary in view of the above-mentioned problems, providing a kind of serial ports switching side simple and convenient, switching efficiency is high
Method, device, computer equipment and storage medium.
A kind of serial ports switching method is applied to serial ports switching circuit, and the serial ports switching circuit includes: control module and string
Jaws equipment, the control module are connect with the serial equipment by serial ports, which comprises
When control module receives switching command, then pass through the communication of control level interrupt and the serial equipment;
After the interruption of the control module and the serial equipment communicate, serial equipment and third party device are by reserving
The connection of serial ports access point, establishes serial communication.
A kind of serial ports switching system, the system comprises: control module, serial equipment and third party device, the control
Module is connect with the serial equipment by serial ports;The control module is used for when receiving switching command, passes through control electricity
The flat communication interrupted with the serial equipment;The third party device is used to communicate when control module with serial equipment interruption
Afterwards, it is connect by reserved serial ports access point with the serial equipment, establishes the communication between the serial equipment.
Above-mentioned serial ports switching method and system then pass through control level interrupt when control module receives switching command
With the communication of serial equipment, then third equipment is connect with serial equipment by reserved serial ports access point and can be established and serial ports
Communication between equipment, which does not need to disconnect the hardware connection between control equipment and serial equipment can be real
Communication between existing serial equipment and third party device, it is simple and convenient, be conducive to improve switching efficiency.
A kind of serial ports switching method, is applied to serial ports switching circuit, and the serial ports switching circuit includes: serial equipment and more
A control module, the multiple control module is connect with the serial equipment by serial ports respectively, in the multiple control module
One of them is in the conductive state with the serial equipment, which comprises
When receiving serial ports switching command, according to the switching command, set by control level interrupt with the serial ports
Standby control module in the conductive state, and established in the serial equipment and other control modules wherein by controlling level
Connection between one.
A kind of serial ports switching system, the system comprises: multiple control modules and serial equipment, the multiple control module
It is connect respectively with the serial equipment by serial ports, one of them in the multiple control module is in the serial equipment
On state;
It is described to be used for serial equipment control module in the conductive state when receiving serial ports switching command, according to institute
Switching command is stated, by the communication for controlling level interrupt and the serial equipment;
One of them in other control modules is used to establish the communication between the serial equipment by controlling level.
Above-mentioned serial ports switching method and system then pass through control level interrupt and string when receiving serial ports switching command
The communication of jaws equipment, then and control in other control modules one of them by control level establish the serial equipment it
Between communication, the serial ports switching method do not need disconnect control equipment and serial equipment between hardware connection serial ports can be realized
Communication between equipment and other control modules, it is simple and convenient, be conducive to improve switching efficiency.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
As shown in Figure 1, proposing a kind of serial ports switching method, it is applied to serial ports switching circuit, the serial ports switching circuit
It include: control module and serial equipment, the control module is connect with the serial equipment by serial ports, and following step is specifically included
It is rapid:
Step 102, control module detects whether to receive switching command, when control module receives switching command (if
It is), then 104 are entered step, when control module is not received by switching command (if not), then control module is kept and serial equipment
Communication.
Wherein, switching command refers to the switching command of serial ports.The sending of switching command can be triggered by key, can also be with
By switch triggering, switching command can be obtained by the state of detection key or switch.Under normal conditions, control module
It is connect and is communicated by serial ports between serial equipment.The connection between third party device and serial equipment is established if necessary
Communication, then need to carry out serial ports switching.Serial equipment refers to the equipment with serial ports, and serial equipment is under different application scenarios
Can be different, for example, serial equipment can be communication module, be also possible to other modules for having serial ports.In one embodiment
In, control module is MCU module, and serial equipment is WIFI module.
Step 104, the communication that control module passes through control level interrupt and serial equipment.
Wherein, when control module detects switching command, made at control module and serial equipment by controlling level
In blocking state, that is, interrupt communication between the two.In one embodiment, pass through the logical of control level interrupt and serial equipment
Before the step of letter further include: release the control the serial ports characteristic of the interface of module.Specifically, by the serial ports of the interface of control module
Characteristic discharges, and becomes common IO (input and output) mouth, i.e., the interface is defined as communicating serial ports by program before, now by it
Become common programmable interface again.Then the level nature of the I/O port is switched to high-impedance state, interrupts communication between the two,
To complete final serial ports release.
Step 106, after control module is communicated with serial equipment interruption, the serial equipment and third party device pass through in advance
The serial ports access point connection stayed, establishes serial communication.
Wherein, third party device refers to equipment connection is established with serial equipment, and third party device, which refers to, has control
The equipment of function, for example, can be the computer equipment of user.Reserved serial ports access point refers to reserved hardware access points, the
Three method, apparatus realize the communication between serial equipment by reserved serial ports access point.As shown in Fig. 2, being one embodiment
In, control module, serial equipment, the connection schematic diagram between third party device.Control module and serial equipment pass through serial ports
Two paths of signals (TXD and RXD) connection, the two-way that third party device passes through serial ports by reserved serial ports access point and serial equipment
Signal connection.
Above-mentioned serial ports switching method then passes through control level interrupt and serial ports when control module receives switching command
The communication of equipment, then third equipment connect by reserved serial ports access point with serial equipment can establish with serial equipment it
Between communication, the serial ports switching method do not need disconnect control equipment and serial equipment between hardware connection serial ports can be realized
Communication between equipment and third party device, it is simple and convenient, be conducive to improve switching efficiency.
In one embodiment, described when the control module receives switching command, then pass through control level interrupt
With the communication of the serial equipment, the serial ports characteristic including discharging the control module interface;When the serial ports characteristic discharges it
Afterwards, the serial port pin level of the control module is switched to high-impedance state, interrupts the communication with the serial equipment.
Wherein, high-impedance state can be high resistant input state or high resistant output state or in input state, and close
The state of upper and lower resistance either other states for blocking the two to communicate.The serial ports characteristic of interface refers to that interface connects as communication
The characteristic of mouth, when needing to interrupt, discharges the serial ports characteristic of the interface by software programming come the characteristic of defining interface first,
Generic interface is converted to, then the state of switch level again.
In one embodiment, the serial equipment is WIFI module;Above-mentioned serial ports switching method further include: the control
Module sends state control signal to the WIFI module, so that the WIFI module enters program state;The third party sets
It is standby that the WIFI module completion burning is controlled by the serial ports access point.
Wherein, serial equipment is WIFI equipment, in order to carry out burning, control module to WIFI equipment by third party device
After receiving switching command further include: send state control signal to WIFI module, so that WIFI module is switched to burning shape
State, then after third party device is communicated with WIFI equipment by serial ports foundation, so that it may normal burning is carried out to WIFI module,
WIFI program is downloaded into WIFI module to complete burning.
As shown in figure 3, to carry out the flow chart of burning in one embodiment to WIFI module by third party device,
In, control module is MCU module.Firstly, opening power supply, MCU module is powered on, and is in WIFI module by serial ports and is normally connected
Connect working condition.MCU module detects key-press status, is determined whether to switch serial ports according to key-press status, if so, serial ports is released
It puts, serial port pin level is switched to high-impedance state, and pass through " WIFI pattern switching controls signal " for the shape in WIFI module
State is switched to program state.Third party device accesses the serial ports by reserved serial ports access point (hardware access points), takes over
WIFI program is downloaded to WIFI module, completes burning by WIFI serial ports.
In one embodiment, above-mentioned serial ports switching method further include: when the control module receives recovery instruction,
Then the communication with the serial equipment is re-established by controlling level.
It wherein,, can be by control for example, after the completion of burning after the completion of third party device and serial equipment communicating
Module, which is sent, restores instruction, to realize so that the state of control module control level re-establishes communication with serial equipment
The switchback of serial ports.
In one embodiment, the serial ports includes: that data send signaling interface and data receiver signaling interface;The control
It includes: that the data of the control module send signaling interface and the serial ports that molding block, which is connect with the serial equipment by serial ports,
The data reception signal interface of equipment connects, the data reception signal interface of the control module and the data of the serial equipment
Send signaling interface connection.
Wherein, serial ports includes that data send signaling interface TXD and data receiver signaling interface RXD.The TXD of control module and
The RXD connection of serial equipment, the TXD connection of the RXD and serial equipment of control module.
In one embodiment it is proposed that a kind of serial ports switching method, is applied to serial ports switching circuit, the serial ports switching
Circuit includes: serial equipment and multiple control modules, and the multiple control module is connected with the serial equipment by serial ports respectively
It connects, one of them in the multiple control module and the serial equipment are in the conductive state, which is characterized in that the method
It include: when receiving serial ports switching command, according to the switching command, at control level interrupt and the serial equipment
The serial equipment and one of them in other control modules are established in the control module of on state, and by controlling level
Between connection.
Wherein, multiple control modules are connect with serial equipment by serial ports respectively, but synchronization can only have a control
Molding block and serial equipment are in the conductive state.Serial equipment and the connection of multiple control modules can switch over, when one
When control module and serial equipment are in the conductive state, other control modules are in interrupt status, by controlling other control moulds
The level of block is in high-impedance state.When needing serial ports being transformed into another control module from a control module, then touch
Serial ports switching command is sent out, control level interrupt and serial equipment control mould in the conductive state can be passed through according to switching command
Then block controls the connection that another control module is established by control level between serial equipment.As shown in figure 4, being one
In a embodiment, multiple control modules (such as, comprising: control module 1, control module 2 ... ... control module N) it is set with serial ports
The schematic diagram of standby connection.In one embodiment, in control level interrupt and serial equipment control module in the conductive state
Before, the serial ports characteristic of the corresponding interface of control module is discharged, then controls the company between level interrupt and serial equipment again
It connects.
It in one embodiment, include control mould in switching command in order to determine the subject control circuit switched
Block identification identifies the target control module for determining and needing to be connected according to control module, establishes target control mould by controlling level
Communication between block and serial equipment.
In one embodiment it is proposed that a kind of serial ports switching method, is applied to serial ports switching circuit, serial ports switching electricity
Road includes: serial equipment and multiple control modules, and the multiple control module is connect with the serial equipment by serial ports respectively,
One of them in the multiple control module is in the conductive state with the serial equipment, which comprises with the string
When jaws equipment control module in the conductive state receives END instruction, at control level interrupt and the serial equipment
In the control module of on state;When one of them in other control modules receives enabled instruction, built by controlling level
Communication between the vertical and described serial equipment.
Wherein, multiple control modules are respectively with serial equipment physical connection, and only synchronization can only have one to be in
On state, when needing to be switched to another control module from a control module, firstly, to the control for being currently on state
Molding block sends END instruction, then can interrupt the control mould in the conductive state with serial equipment by controlling level
Block.Then one of reception enabled instruction in other control modules, then the control module can be by controlling level
Establish the communication between serial equipment.
As shown in figure 5, in one embodiment it is proposed that a kind of serial ports switching system, the system comprises: control module
502, serial equipment 504 and third party device 506, the control module are connect with the serial equipment by serial ports;The control
Molding block is used for when receiving switching command, by the communication for controlling level interrupt and the serial equipment;The third party
Equipment is used to pass through reserved serial ports access point and the serial equipment after control module is communicated with serial equipment interruption
The communication between the serial equipment is established in connection.
In one embodiment, the control module is also used to discharge the serial ports characteristic of the interface of the control module;When
After the serial ports characteristic release, the serial port pin level of the control module is switched to high-impedance state, is interrupted and the string
The communication of jaws equipment.
In one embodiment, the serial equipment is WIFI module;The control module also uses transmission state control letter
Number arrive the WIFI module so that the WIFI module enters program state;The third party device is also used to through the string
Mouth access point controls the WIFI module and completes burning.
In one embodiment, the control module is also used to then pass through control level weight when receiving recovery instruction
The new communication established with the serial equipment.
In one embodiment, the serial ports includes: that data send signaling interface and data receiver signaling interface;The control
The data of molding block send signaling interface and connect with the data reception signal interface of the serial equipment, the number of the control module
It is connect according to signaling interface is received with the data of serial equipment transmission signaling interface.
In one embodiment it is proposed that a kind of serial ports switching system, the system comprises: multiple control modules and serial ports
Equipment, the multiple control module are connect with the serial equipment by serial ports respectively, in the multiple control module wherein
One in the conductive state with the serial equipment;It is described to be used for serial equipment control module in the conductive state when reception
When to serial ports switching command, according to the switching command, pass through the communication of control level interrupt and the serial equipment;Other controls
One of them in molding block is used to establish the communication between the serial equipment by controlling level.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the program can be stored in a non-volatile computer and can be read
In storage medium, the program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, provided herein
Each embodiment used in any reference to memory, storage, database or other media, may each comprise non-volatile
And/or volatile memory.Nonvolatile memory may include that read-only memory (ROM), programming ROM (PROM), electricity can be compiled
Journey ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include random access memory
(RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms, such as static state RAM
(SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhanced SDRAM
(ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) directly RAM (RDRAM), straight
Connect memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously
The limitation to the application the scope of the patents therefore cannot be interpreted as.It should be pointed out that for those of ordinary skill in the art
For, without departing from the concept of this application, various modifications and improvements can be made, these belong to the guarantor of the application
Protect range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.