The method and the device for carrying out said thereof of transmission asynchronous serial-port data
Technical field
The present invention relates to the communications field, relate in particular to the method and apparatus that passes through the multiple speed asynchronous serial-port data of synchronization channel transmissions in the communications field.
Background technology
In modern communication systems, the distance of carrying out communication between the asynchronous serial port equipment is very limited, and the communication of long distance is normally finished by the 2M circuit.Can utilize time slot in the 2M circuit to transmit the data of asynchronous serial port communication? promptly need asynchronous serial-port data is suitably changed, so that transmit by the 2M circuit.Traditional data transferring method is: CPU is by self serial ports or reception of expansion serial ports and transmission serial data, and CPU extracts or send the data of certain time slot in the HW line by the HDLC chip.The HW link tester is crossed the E1 interface chip and is become the E1 signal and transmit.Though above scheme is feasible, there are many weak points:
1) this scheme need take carrying serial ports or expanding serial ports of CPU.The serial ports that general CPU carries seldom is mainly used to do the modules configured mouth and uses.If device externally needs serial ports more, that just need add the serial ports of a lot of expansions, the hardware cost height, and very too fat to move.
2) on software, the serial ports transceive data of CPU need take the processing time of CPU, if serial ports reach three or more than, then the real-time to CPU has bigger influence.
3) also need the HDLC protocol controller on the hardware, the hardware cost height, and need software to cooperate, and influence system real time, system reliability is reduced.
Can we allow serial data without CPU, and directly go in the time slot through hardware path arrival 2M circuit?
Summary of the invention
The objective of the invention is to solve serial data carries out real-time Transmission by synchronous 2M circuit problem in order to overcome above-mentioned shortcoming of the prior art.Because in the present invention, asynchronous serial port can use any effective value in certain communication baud rate scope to install and the devices communicating that is connected by this, and do not need the changed serial port parameter configuration, that is to say that these data can transmit pellucidly, and do not have any change, so be called " transparent " serial ports.
For achieving the above object, the technical solution used in the present invention is:
A kind of method of transmitting asynchronous serial-port data comprises the following steps:
The HW line comes out the data separating of HW circuit time slot to the serial ports modular converter, and is sent to serial ports and distributes control module;
Serial ports distributes serial ports the signal of control module output to be sent to HW circuit time slot behind over-sampling to HW line modular converter;
The clock processing module is transformed into the clock signal that each module needs to the clock signal of outside input, and outputs to each module;
The serial data of the input HW line that communication watchdog module monitoring is extracted in the time slot if the data of this time slot are zero for a long time, then cuts off this data of transparent mouthful, when data revert to high level, recovers output.
Each step of front, wherein said serial ports is as follows the process that is sent to HW circuit time slot after the serial data sampling to HW line modular converter: adopt the clock of 32kHz that serial data is sampled, and go here and there and change, latch, also go here and there and change, with time slot dateout in appointment.It is identical with it that the HW line is separated the process that is sent to serial ports to the serial ports modular converter with HW line time slot data, but need the transposing clock signal.
Described clock processing module the 8kHz of outside input and 4MHz clock signal be transformed into the HW line to serial ports modular converter, serial ports to the needed 8K of HW line modular converter, 32K, 2M clock signal, reach the needed 8K clock signal of communication watchdog module.
Described transmission serial ports distributes control module, receives two control signals of serial ports distribution control module according to each serial ports, and control far-end serial ports is connected with corresponding local serial ports.
A kind of device for carrying out said that transmits the method for asynchronous serial-port data distributes control module to constitute to serial ports modular converter, serial ports to HW line modular converter, clock processing module, communication watchdog module and two serial ports by the HW line.The HW line connects the input of HW line and outputs to serial ports distribution control module to the serial ports modular converter, and the serial ports that is sent by control distributes control module to export; The HW line also links to each other with the communication watchdog module to the serial ports modular converter.Asynchronous serial-port data is input to and receives serial ports distribution control module, and the serial ports that is received by control distributes control module input serial ports to HW line modular converter again, and outputs to the HW line by serial ports to HW line modular converter.The clock processing module provide respectively the HW line to serial ports modular converter, serial ports to HW line modular converter, clock processing module, the required clock signal of communication watchdog module, simultaneously provide time slot selection signal to serial ports modular converter, serial ports to HW line modular converter to the HW line.
Said apparatus, wherein said HW line is made up of deserializer spare, parallel-to-serial converter spare and latch to the serial ports modular converter.HW line, time slot select signal, 2M clock signal to be input to deserializer spare, output to latch through deserializer spare, output to parallel-to-serial converter spare by latch again, are exported to serial ports by parallel-to-serial converter spare at last.Latch connects the 8K clock, and parallel-to-serial converter spare connects 8K, 32K clock.
Described serial ports selects module to form to HW line modular converter by deserializer spare, parallel-to-serial converter spare, latch and time slot.Serial ports, 32K clock signal are input to deserializer spare, output to latch through deserializer spare 301, output to parallel-to-serial converter spare by latch again, and last parallel-to-serial converter spare selects module to export to the HW line through time slot.Latch connects the 8K clock, and parallel-to-serial converter spare connects 8K, 2M clock, and time slot is selected module to connect time slot and selected signal.
The HW line distributes control module to be realized by FPGA or EPLD to serial ports modular converter, serial ports to HW line modular converter, clock processing module, communication watchdog module and serial ports.
The device for carrying out said of the method for described transmission asynchronous serial-port data connects 3 local serial ports and 12 far-end serial ports.
Adopt the method for the invention and device, compared with prior art, asynchronous RS232, RS422 serial data can be passed through synchronization channel transmissions.Asynchronously realize by hardware fully to synchronous conversion, thereby can solve original employing CPU effectively and add problems such as cost height, real-time that HDLC chip and serial port chip bring are poor, reliability is low, the asynchronous interface that can adapt to different rates, need not dispose communications parameter, realize that hardware is transparent completely, real-time is improved a lot,, and reduce system cost than the reliability height of software realization mode.
Description of drawings
Fig. 1 adopts the present invention to realize the block diagram of a HW line and two transparent serial ports conversions, wherein realizes the conversion of transparent serial ports and HW in 102.
Fig. 2 is the schematic diagram that transparent serial ports and HW change 102 refinements among Fig. 1, wherein most importantly HW to serial ports modular converter 201 and serial ports to 202 two submodules of HW modular converter;
Fig. 3 is the process schematic diagram that HW line data transaction arrives serial ports 201 refinements among Fig. 2;
Fig. 4 is that serial data is transformed into the process schematic diagram of serial ports to 202 refinements of HW modular converter among Fig. 2;
Fig. 5 is the 8K clock (CLK8K) imported among Fig. 2 and the phase relation of 4M clock (CLK4M) signal;
Fig. 6 is the clock signal phase relation of clock processing module 206 input and output among Fig. 2;
Fig. 7 is watchdog module 205 block diagrams among Fig. 2;
Fig. 8 sends serial ports distribution module 203 block diagrams among Fig. 2;
Fig. 9 receives serial ports distribution module 204 block diagrams among Fig. 2.
Embodiment
Below in conjunction with embodiment and accompanying drawing, further specify the present invention.
Method and apparatus by 2M circuit real-time Transmission asynchronous " transparent " serial data of the present invention is made up of following a few part main functional modules as shown in Figure 1:
A. the serial ports level switch module 101
B. serial ports and HW signal conversion module 102
C.E1 interface module 103
Serial ports level switch module 101 provides the corresponding interface level according to different external serial ports (RS232 or RS422);
E1 interface module 103 is carried out the serial ports time gas exchange, and realizes the HW signal of 2M speed and the mutual conversion of standard E1 signal;
Serial ports and HW signal conversion module 102 are cores of the present invention, and it adopts EPLD or FPGA device as hardware carrier.Its basic principle is with clock Direct Sampling serial data, is put into the HW line then and gets on; In like manner, also use clock sampling HW line (synchronously), then data are put into serial ports and get on.
By Fig. 3 and Fig. 4 as seen, transfer process mainly needs deserializer spare 301, latch 302, parallel serial conversion module 303, time slot to select modules such as module 304, and wherein important signal is to need to produce time slot to select signal and clock signal.
Described in detail below in conjunction with concrete application example.
To the data of two serial ports of some time slot insertions in each 2M line, that is to say that each transparent mouth accounts for time slot half.Known that by sampling thheorem when each serial ports during with half slot transmission, the speed of design serial ports reaches as high as 32k/2=16k (bit/s), actually support that the serial ports flank speed is 14.4kbit/s, this is enough for most of application scenarios.Preceding 6 time slots to a HW line extract and insert now, and promptly a module can be finished 12 transparent mouthful conversion.Because a local serial ports scans transparent mouthful of a plurality of far-ends possibly, so design now can all be assigned to one of them local mouthful with the data (promptly 12 transparent mouthful) of 6 time slots, also can be only will be wherein half time slot (promptly wherein 1 transparent mouthful) be assigned to one of them local mouthful, transparent mouthful of data allocations that can also any several time slots is to one of them local mouth.After consideration, now the serial ports of this locality as 3, to satisfy the needs that distribute 12 transparent mouthful of far-end arbitrarily.
By Fig. 2 theory diagram as can be seen, this module comprises 6 submodules, and these 6 submodules are finished specific function respectively, and the function of each module is as follows:
The HW line is to serial ports modular converter 201: the data separating of 6 time slots of the time slot 0~time slot 5 of HW line (12 transparent mouthful) is come out, and be sent to the serial ports that control sends and distribute control module 203.
Serial ports is to HW line modular converter 202: receiving 12 road rs 232 serial interface signals that serial ports distributes control module 204 outputs are sent to the HW line behind over-sampling time slot 0~time slot 5.
The core of above-mentioned two submodules mainly is made up of deserializer spare 301 and parallel-to-serial converter spare 303, also comprises latch 302 simultaneously.The input data transaction of serial ports is as follows to the process on the HW line: the clock of 32kHz is sampled to serial data, sampling is to realize by 301 strings and conversion, the clock of string and conversion is 32kHz, promptly (125us) samples 4 times in the time of a frame, first sampled point in one frame in the 8kHz frame synchronizing signal more after a while, and the sampled data in the former frame is latched with frame synchronizing signal, come these data to be got in the parallel-to-serial converter spare 303 in next frame synchronizing signal temporarily, 303 clock is 2MHz, by the output of time slot selection 304 control clocks, can be in the time slot dateout of appointment.Just produced the conversion time delay of a frame (125 μ s) like this between input and output, this is to not influence of data communication.Oppositely as the same, only clock is swapped round.
Clock processing module 206: the 8K clock signal of outside input and 4M clock signal are transformed into the clock signal that each module needs, comprise the HW line to serial ports modular converter 201, serial ports to HW line modular converter 202, communication watchdog module 205, to clock signal 8kHz and 4MHz from the outside, cooperate with unit such as door or door and not gates with d type flip flop and to finish adjustment each clock, reach requirement as shown in Figure 6, wherein C4M and C8K are input signal, and all the other are output signal.
Communication watchdog module 205: 12 transparent mouthful of data to input HW line are monitored, if wrong, then output are changed to normal condition.The communication house dog mainly is the data status that monitoring is extracted in the time slot, respectively the data of 12 transparent mouthful of time slots are monitored, if the data of this time slot long-time (being decided to be 2 seconds in this module) are zero, then cut off this data of transparent mouthful, when data revert to high level, recover output, so just can realize the function of communication house dog.
Serial ports distributes control module: it is divided into control serial ports
distribution control module 203 that sends and the serial ports that control receives and distributes
control module 204, finishes respectively on 12 transparent mouth data allocations to 3 serial ports and 3 serial datas being assigned on 12 transparent mouths.Each control signal of transparent mouthful needs two, and signal selects to be defined as follows table:
| This transparent mouth is assigned to serial ports 1 | This transparent mouth is assigned to serial ports 2 | This transparent mouth is assigned to serial ports 3 | This transparent mouth is not assigned to any serial ports |
Bit1 | ??“0” | ??“0” | ??“1” | ??“1” |
Bit2 | ??“0” | ??“1” | ??“0” | ??“1” |
12 transparent mouthful needs 24 control lines altogether, and this line can link to each other with cpu i/f, also can link to each other with the dial-up of hardware, that is to say and can softly control, and also can control firmly.This module comprises two submodules: the serial ports that the serial ports that control sends distributes control module 203 and control to receive distributes control module 204.Because comprise 12 transparent mouthful data in the time slot 0~time slot 5 on a pair of HW line that links to each other of module therewith, but the external serial ports of this module has only designed 3, so these 12 transparent mouthful can not take a serial ports separately separately, and will one or more transparent mouthful be assigned on the external serial ports, that is to say with 3 external serial ports and link to each other with 12 transparent mouthful, for this reason, each transparent mouth has used 2 control line Bit1 and Bit2 to realize this distribution of transparent mouthful (12 transparent mouth totally 24 control lines), as Fig. 8 and shown in Figure 9, the logic in the module has mainly been used 2-4 decoder and data distributor and gate.