Serial port switching device and method suitable for X.25 interface
Technical Field
The invention belongs to the technical field of data communication, and particularly relates to a serial port switching device and method suitable for an X.25 interface.
Background
The civil aviation air traffic control automation system can realize coordination and handover of control data between the civil aviation air traffic control automation system and an adjacent control center through inputting and outputting AIDC messages according to the specification. The aid id message transmission generally adopts an x.25 interface mode, and when actually deployed, an upstream system needs to be connected to 2 sets of downstream systems (A, B), and flexible switching between the systems A, B is required.
The x.25 protocol is an interface procedure between Data Terminal Equipment (DTE) and data circuit terminating equipment (DCE); the x.25 protocol is still widely used in wide area packet switched networks today.
Since x.25 is a connection-oriented protocol, one-to-two connection and link switching cannot be realized by a common serial port switch. Meanwhile, the common line switcher cannot process the serial port control pin according to the characteristics of the x.25 protocol, which may cause the upstream interface to not sense the change of the serial port state in time in the switching process, and prevent the reconstruction of the x.25 link. Therefore, it is necessary to invent a serial port switching device suitable for the x.25 interface.
The X.25 protocol adopts a layered architecture and is divided into three layers from bottom to top: the physical layer, the data link layer and the packet layer correspond to the lower three layers of the OSI reference model, respectively. The invention works in the physical layer and realizes the switching connection between the physical interfaces of the upstream and downstream X.25 equipment.
Disclosure of Invention
In view of the above deficiencies of the prior art, an object of the present invention is to provide a serial port switching device and method suitable for an x.25 interface, so as to solve the problem that the prior art cannot switch a data pin, a timing pin and a control pin in a serial port and quickly trigger an x.25 link reestablishment according to the characteristics of an x.25 protocol.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
the invention relates to a serial port switching device suitable for an X.25 interface, which comprises: the device comprises a shell and two serial port switching units arranged in the shell; the serial port switching unit comprises an uplink port, two downlink ports, three level conversion chips, an alternative gating module, a microcontroller, a panel key, a status indicator lamp and a control serial port;
the panel key and the status indicator lamp are arranged on the front panel of the shell;
the uplink port, the two downlink ports and the control serial port are arranged on the rear panel of the shell;
the uplink port and the two downlink ports are respectively electrically connected with a level conversion chip, and the three level conversion chips and the microcontroller are electrically connected with the alternative gating module;
the two-choice gating module is composed of a group of pin gating units, each pin gating unit corresponds to one pin of the uplink port and the downlink port, and the two-choice gating module allows data, timing and control signals of a selected channel to pass through according to the control of the microcontroller;
the microcontroller is electrically connected with the panel key, the status indicator lamp and the control serial port respectively; the microcontroller is connected with the panel keys through the general I/O port and reads the key states; a connection status indicator lamp for controlling the on/off status of the indicator lamp; connecting an alternative-to-alternative gating module and setting a gating state; the microcontroller is connected with the control serial port to receive commands and output states.
Furthermore, the uplink port is a DB-25M connector, the downlink port is a DB-25F connector, and the control serial port is an RJ-45 connector.
Further, the panel keys comprise a manual/command setting key and a channel selection key.
Further, the status indicator lamps comprise a manual/command setting status indicator lamp, a channel selection status indicator lamp, a signal uplink status indicator lamp and a signal downlink status indicator lamp.
Furthermore, the device also comprises a time delay setting dial switch which is electrically connected with the microcontroller.
Further, the processing flow of the microcontroller comprises: initializing, processing keys and serial ports and switching channels;
in the initialization stage, the microcontroller reads the state of a dial switch to obtain the time delay; the microcontroller controls the alternative gating module to enable the main channel to be connected with the channel A, the initial channel selection mode is a command mode, and the initial channel selection state is the channel A;
in the operation process, the panel key informs the microcontroller in an interruption mode and triggers the key state reading, and the microcontroller receives a control command through a control serial port; when the manual/command button is triggered, a new channel selection mode is set; when the channel selection key is triggered, if the current channel selection mode is a manual mode, setting a new A, B channel selection result; when a channel selection instruction is read from the control serial port and the current channel selection mode is a command mode, setting a new A, B channel selection result;
if the new channel selection result is inconsistent with the current state, the microcontroller performs channel switching processing; and the microcontroller sends a gating signal to enable the two-way gating module to connect each pin of the main channel with a signal ground, after waiting for a preset time, the microcontroller sends the gating signal again to enable the two-way gating module to communicate each pin of the main channel with the corresponding pin of the selected channel A or B, and after the channel switching is finished, the microcontroller sets a state indicator lamp according to a new channel selection result.
The invention relates to a serial port switching method suitable for an X.25 interface, which comprises the following steps:
in the initialization stage, the microcontroller reads the state of a dial switch to obtain the time delay; the microcontroller controls the alternative gating module to enable the main channel to be connected with the channel A, the initial channel selection mode is a command mode, and the initial channel selection state is the channel A;
in the operation process, the panel key informs the microcontroller in an interruption mode and triggers the key state reading, and the microcontroller receives a control command through a control serial port; when the manual/command button is triggered, a new channel selection mode is set; when the channel selection key is triggered, if the current channel selection mode is a manual mode, setting a new A, B channel selection result; when a channel selection instruction is read from the control serial port and the current channel selection mode is a command mode, setting a new A, B channel selection result;
if the new channel selection result is inconsistent with the current state, the microcontroller performs channel switching processing; and the microcontroller sends a gating signal to enable the two-way gating module to connect each pin of the main channel with a signal ground, after waiting for a preset time, the microcontroller sends the gating signal again to enable the two-way gating module to communicate each pin of the main channel with the corresponding pin of the selected channel A or B, and after the channel switching is finished, the microcontroller sets a state indicator lamp according to a new channel selection result.
The serial port switching unit in the device of the invention provides two channel switching modes: a manual switching mode and a command switching mode; when the manual switching mode is set through the panel keys, the channel selection keys are arranged on the channel A to indicate that the channel A is communicated with the main channel, and the channel selection keys are arranged on the channel B to indicate that the channel B is communicated with the main channel. When the command switching mode is set through the manual/command key, the selection of the A/B channel is set by the command received by the control serial port. Under the two channel switching modes, the channel switching mode has an intermediate state with the set time length, each pin of the main channel is connected with the signal ground, and the microcontroller finishes the setting of the time delay time length by reading the state of the time delay setting dial switch.
The invention can appoint the uplink port to communicate with the downlink port A or B in a manual or command mode, and meet the transmission requirement of an X.25 protocol; meanwhile, an intermediate state with a specified duration is added in the switching process, so that the external X.25 interface equipment can detect the change of the interface state in time and reset the X.25 logical link.
The channel switching is actually 1 to 3 gating logic inside the device; during switching, under the control of a selection signal, the main channel is firstly communicated with a signal ground, so that a pin of the main channel is in a logic off state; the intermediate state is maintained for a certain time, and the time is set by a delay setting dial switch; in the intermediate state, the external device corresponding to the main channel detects the change of the interface state and resets the X.25 logical link; after the intermediate state, the main channel will communicate with either the a channel or the B channel under the control of the select signal.
The invention has the beneficial effects that:
each serial port switching unit of the device can make one upstream X.25 interface and two downstream X.25 interfaces switched and connected, and support two switching modes of manual operation and command.
The channel switching process of the invention has an intermediate state with settable duration, during which the pin of the uplink port is connected with signal ground, so that the external device can detect the change of the port state, immediately reset and try to reestablish the X.25 link.
The invention can display detailed working state and port signal transmission state through the panel indicator light.
Drawings
FIG. 1 is a logic structure diagram of a serial port switching unit according to the present invention;
FIG. 2 is a schematic diagram of a pin strobe unit;
FIG. 3 is a flow chart of a channel switching process;
FIG. 4 is a schematic view of a front panel according to the present invention;
fig. 5 is a schematic view of a rear panel according to the present invention.
Detailed Description
In order to facilitate understanding of those skilled in the art, the present invention will be further described with reference to the following examples and drawings, which are not intended to limit the present invention.
Referring to fig. 1, a serial port switching device suitable for an x.25 interface of the present invention includes: the device comprises a shell and two serial port switching units arranged in the shell; the serial port switching unit comprises an uplink port (main channel), two downlink ports (A, B channels), three level conversion chips, an alternative gating module, a Microcontroller (MCU), a panel key, a status indicator lamp and a control serial port;
the panel key and the status indicator lamp are arranged on the front panel of the shell;
the uplink port, the two downlink ports and the control serial port are arranged on the rear panel of the shell;
the uplink port and the two downlink ports are respectively electrically connected with a level conversion chip, and the three level conversion chips and the microcontroller are electrically connected with the alternative gating module;
the microcontroller is electrically connected with the panel key, the status indicator lamp and the control serial port respectively.
The signals (RXD, RXC1, RXC2, CTS, DSR, DCD) entered by the main channel are input to the one-out-of-two gating module after level conversion, and corresponding signals (TXD, TXC1, TXC2, CTS, DSR, DCD) are output from the A or B channel according to the gating state (through level conversion).
Signals (RXD, RXC, RTS and DTR) entering from the A, B channel are input into the alternative gating module after level conversion, signals of the channel A or the channel B pass through according to the gating state, and corresponding signals (TXD, TXC, RTS and DTR) are output from the main channel after level conversion.
As shown in fig. 2, the one-out-of-two gating module is composed of a group of pin gating units, and each pin gating unit corresponds to one path of pin signals; under the control of the selection signal, the main pin can be connected with one of the pin A, the pin B or the ground pin, so that the electric signal passes through; a Microcontroller (MCU) allows data, timing and control signals of the selected channel to pass through under a set condition by controlling a pin gating unit; when the local connection is connected with the main channel, the data and timing signal transmission of the main channel is blocked, and the control signal is in an OFF state.
The serial port switching unit provides two channel switching modes: a manual switching mode and a command switching mode; when the manual switching mode is set through the panel keys, the channel selection keys are arranged on the channel A to indicate that the channel A is communicated with the main channel, and the channel selection keys are arranged on the channel B to indicate that the channel B is communicated with the main channel. When the command switching mode is set through the manual/command key, the selection of the A/B channel is set by the command received by the control serial port.
Under the two channel switching modes, the channel switching has an intermediate state of appointed time length, and the time length can be set through a time delay setting dial switch. The intermediate state places each pin of the main channel port in a grounded state, thereby causing the external device connected to the corresponding port to detect the port failure and reset the corresponding x.25 link.
FIG. 3 is a flow chart of channel switching processing, wherein the processing flow of the microcontroller includes three parts, namely initialization, key and serial processing, and channel switching processing;
in the initialization stage, the microcontroller reads the state of a dial switch to obtain the time delay; meanwhile, the microcontroller controls the alternative gating module to enable the main channel to be connected with the channel A, the initial channel selection mode is a command mode, and the initial channel selection state is the channel A;
in the operation process, the panel key informs the microcontroller in an interruption mode and triggers the key state reading, and meanwhile, the microcontroller receives a control command through a control serial port; when the manual/command button is triggered, a new channel selection mode is set; when the channel selection key is triggered, if the current channel selection mode is a manual mode, setting a new A, B channel selection result; when a channel selection instruction is read from the control serial port and the current channel selection mode is a command mode, setting a new A, B channel selection result;
if the new channel selection result is inconsistent with the current state, the microcontroller performs channel switching processing; and the microcontroller sends a gating signal to enable the two-way gating module to connect each pin of the main channel with a signal ground, after waiting for a preset time, the microcontroller sends the gating signal again to enable the two-way gating module to communicate each pin of the main channel with the corresponding pin of the selected channel A or B, and after the channel switching is finished, the microcontroller sets a state indicator lamp according to a new channel selection result.
Fig. 4 is a schematic view of a front panel, on which: manual/command setting keys and status indicator lamps, channel selection keys and status indicator lamps, signal uplink status indicator lamps and signal downlink status indicator lamps.
And pressing a manual/command setting key, reading key input by the MCU, and setting the channel switching mode into a manual switching mode or a command switching mode. When the manual switching mode is set, the manual indicator light is normally on, and the command indicator light is not on; when the command switching mode is set, the command indicator lamp is normally on, and the manual indicator lamp is not on.
When the manual switching mode is set, the channel selection key is pressed, the MCU reads the key input and sets the main channel to be communicated with the channel A or the channel B. When the main channel is communicated with the channel A, the indicator light A is always on, and the indicator light B is not on; when the main channel is communicated with the channel B, the indicator light B is always on, and the indicator light A is not on.
When the command switching mode is set, the serial port switching unit receives a switching command through the control serial port of the rear panel to select A, B channels.
FIG. 5 is a rear panel schematic with the main channel being a DB-25M connector, DTE interface mode; A. the channel B is a DB-25F connector and a DCE interface mode; the control serial port is an RJ-45 connector, and is specifically shown in the following tables 3 to 5:
TABLE 3
Pin number
|
(symbol)
|
Definition of
|
Direction of transmission
|
2
|
TXD
|
Data output
|
Sending
|
3
|
RXD
|
Data entry
| Receiving |
|
4
|
RTS
|
Request sending
| Sending |
|
5
|
CTS
|
Allowing transmission
| Receiving |
|
6
|
DSR
|
Data device ready
| Receiving |
|
7
|
GND
| Signal ground |
|
|
8
|
DCD
|
Carrier detection
| Receiving |
|
15
|
RXC1
|
Clock input
|
Receiving
|
17
|
RXC2
|
Clock input
|
Receiving
|
20
|
DTR
|
Data terminal ready
|
Sending
|
24
|
TXC
|
Clock output
|
Sending |
TABLE 4
Pin number
|
(symbol)
|
Definition of
|
Direction of transmission
|
2
|
RXD
|
Data entry
|
Receiving
|
3
|
TXD
|
Data output
| Sending |
|
4
|
RTS
|
Request sending
| Receiving |
|
5
|
CTS
|
Allowing transmission
| Sending |
|
6
|
DSR
|
Data device ready
| Sending |
|
7
|
GND
| Signal ground |
|
|
8
|
DCD
|
Carrier detection
|
Output of
|
15
|
TXC1
|
Clock output
| Sending |
|
17
|
TXC2
|
Clock output
| Sending |
|
20
|
DTR
|
Data terminal ready
|
Receiving
|
24
|
RXC
|
Clock input
|
Receiving |
TABLE 5
Pin number
|
(symbol)
|
Definition of
|
Direction of transmission
|
3
|
GND
| Signal ground |
|
|
4
|
RXD
|
Data entry
| Receiving |
|
5
|
TXD
|
Data output
|
Sending |
Table 3 is a main channel signal pin definition table, table 4 is an A, B channel signal pin definition table, and table 5 is a control serial pin definition table.
While the invention has been described in terms of its preferred embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention.