CN113709590A - Method, device and system for adjusting line sequence of serial port circuit and readable storage medium - Google Patents

Method, device and system for adjusting line sequence of serial port circuit and readable storage medium Download PDF

Info

Publication number
CN113709590A
CN113709590A CN202110996233.1A CN202110996233A CN113709590A CN 113709590 A CN113709590 A CN 113709590A CN 202110996233 A CN202110996233 A CN 202110996233A CN 113709590 A CN113709590 A CN 113709590A
Authority
CN
China
Prior art keywords
line sequence
serial port
port circuit
tested
line
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110996233.1A
Other languages
Chinese (zh)
Inventor
苏航
曾明强
赖国洪
刘伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ruijie Networks Co Ltd
Original Assignee
Ruijie Networks Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ruijie Networks Co Ltd filed Critical Ruijie Networks Co Ltd
Priority to CN202110996233.1A priority Critical patent/CN113709590A/en
Publication of CN113709590A publication Critical patent/CN113709590A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04QSELECTING
    • H04Q1/00Details of selecting apparatus or arrangements
    • H04Q1/02Constructional details
    • H04Q1/10Exchange station construction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/10Packet switching elements characterised by the switching fabric construction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04QSELECTING
    • H04Q1/00Details of selecting apparatus or arrangements
    • H04Q1/02Constructional details

Abstract

The invention provides a method, a device and a system for adjusting a line sequence of a serial port circuit and a readable storage medium, wherein the method for adjusting the line sequence comprises the following steps: detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started or not; if the serial port circuit is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with opposite-end equipment by adopting the line sequence to be tested; if the communication fails, polling line sequence channels in the serial port circuit until the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identify different line sequences; and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface. The method is used for realizing the compatibility and the practicability of the serial port.

Description

Method, device and system for adjusting line sequence of serial port circuit and readable storage medium
Technical Field
The invention belongs to the technical field of communication, and particularly relates to a method, a device and a system for adjusting a line sequence of a serial port circuit and a readable storage medium.
Background
The serial port is used as a basic management port of the switch, plays an important role in configuration and management of the switch, the switch can be configured, monitored and abnormal state processed through the serial port of the switch, and all functions of the switch are configured through the serial port, so that the management of the serial port becomes very important in a data center application scene and a common machine room application scene.
The interface of the serial port of the switch is different from the traditional serial port, and RJ45 is generally adopted as an external serial port interface. Traditional trapezoidal serial ports is compared to the RJ45 interface, and is small and exquisite nimble, the overall arrangement of being convenient for, and the cost is lower, and the serial ports of switch can directly use the net twine to communicate, has improved communication distance greatly, when carrying out large-scale rack overall arrangement, can directly use the net twine to connect serial port manager, makes things convenient for the field wiring. The serial port of the switch generally uses a three-wire mode, the protocol is simple to realize, and the communication reliability is high.
After the existing serial ports (such as a switch, a server, a computer and the like) are designed, the line sequence of the serial ports is determined, only one network cable corresponding to the line sequence can be used for communication, and the network cables of other line sequences cannot be used for communication. In an application scenario where the types of network cables required for layout and routing are many, the error probability and the routing cost of routing are increased, and the maintenance cost is also increased.
How to realize the compatibility and the practicability of the serial port becomes a technical problem which needs to be solved urgently.
Disclosure of Invention
The embodiment of the invention provides a method, a device and a system for adjusting a line sequence of a serial port circuit and a readable storage medium, which are used for realizing the compatibility and the practicability of a serial port.
In a first aspect, an embodiment of the present invention provides a method for adjusting a line sequence of a serial port circuit, including:
detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started or not;
if the serial port circuit is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with opposite-end equipment by adopting the line sequence to be tested;
if the communication fails, polling line sequence channels in the serial port circuit until the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identify different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
In one possible implementation manner, before the detecting whether the line sequence adaptive function of the electronic device including the serial port circuit is turned on, the method further includes:
determining a target line sequence channel in a gating state in a plurality of groups of line sequence channels included in the serial port circuit;
and determining a line sequence corresponding to the target line sequence channel according to the corresponding relation between the line sequence channels and the line sequence, taking the line sequence corresponding to the target line sequence channel as a line sequence to be tested which can be adapted to the electronic equipment, and storing the line sequence to be tested.
In one possible implementation manner, if the communication fails, polling a line-sequential channel in the serial port circuit until the electronic device effectively communicates with the peer device through the network cable includes:
sampling the level state of the serial port signal from the opposite terminal equipment;
if the level state indicates that the serial port signal is invalid, indicating that the electronic equipment is in invalid communication with the opposite terminal equipment under the line sequence to be tested;
and polling a line sequence channel in the serial port circuit until the sampled serial port signal is effective, and stopping polling.
In one possible implementation manner, after the sampling a level state of the serial port signal from the peer device, the method further includes:
and if the level state indicates that the serial port signal is invalid, the internal power supply of the serial port circuit is closed.
In one possible implementation manner, the determining a target line sequence adapted to the electronic device under the effective communication, and configuring the target line sequence to the serial port circuit includes:
determining a current line sequence channel when the serial port signal is valid;
storing a target line sequence corresponding to the current line sequence channel, replacing the line sequence to be detected, and taking the target line sequence as a target line sequence adapted to the electronic equipment under the effective communication;
and configuring the target line sequence to the serial port interface.
In one possible implementation manner, after detecting whether a line sequence adaptive function of the electronic device including the serial port circuit is turned on, the method further includes:
if not, reading the line sequence to be tested;
and configuring the line sequence to be tested to the serial port interface, and communicating with the opposite terminal equipment by adopting the line sequence to be tested.
In one possible implementation manner, after the attempting of communication with the peer device by using the line sequence to be tested, the method further includes:
and if the communication is successful, the line sequence to be tested is adopted to communicate with the opposite terminal equipment.
In a second aspect, an embodiment of the present invention provides a serial port circuit line sequence adjustment system, including:
the device comprises an opposite terminal device and an electronic device comprising the serial port circuit, wherein the serial port circuit comprises a controller, a serial port interface and a line sequence channel adjusting unit which is respectively coupled with the controller and the serial port interface; wherein the controller is to:
detecting whether a line sequence self-adaptive function of the electronic equipment is started or not;
if the serial port interface is started, when a network cable is inserted into the serial port interface, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with the opposite terminal equipment by adopting the line sequence to be tested;
if the communication fails, polling the line sequence channels in the line sequence channel adjusting unit until the electronic equipment effectively communicates with the opposite terminal equipment through the network cable, wherein the line sequence channels are in multiple groups, and each group in the multiple groups of line sequence channels respectively identifies different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
In a third aspect, an embodiment of the present invention provides a line sequence adjusting apparatus, where the line sequence adjusting apparatus includes a processor, and the processor is configured to implement the steps of the line sequence adjusting method according to any one of the above when executing a computer program stored in a memory.
In a fourth aspect, the present invention provides a readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the steps of the line sequence adjustment method according to any one of the above.
The invention has the following beneficial effects:
the embodiment of the invention provides a method, a device, a system and a readable storage medium for adjusting a line sequence of a serial port circuit, which comprises the steps of firstly detecting whether the line sequence self-adaptive function of an electronic device comprising the serial port circuit is started, if the line sequence self-adaptive function is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, adopting the line sequence to be tested to try to communicate with an opposite terminal device, if the communication fails, polling a plurality of groups of line sequence channels in the serial port circuit until the electronic device effectively communicates with the opposite terminal device through the network cable, then determining a target line sequence adapted to the electronic device under the effective communication, then configuring the target line sequence to the serial port interface, and thus, after the line sequence self-adaptive function of the electronic device comprising the serial port circuit is started, selecting the line sequence of the serial port interface in a self-adaptive way, the serial interface can support various line sequences, and can support three network line types such as direct connection, cross connection and reversal connection, thereby realizing the compatibility and practicability of the serial interface.
Drawings
Fig. 1 is a block diagram of one structure of a serial port circuit line sequence adjustment system according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for adjusting a line sequence of a serial port circuit according to an embodiment of the present invention;
FIG. 3 is a flowchart of the method of FIG. 1 prior to step S101;
FIG. 4 is a flowchart of the method of step S103 in FIG. 1;
FIG. 5 is a flowchart of the method of step S104 in FIG. 1;
FIG. 6 is a flowchart of the method of FIG. 1 after step S101;
fig. 7 is a flowchart of a method for adjusting a line sequence of a serial port circuit according to an embodiment of the present invention;
fig. 8 is a block diagram of a serial port circuit line sequence adjustment system according to an embodiment of the present invention;
fig. 9 is a block diagram of a line sequence adjusting apparatus according to an embodiment of the present invention.
Detailed Description
The term "comprises" and any variations thereof in the description and claims of the invention are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the invention. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In order to better understand the technical solutions of the present invention, the technical solutions of the present invention are described in detail below with reference to the drawings and the specific embodiments, and it should be understood that the specific features in the embodiments and the embodiments of the present invention are detailed descriptions of the technical solutions of the present invention, and are not limitations of the technical solutions of the present invention, and the technical features in the embodiments and the embodiments of the present invention may be combined with each other without conflict.
After the existing serial ports (such as a switch, a server, a computer and the like) are designed, the line sequence of the serial ports is determined, only one network cable corresponding to the line sequence can be used for communication, and the network cables of other line sequences cannot be used for communication. The existing commonly used network cable types comprise a cross cable, a direct cable and a reversal cable which is customized and used on a serial port, wherein the reversal cable cannot be used on the Ethernet, and the customization price is higher. Taking the switch as an example, in the process of carrying out switch overhead wiring or maintenance debugging on site, one type of network cable cannot be used to meet wiring requirements, the reverse network cable used by the serial port and the network cable used by the Ethernet are always strictly distinguished, otherwise, serial port and network port communication are abnormal, the error probability of wiring and the wiring cost are greatly increased, meanwhile, in the maintenance process, the distinction is also needed, and the maintenance cost of a machine room is greatly improved. That is, in an application scenario where the number of types of network cables required for the layout and routing is large, the routing error probability and the routing cost are increased, and the maintenance cost is also increased. How to realize the compatibility and the practicability of the serial port becomes a technical problem which needs to be solved urgently.
In view of this, the embodiments of the present invention provide a method, an apparatus, a system and a readable storage medium for adjusting a line sequence of a serial port circuit, so as to implement compatibility and practicability of a serial port.
Before introducing the method for adjusting the line sequence of the serial port circuit provided by the embodiment of the invention, a line sequence adjusting system including the serial port circuit is described in detail.
Fig. 1 is a block diagram of one of the line sequence adjusting systems according to the embodiments of the present invention, where the line sequence adjusting system includes an opposite terminal device 30 and an electronic device 10 including the serial port circuit 01, where the serial port circuit 01 includes a controller 1, a serial port interface 2, and a line sequence channel adjusting unit 3 respectively coupled to the controller 1 and the serial port interface 2, and the serial port circuit 01 further includes a level converting unit 4 respectively coupled to the controller 1 and the line sequence channel adjusting unit 3.
The electronic device 10 may be a switch, a server, a notebook computer, a tablet computer, etc., and is not limited herein. If the electronic Device 10 is a switch, the controller 1 may be a Complex Programmable Logic Device (CPLD) or a Central Processing Unit (CPU), and is not limited herein. The peer device 30 may be an upper computer interacting with the switch through a serial port, and may configure and read a state of the switch. In addition, controller 1 can directly interact through serial ports and host computer, controls the switch, can also control and monitor level conversion unit 4, coordinates the normal work of whole serial circuits 01.
The level conversion unit 4 may be an RS232 chip for converting TTL signals to RS232 signals, and mainly performs level conversion, and since the level range of the RS232 signals is-15V to 15V, and the operating voltage of the controller 1 inside the switch is generally 3.3V, the level conversion unit 4 performs level conversion, so that the normal operation of the switch can be ensured. The level shift unit 4 includes a level shift section and a control section. The control part can control the power supply part of the RS232 chip, and accordingly the RS232 chip has multiple working modes (power supply modes), for example, when the RS232 chip does not perform data interaction, an internal power supply can be automatically turned off, so that power consumption is reduced. Can be carried out by aiming at forceon,
Figure BDA0003234215090000074
The level of the pin is adjusted, the RS232_ RX pin is monitored, and the power supply part of the RS232 chip is controlled.
There are the following four modes as to the power mode of the RS232 chip. The level status of each pin in four modes is shown in table 1, where "x" indicates "independently of it", "Z" indicates a high impedance state "," H "indicates a high level", "L" indicates a low level ", and" Y "indicates" the level status of RS232_ RX is less than-2.7V, or greater than 2.7V, or between-0.3V and the duration is less than 30 μ s ".
Figure BDA0003234215090000071
TABLE 1
The first mode is an internal power forced off mode, which may be a pull-down by the controller 1
Figure BDA0003234215090000072
And the pin is connected with the RS232 chip, so that the internal power supply of the RS232 chip is turned off, and at the moment, the RS232 chip is in a turned-off state and does not respond to all serial port requests.
The second mode is an automatic power off mode, which may be a pull-up by the controller 1
Figure BDA0003234215090000073
The pins are pulled up simultaneously, at the moment, the automatic power mode is in an off state, the RS232 chip can normally work and is in a working state all the time without paying attention to the level state of the RS232_ RX pin, and in the mode, the power consumption of the RS232 chip is high.
The third mode is an automatic power mode on mode, which may be a pull-up by the controller 1
Figure BDA0003234215090000081
The pins are pulled down simultaneously, at the moment, the automatic power mode is started, and the RS232 chip can determine whether to be turned off or not according to the level state of the RS232_ RX pinAnd closing the internal power supply, and when the level state of the RS232_ RX is less than-2.7V, or more than 2.7V, or between-0.3V and the duration is less than 30 mu s, indicating that the data is in an effective state, wherein at the moment, the external serial port is considered to be connected, the data works normally, and the internal power supply is turned on, so that the normal communication with the opposite terminal equipment can be ensured. In addition, a pull-up is required
Figure BDA0003234215090000082
And the level conversion unit 4 informs the controller 1 that data comes from the serial port.
And the fourth mode is an automatic internal power supply closing mode, when the level state of the RS232_ RX is between-0.3V and the duration is more than 30 mu s, the external serial port connection can be considered to be disconnected, at the moment, the automatic internal power supply closing mode is entered, the internal power supply is in a closing state, and the RS232 chip enters a low power consumption mode. In addition, pull-down is also required
Figure BDA0003234215090000083
And the level conversion unit 4 informs that the serial port of the controller 1 is not connected with the opposite terminal equipment.
The line sequence channel adjusting unit 3 can adjust a serial port line sequence, the line sequence channel adjusting unit 3 can include six analog switches, which are respectively 1A-1B, 2A-2B, 3A-3B, 4A-4B, 5A-5B and 6A-6B, wherein a and B are pins of the analog switches, C is a control pin which can control connection and disconnection between a and B, and control over the C pin is realized by the controller 1, wherein 1A-1B and 2A-2B are used for realizing the line sequence of externally used reverse lines, 3A-3B and 4A-4B are used for realizing the line sequence of externally used straight lines, 5A-5B and 6A-6B are used for realizing the line sequence of externally used cross lines, and 1C-6C are used for controlling on and off between a and B.
The serial port interface 2 is an external interface of the serial port circuit 01, and may be an RJ45 interface, and may be directly connected with the network cable 20 through an RJ45 interface, wherein when the serial port interface 2 is an RJ45 interface, pins 1, 2, 3, and 6 on the interface are used as data transmission, only two pins of each line pass through data, other pins are in an idle state, and pins 4 and 5 are used as ground, so as to form a three-wire communication mode of the serial port.
The mesh wire 20 includes three types including a cross wire, a straight wire and a reverse wire; corresponding to the cross line, one end of the mesh wire 20 is 568A standard, and the other end is 568B standard; for the direct connection, the line sequences at the two ends of the network cable 20 are the same, and are either 568A standard or 568B standard; for inverted lines, one end of the mesh 20 may be 568A standard and the other end must be in the opposite direction, e.g., the ordering of the 568A standard lines is: green white, green, orange white, blue white, orange, brown white, brown, reverse, the other end line is ordered: brown, brown white, orange, blue white, blue, orange white, green white.
After the line sequence adjusting system of the serial port circuit is described in detail, the corresponding line sequence adjusting process is explained.
Fig. 2 is a flowchart of a method for adjusting a line sequence of a serial port circuit according to an embodiment of the present invention, where the method includes:
s101: detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started or not;
it should be noted that, the electronic device is first started, and the line sequence adaptive function is turned on by default, so that after the electronic device adapts to a line sequence, the electronic device may use the serial interface to communicate with the electronic device, such as a switch, so that the turn-on or turn-off of the line sequence adaptive function of the electronic device may be configured under communication.
S102: if the serial port circuit is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with opposite-end equipment by adopting the line sequence to be tested;
if opened electronic equipment's line sequence self-adaptation function, insert at the net twine during serial port interface in the serial circuits, for example, after the switch restarts, for example, detect the net twine after the serial ports plug and insert serial port interface again, need carry out serial ports connection again, can be with the line sequence configuration that awaits measuring of prestore arrive serial port interface adopts the line sequence that awaits measuring with opposite terminal equipment tries to communicate, the line sequence that awaits measuring can electronic equipment starts the line sequence that the adaptation arrived last time. That is to say, if the electronic device starts the line sequence adaptive function, and the network cable is inserted after the next device is restarted, or the network cable is inserted again after the serial port is plugged, the last adapted line sequence to be tested can be adopted to try to communicate, and since the historical serial port connection record is more in line with the actual use habit of the user, the correctness of the line sequence is ensured, and the success rate of communication is improved.
S103: if the communication fails, polling line sequence channels in the serial port circuit until the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identify different line sequences;
if the communication between the line sequence to be tested and the opposite terminal equipment fails, polling a line sequence channel in the serial port circuit until the electronic equipment effectively communicates with the opposite terminal equipment through the network cable, namely, the line sequence to be tested is invalid, the network cable used externally is not matched with the existing line sequence of the electronic equipment, and the line sequence channel in the serial port circuit needs to be polled so as to be matched with the effective line sequence. The line sequence channels are in multiple groups, each group in the multiple groups of line sequence channels is respectively marked with different line sequences, and each group of line sequence channels comprises a sending channel and a receiving channel. For example, when the network cable type includes three types, namely a direct connection line, a cross line and a reverse line, the cable sequence may have three different situations, and the number of the groups of the cable sequence channels may be three, which is not limited herein.
S104: and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
When the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, the target line sequence adapted to the electronic equipment under the effective communication can be determined, and at the moment, the target line sequence is configured to the serial port interface, so that the compatibility of the serial port interface to the target line sequence can be realized. Therefore, on the premise that a plurality of groups of line sequence channels are compatible with various line sequences, the serial port interface can be adapted to any line sequence to ensure effective communication between the electronic equipment and the opposite terminal equipment, and correspondingly, the serial port interface can support various line sequences, so that the compatibility and the practicability of the serial port interface are realized.
In the embodiment of the present invention, as shown in fig. 3, if the electronic device is started for the first time, in step S101: before detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started, the method further comprises the following steps:
s201: determining a target line sequence channel in a gating state in a plurality of groups of line sequence channels included in the serial port circuit;
s202: and determining a line sequence corresponding to the target line sequence channel according to the corresponding relation between the line sequence channels and the line sequence, taking the line sequence corresponding to the target line sequence channel as a line sequence to be tested which can be adapted to the electronic equipment, and storing the line sequence to be tested.
In the specific implementation process, the specific implementation process from step S201 to step S202 is as follows:
firstly, the electronic device defaults to start a line sequence self-adaptive function when being started for the first time, so that the electronic device can be ensured to be adapted to a currently available line sequence, and a user can conveniently operate other functions of the electronic device, such as functions of port configuration, temperature detection and the like. After the electronic device is started for the first time and a network cable is inserted, a target line sequence channel in a gating state in a plurality of groups of line sequence channels included in the serial port circuit is determined; therefore, according to the corresponding relation between the line sequence channel and the line sequence, the line sequence corresponding to the target line sequence channel can be determined, the line sequence corresponding to the target line sequence channel is used as the line sequence to be tested which can be adapted to the electronic equipment, and the line sequence to be tested is stored. That is to say, after the electronic device is started for the first time and a network cable is inserted, the line sequence adaptive function is started by default, so that the electronic device can be ensured to be adapted to a currently available line sequence, correspondingly, a target line sequence channel in a gating state is necessarily existed, the corresponding line sequence is determined through the target line sequence channel, and the validity of the line sequence is ensured. Taking an electronic device as an example of a switch, after a serial port of the switch is used for the first time, the switch is already adapted to a currently available line sequence, and the controller obtains a value according to the gating states of a plurality of groups of line sequence channels in the line sequence channel adjusting unit, determines a line sequence corresponding to the value, and stores the line sequence. The user can be prompted through the serial port so that the user can select whether to turn off the line sequence self-adaptive function.
In the embodiment of the present invention, as shown in fig. 4, step S103: if the communication fails, polling a line sequence channel in the serial port circuit until the electronic device is effectively communicated with the opposite terminal device through the network cable, including:
s301: sampling the level state of the serial port signal from the opposite terminal equipment;
s302: if the level state indicates that the serial port signal is invalid, indicating that the electronic equipment is in invalid communication with the opposite terminal equipment under the line sequence to be tested;
s303: and polling a line sequence channel in the serial port circuit until the sampled serial port signal is effective, and stopping polling.
In the specific implementation process, the specific implementation process of steps S301 to S303 is as follows:
first, the level state of the serial port signal from the peer device is sampled, for example, the level state of the RS232_ RX pin may be monitored by a level shifting unit, and the relevant valid signal is passed through
Figure BDA0003234215090000111
Pin output, the controller through sampling
Figure BDA0003234215090000112
The level state of the pin is determined, so that the level state of the serial port signal from the opposite terminal equipment is determined(ii) a Then, according to the level state, detecting the effectiveness of communication between the electronic equipment and the opposite terminal equipment under the line sequence to be detected; if the level state indicates that the serial port signal is invalid, it indicates that the electronic device is in invalid communication with the opposite terminal device under the line sequence to be tested, and it indicates that the line sequence to be tested stored in the controller is not applicable to the current line sequence of the network cable, at this time, the controller starts polling the line sequence channels in the serial port circuit, and may be configured to start and close each group of line sequence channels in the line sequence channel adjustment unit in a polling manner until sampling is performed
Figure BDA0003234215090000121
And (5) the serial port signal corresponding to the pin is valid, and the polling is stopped. Therefore, the serial port interface is adaptively adjusted from the line sequence to be detected to the line sequence corresponding to the valid serial port signal, and the accuracy of line sequence adjustment is ensured.
It should be noted that, if it is detected that the line sequence adaptive function of the electronic device is turned on, the controller may control each group of line sequence channels in the line sequence channel adjustment unit to be turned on, and the RS232 chip in the level conversion unit monitors the level state of the RS232_ RX, and passes the relevant valid signal through
Figure BDA0003234215090000122
Pin output, the controller through sampling
Figure BDA0003234215090000123
Level signals of the pins determine whether a network cable is inserted into the serial port interface at present and continuous sampling is needed
Figure BDA0003234215090000124
Level signal of pin when detecting
Figure BDA0003234215090000125
If the signal is valid, the serial port interface is inserted with the network cable, and is normally connected with the opposite terminal equipment. At this time, each of the line-sequential channel adjusting units is turned offThe serial port interface is configured by the line sequence to be tested currently stored by the controller, and the line sequence to be tested is retested
Figure BDA0003234215090000126
Whether the level signal of the pin is effective or not, and when the level signal of the pin is ineffective, the line sequence channel in the serial port circuit is polled until the level signal is sampled
Figure BDA0003234215090000127
The level signal of the pin is valid and the polling is stopped.
In the embodiment of the present invention, if the level shift unit 4 is in the automatic power mode, in step S301: after sampling the level state of the serial port signal from the opposite terminal device, the method further comprises:
and if the level state indicates that the serial port signal is invalid, the internal power supply of the serial port circuit is closed.
If the level conversion unit is in an automatic power mode, the internal power of the level conversion unit can be automatically turned on and turned off in the automatic power mode. After the level state of the serial port signal from the opposite terminal equipment is sampled, if the serial port signal from the opposite terminal equipment comes
Figure BDA0003234215090000128
If the range of the level state of the pin indicates that the serial port signal is invalid, the serial port signal indicates that the line sequence to be tested stored in the controller is not suitable for the line sequence of the current network cable, at this time, the internal power supply of the level conversion unit can be turned off, and accordingly, the RS232 chip in the level conversion unit enters a standby low-power-consumption mode, so that the power consumption of the electronic equipment is reduced. And subsequently polling the line sequence channel in the line sequence channel adjusting unit by the controller, and awakening the RS232 chip in the level conversion unit until the serial port signal is sampled to be effective, so that the electronic equipment can communicate with the opposite terminal equipment. In addition, after the current line sequence is adjusted in a self-adaptive manner, if the serial port signal is not detected to be valid, the external serial port is disconnected, and the external serial port can be closedAnd when the internal power supply of the level conversion unit is used, all the channels of the line sequence channel adjusting unit are opened, and the next effective detection of the serial port signal is waited.
In the embodiment of the present invention, as shown in fig. 5, step S104: determining a target line sequence adapted to the electronic device under the effective communication, and configuring the target line sequence to the serial port interface, including:
s401: determining a current line sequence channel when the serial port signal is valid;
s402: storing a target line sequence corresponding to the current line sequence channel, replacing the line sequence to be detected, and taking the target line sequence as a target line sequence adapted to the electronic equipment under the effective communication;
s403: and configuring the target line sequence to the serial port interface.
In the specific implementation process, the specific implementation process of steps S401 to S403 is as follows:
firstly, determining a current line sequence channel when the serial port signal is valid, that is, determining a line sequence channel in a gating state when the serial port signal is valid, and then determining a target line sequence corresponding to the line sequence channel in the gating state according to a corresponding relation between the line sequence channel and the line sequence, wherein the target line sequence is different from the line sequence to be detected, so that the serial port interface is adapted and adjusted to a new line sequence. In addition, the target line sequence corresponding to the current line sequence channel when the serial port signal is valid may be stored, and the target line sequence may replace the last stored line sequence to be tested, so that, subsequently, when the electronic device is reinserted into a network cable, the target line sequence may be used to perform communication configuration and detection. After the target line sequence corresponding to the current line sequence channel is determined, the target line sequence can be used as the target line sequence adapted to the electronic device under the effective communication, and the target line sequence is configured to the serial port interface, so that the self-adaptive adjustment of the serial port interface to the target line sequence is ensured, the compatibility of the serial port interface is realized, and the line sequence adjustment efficiency is improved.
As shown in table 2, the table shows correspondence between the line sequence value stored in the controller, the control value of the controller to the line sequence channel adjusting unit, the channel state of the line sequence channel adjusting unit, and the line sequence.
Figure BDA0003234215090000141
TABLE 2
Taking table 2 as an example, when the controller issues a control instruction of "110" to the line sequence channel adjustment unit, the 1A-1B channel and the 2A-2B channel are controlled to be opened, and the other channels are controlled to be closed, at this time, the line sequence corresponding to the serial interface is the line sequence of "reverse line". Based on the same implementation process, other cases are not described again.
In the embodiment of the present invention, as shown in fig. 6, in step S101: after detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started, the method further comprises the following steps:
s501: if not, reading the line sequence to be tested;
s502: and configuring the line sequence to be tested to the serial port interface, and communicating with the opposite terminal equipment by adopting the line sequence to be tested.
In the specific implementation process, the specific implementation process of steps S501 to S502 is as follows:
firstly, if the self-adaptive function of the line sequence of the electronic equipment is not started, reading the line sequence to be tested, configuring the line sequence to be tested to the serial port interface, and communicating with the opposite terminal equipment by adopting the line sequence to be tested. That is to say, when the line sequence adaptive function of the electronic device is in the off state, after the network cable is inserted into the serial port interface, the currently stored line sequence to be tested of the controller can be directly used for communication. At this time, the serial interface only supports one line sequence, and the supported line sequence depends on the line sequence adaptive to the serial interface after last power-on. The situation continues until the self-adaptive line sequence function is restarted, and the line sequence self-adaptation is carried out again after the network cable is inserted into the serial port interface.
It should be noted that, if the electronic device is powered on and restarted, hardware initialization may be performed first, and in the hardware initialization process, the hardware initialization may be performed by pulling down
Figure BDA0003234215090000151
And the pin controls the level conversion unit to be in an internal power supply forced closing mode, and at the moment, the electronic equipment does not respond to an external serial port. After the hardware initialization is completed, the hardware initialization can be completed by pulling high
Figure BDA0003234215090000152
And the pin is used for pulling down the forceon pin to control the level conversion unit to be in a power mode of starting an automatic power mode, and at the moment, the level conversion unit can normally work and can carry out serial port interaction. After the level conversion unit is started, system configuration can be checked, whether the line sequence self-adaptive function is started or not is detected, and then a corresponding line sequence configuration process is carried out according to the starting condition of the line sequence self-adaptive function. Accordingly, a schematic diagram of the entire line sequence adjustment method according to the embodiment of the present invention may be as shown in fig. 7, and since each step has been described in detail in the foregoing, it is not described herein again.
Based on the same inventive concept, as shown in fig. 8, an embodiment of the present invention further provides a structural block diagram of a line sequence adjustment system of a serial port circuit 01, where the line sequence adjustment system includes:
the device comprises an opposite terminal device 30 and an electronic device 10 comprising the serial port circuit 01, wherein the serial port circuit 01 comprises a controller 1, a serial port interface 2 and a line sequence channel adjusting unit 3 respectively coupled with the controller 1 and the serial port interface 2; wherein:
the controller 1 is configured to detect whether a line sequence adaptive function of the electronic device 10 is turned on;
if the serial port interface is started, when the network cable 20 is inserted into the serial port interface, configuring a pre-stored line sequence to be tested to the serial port interface 2, and trying to communicate with the opposite terminal device 30 by adopting the line sequence to be tested;
if the communication fails, polling the line sequence channels in the line sequence channel adjusting unit 3 until the electronic device 10 effectively communicates with the opposite terminal device 30 through the network cable 20, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identifies different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface 2.
In an embodiment of the present invention, the serial port circuit further includes a level shift unit coupled between the line sequence adjustment unit and the controller, the level shift unit is configured to shift a level, and when the level shift unit is a TTL-to-RS 232 chip, the level shift unit may convert a TTL signal into an RS232 signal. In addition, the functions of each module in the serial port circuit have been described in detail in the foregoing, and are not described herein again.
Based on the same inventive concept, as shown in fig. 9, an embodiment of the present invention further provides a line sequence adjusting apparatus, where the line sequence adjusting apparatus includes a processor 100, and the processor 100 is configured to implement the following steps when executing a computer program stored in a memory 200:
detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started or not;
if the serial port circuit is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with opposite-end equipment by adopting the line sequence to be tested;
if the communication fails, polling line sequence channels in the serial port circuit until the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identify different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
Alternatively, the processor 100 may be a central processing unit, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits for controlling program execution.
Alternatively, the Memory 200 may include a Read Only Memory (ROM), a Random Access Memory (RAM), and a disk Memory. The memory 200 is used for storing data required by the processor 100 during operation, i.e. storing a computer program that can be executed by the processor 100, and the processor 100 executes the method shown in fig. 2 by executing the computer program stored in the memory 200. The number of the memory 200 is one or more, and the number of the processor 100 is one or more.
An embodiment of the present invention further provides a readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the line sequence adjustment method as described above.
The embodiment of the invention provides a method, a device, a system and a readable storage medium for adjusting a line sequence of a serial port circuit, which comprises the steps of firstly detecting whether the line sequence self-adaptive function of an electronic device comprising the serial port circuit is started, if the line sequence self-adaptive function is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, adopting the line sequence to be tested to try to communicate with an opposite terminal device, if the communication fails, polling a plurality of groups of line sequence channels in the serial port circuit until the electronic device effectively communicates with the opposite terminal device through the network cable, then determining a target line sequence adapted to the electronic device under the effective communication, then configuring the target line sequence to the serial port interface, and thus, after the line sequence self-adaptive function of the electronic device comprising the serial port circuit is started, selecting the line sequence of the serial port interface in a self-adaptive way, the serial interface can support various line sequences, and can support three network line types such as direct connection, cross connection and reversal connection, thereby realizing the compatibility and practicability of the serial interface.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may 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, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A method for adjusting the line sequence of a serial port circuit is characterized by comprising the following steps:
detecting whether a line sequence self-adaptive function of the electronic equipment comprising the serial port circuit is started or not;
if the serial port circuit is started, when a network cable is inserted into a serial port interface in the serial port circuit, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with opposite-end equipment by adopting the line sequence to be tested;
if the communication fails, polling line sequence channels in the serial port circuit until the electronic equipment is effectively communicated with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identify different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
2. The method of claim 1, wherein prior to the detecting whether a line sequence adaptation function of an electronic device including the serial port circuit is turned on, the method further comprises:
determining a target line sequence channel in a gating state in a plurality of groups of line sequence channels included in the serial port circuit;
and determining a line sequence corresponding to the target line sequence channel according to the corresponding relation between the line sequence channels and the line sequence, taking the line sequence corresponding to the target line sequence channel as a line sequence to be tested which can be adapted to the electronic equipment, and storing the line sequence to be tested.
3. The method of claim 2, wherein if the communication fails, polling a line-sequential channel in the serial port circuit until the electronic device effectively communicates with the peer device through the network cable comprises:
sampling the level state of the serial port signal from the opposite terminal equipment;
if the level state indicates that the serial port signal is invalid, indicating that the electronic equipment is in invalid communication with the opposite terminal equipment under the line sequence to be tested;
and polling a line sequence channel in the serial port circuit until the sampled serial port signal is effective, and stopping polling.
4. The method of claim 3, wherein after said sampling the level status of the serial port signal from the peer device, the method further comprises:
and if the level state indicates that the serial port signal is invalid, the internal power supply of the serial port circuit is closed.
5. The method of claim 3 or 4, wherein the determining the target line order adapted by the electronic device under the active communication and configuring the target line order to the serial port interface comprises:
determining a current line sequence channel when the serial port signal is valid;
storing a target line sequence corresponding to the current line sequence channel, replacing the line sequence to be detected, and taking the target line sequence as a target line sequence adapted to the electronic equipment under the effective communication;
and configuring the target line sequence to the serial port interface.
6. The method of claim 1, wherein after the detecting whether a line sequence adaptive function of an electronic device including the serial port circuit is turned on, the method further comprises:
if not, reading the line sequence to be tested;
and configuring the line sequence to be tested to the serial port interface, and communicating with the opposite terminal equipment by adopting the line sequence to be tested.
7. The method of claim 1, wherein after the attempting to communicate with the peer device using the wire sequence under test, the method further comprises:
and if the communication is successful, the line sequence to be tested is adopted to communicate with the opposite terminal equipment.
8. A serial port circuit line sequence adjusting system is characterized by comprising:
the device comprises an opposite terminal device and an electronic device comprising the serial port circuit, wherein the serial port circuit comprises a controller, a serial port interface and a line sequence channel adjusting unit which is respectively coupled with the controller and the serial port interface; wherein the controller is to:
detecting whether a line sequence self-adaptive function of the electronic equipment is started or not;
if the serial port interface is started, when a network cable is inserted into the serial port interface, configuring a pre-stored line sequence to be tested to the serial port interface, and trying to communicate with the opposite terminal equipment by adopting the line sequence to be tested;
if the communication fails, polling the line sequence channels in the line sequence channel adjusting unit until the electronic equipment effectively communicates with the opposite terminal equipment through the network cable, wherein the serial port circuit comprises a plurality of groups of line sequence channels, and each group of line sequence channels respectively identifies different line sequences;
and determining a target line sequence adapted to the electronic equipment under the effective communication, and configuring the target line sequence to the serial port interface.
9. A line sequence adjustment apparatus, characterized in that the line sequence adjustment apparatus comprises a processor for implementing the steps of the line sequence adjustment method according to any one of claims 1-7 when executing a computer program stored in a memory.
10. A readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the line sequence adjustment method according to any one of claims 1 to 7.
CN202110996233.1A 2021-08-27 2021-08-27 Method, device and system for adjusting line sequence of serial port circuit and readable storage medium Pending CN113709590A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110996233.1A CN113709590A (en) 2021-08-27 2021-08-27 Method, device and system for adjusting line sequence of serial port circuit and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110996233.1A CN113709590A (en) 2021-08-27 2021-08-27 Method, device and system for adjusting line sequence of serial port circuit and readable storage medium

Publications (1)

Publication Number Publication Date
CN113709590A true CN113709590A (en) 2021-11-26

Family

ID=78656069

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110996233.1A Pending CN113709590A (en) 2021-08-27 2021-08-27 Method, device and system for adjusting line sequence of serial port circuit and readable storage medium

Country Status (1)

Country Link
CN (1) CN113709590A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201985406U (en) * 2010-11-30 2011-09-21 苏州市职业大学 Multi-functional network wire connector
CN203104527U (en) * 2012-12-04 2013-07-31 深圳市双赢伟业科技股份有限公司 USB interface conversion device
CN204856482U (en) * 2015-06-16 2015-12-09 北京卓越信通电子股份有限公司 Serial ports conversion equipment that can match line preface wantonly
WO2016082563A1 (en) * 2014-11-24 2016-06-02 天地融科技股份有限公司 Universal audio adapter apparatus and electronic device
CN109359078A (en) * 2018-12-10 2019-02-19 威创集团股份有限公司 A kind of self-adapting serial port interface circuit and its control method for middle control host
CN110851386A (en) * 2019-10-24 2020-02-28 深圳市信锐网科技术有限公司 Interface configuration equipment
CN112463679A (en) * 2020-12-10 2021-03-09 苏州浪潮智能科技有限公司 Multifunctional serial port line system and PCB
CN112988642A (en) * 2019-12-16 2021-06-18 浙江宇视科技有限公司 Reverse connection preventing method for serial port signals and switch switching circuit

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN201985406U (en) * 2010-11-30 2011-09-21 苏州市职业大学 Multi-functional network wire connector
CN203104527U (en) * 2012-12-04 2013-07-31 深圳市双赢伟业科技股份有限公司 USB interface conversion device
WO2016082563A1 (en) * 2014-11-24 2016-06-02 天地融科技股份有限公司 Universal audio adapter apparatus and electronic device
CN204856482U (en) * 2015-06-16 2015-12-09 北京卓越信通电子股份有限公司 Serial ports conversion equipment that can match line preface wantonly
CN109359078A (en) * 2018-12-10 2019-02-19 威创集团股份有限公司 A kind of self-adapting serial port interface circuit and its control method for middle control host
CN110851386A (en) * 2019-10-24 2020-02-28 深圳市信锐网科技术有限公司 Interface configuration equipment
CN112988642A (en) * 2019-12-16 2021-06-18 浙江宇视科技有限公司 Reverse connection preventing method for serial port signals and switch switching circuit
CN112463679A (en) * 2020-12-10 2021-03-09 苏州浪潮智能科技有限公司 Multifunctional serial port line system and PCB

Similar Documents

Publication Publication Date Title
JP3686443B2 (en) Device and method for manipulating the power status of a remote device
KR100597734B1 (en) Memorydrive and method of controlling the same
US7895386B2 (en) USB interface provided with host/device function and its control method
US20020169915A1 (en) USB connection-detection circuitry and operation methods of the same
EP2534496B1 (en) Determination of physical connectivity status of devices based on electrical measurement
US9019968B2 (en) Method and system for managing communication ports
US6378025B1 (en) Automatic multi-mode termination
CN104054064B (en) Flexible port configuration based on interface coupling
EP2625587B1 (en) Digital rack interface pod (drip) with intelligent power control system and method
TW201202904A (en) System and method for identifying power connections in computer systems having redundant power supplies
CN112799985B (en) USB interface control method, USB control circuit and intelligent networking equipment mainboard
WO2007133038A1 (en) Apparatus and method for controlling power to usb device
CN109726059A (en) A kind of server test system
CN103530215A (en) Self-inspection method and device of inter integrated circuit host and host
CN107402893A (en) USB switching method and device, system
US20040162928A1 (en) High speed multiple ported bus interface reset control system
US20160156518A1 (en) Server for automatically switching sharing-network
CN113709590A (en) Method, device and system for adjusting line sequence of serial port circuit and readable storage medium
CN107153456A (en) OTG connections control method, OTG connection control devices and electronic equipment
US11928074B2 (en) USB active optical cable and plug capable of managing power consumption and status
CN110768851A (en) Network fault detector and detection method thereof
CN114661646A (en) Serial port switching control circuit
CN205910643U (en) Mainboard and server
CN109388216A (en) The veneer and the network equipment of starter, the network equipment
CN108090009A (en) A kind of multimachine method, apparatus of falling machine and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination