CN103024088B - Method for simultaneous communication of double serial ports - Google Patents
Method for simultaneous communication of double serial ports Download PDFInfo
- Publication number
- CN103024088B CN103024088B CN201210554371.5A CN201210554371A CN103024088B CN 103024088 B CN103024088 B CN 103024088B CN 201210554371 A CN201210554371 A CN 201210554371A CN 103024088 B CN103024088 B CN 103024088B
- Authority
- CN
- China
- Prior art keywords
- data
- serial
- request
- perform step
- communication
- 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.)
- Active
Links
Landscapes
- Information Transfer Systems (AREA)
- Communication Control (AREA)
Abstract
The invention provides a method for simultaneous communication of double serial ports. The method comprises steps of connecting a first serial port and a second serial port of a first Microprogrammed Control Unit (MCU) to a first serial port and a second serial port of a second MCU or the external first serial port and the external second serial port; detecting the working state of first serial ports and second serial ports by using a data request transmitting party when data are required to be transmitted; transmitting the data request through available ports by using the data request transmitting party in accordance with detection results; and receiving and processing the received data request by using a data receiving party. Two serial ports can conduct data communication at the same time and are independent, communication protocols of two serial ports are the consistent, the speed of serial ports and use efficiency of a central processing unit (CPU) are improved by one time, the stability of communication is greatly improved through double serial port communication, the communication is converted to one serial port when the other serial port goes wrong, and the testing efficiency of products can be improved.
Description
Technical field
The present invention relates to serial port communication technology, particularly relate to a kind of method that double-serial port communicates simultaneously.
Background technology
Serial communication is used for MCU and MCU and the data transmission between MCU and peripheral hardware, is widely used in industrial communication field.So-called serial communication refers to by data signal line, bottom line, control line etc., and a kind of communication mode transmitting data is carried out in step-by-step.The data wire that this communication mode uses is few, can save communications cost in telecommunication.Wherein, RS-232 serial communication mode has the international standard of specification because of it, and is accepted extensively by people and use, and has become the standard interface had between serial communication function equipment.
Industrial communication technology has become a most active branch of modern automation technology field development, and various new technology, agreement, standard, product, application emerge in an endless stream, and double serial port communication technology is exactly be applied to the new technology of of industrial communication field.And in most of MCU, only have a full duplex serial port, the demand that many MCU apply can not be met, the treatment effeciency of MCU can not be made full use of, there is following defect: transmission speed is slow, and efficiency is low, this is the greatest drawback of serial communication, if make parallel communications into, then cost can increase, and distance is very short, if use USB instead, then cost increase is larger; If Serial Port Line has been broken, MCU just cannot with another one MCU or peripheral hardware proper communication; Suddenly interrupted if communicated between serial ports, cannot to have judged that MCU quits work or because serial communication blocks.
Summary of the invention
In order to solve the problems of the prior art, the invention provides a kind of method that double-serial port communicates simultaneously, the method is at serial port communication technology and MIPI interface (Mobile Industry Processor Interface, mobile Industry Processor Interface) basis realizes double-serial port while communication, and the seamless switching of transfer of data can be realized between two serial ports according to the signal intelligence of serial ports, greatly improve the communication speed of serial ports and the service efficiency of CPU.
The present invention realizes goal of the invention by implementing following technical scheme: a kind of method that double-serial port communicates simultaneously, comprises the following steps:
A) first serial of a MCU, second serial are connected with the first serial of the 2nd MCU or peripheral hardware, second serial respectively;
B) when there being data to need to send, request of data transmit leg detects the operating state of first serial, second serial;
C) according to testing result, request of data transmit leg sends request of data by free serial ports;
D) data receiver receives and processes the request of data received.
As a further improvement on the present invention, described step C comprises step by step following:
C1) data that request sends are obtained;
C2) judge whether, by these data write first serial, if so, to perform step C3; Otherwise, perform step C4;
C3) by buffer area corresponding with this serial ports for the write of these data;
C4) judge whether, by these data write second serial, if so, to perform step C3; Otherwise, perform step C5;
C5) request of data terminates.
As a further improvement on the present invention, described step D comprises step by step following:
D1) detect first serial, second serial, when receiving DMA and interrupting, perform step D2;
D2) the DMA source address data received are read;
D3) judge whether these DMA data are the data that first serial receives, if so, perform step D4; Otherwise, perform step D5;
D4) also processes data requests is received;
D5) judge whether these DMA data are the data that second serial receives, if so, perform step D4; Otherwise, perform step D6;
D6) request of data terminates.
As a further improvement on the present invention, described step D4 comprises step by step following:
D4-1) detect the communications status of first serial, second serial, and judge whether to occur communication disruption, if so, perform step D4-2; Otherwise, perform step D4-8;
D4-2) judge that whether first serial is effective, if so, perform step D4-3; Otherwise, perform step D4-5;
D4-3) by these data write first serial, and data response is sent to request of data transmit leg;
D4-4) judge whether request of data transmit leg receives data response in setting-up time, if so, performs step D4-3; Otherwise, perform step D4-5;
D4-5) by these data write second serial, and data response is sent to request of data transmit leg;
D4-6) judge whether request of data transmit leg receives data response in setting-up time, if so, performs step D4-5; Otherwise, perform step D7;
D4-7) ceased communication;
D4-8) continue to receive DMA data.
As a further improvement on the present invention, described first serial or second serial are MIPI interface, and described MIPI interface comprises data wire and markings; Described data wire is used as RXD, for the reception of data; Described markings are used as TXD, for the transmission of data.
The invention has the beneficial effects as follows: two serial ports can carry out data communication simultaneously, separate, and the communication protocol of two serial ports is consistent, all supports RS232, the speed of serial ports and efficiency is all doubled, also the utilization rate of CPU be doubled; And double serial port communication also improves the stability of communication greatly, when a serial ports break can be seamless another serial ports that is switched to continue communication; In addition double serial port communication also contributes to the testing efficiency improving product, shortens the construction cycle of product.
Accompanying drawing explanation
Fig. 1 is the flow chart of the method for a kind of double serial port communication in the embodiment of the present invention;
The flow chart that Fig. 2 is first serial in the embodiment of the present invention, second serial sends data;
The flow chart that Fig. 3 is first serial in the embodiment of the present invention, second serial receives data;
Fig. 4 is reception in the embodiment of the present invention and processes data requests flow chart;
Fig. 5 is the Principle of Communication figure of serial ports of the present invention;
Fig. 6 is the double serial port communication schematic diagram in the embodiment of the present invention.
Embodiment
Illustrate below in conjunction with accompanying drawing and embodiment the present invention is further described.
In the embodiment of the method simultaneously communicated at double-serial port of the present invention, as shown in Figure 1, the method comprises the steps: the flow chart of the method
The first serial of the one MCU, second serial are connected with the first serial of the 2nd MCU or peripheral hardware, second serial by step S11 respectively: in this step, the first serial of the one MCU, second serial are connected with the first serial of the 2nd MCU or peripheral hardware, second serial respectively, first serial, second serial can be communicated simultaneously;
Step S12 is when there being data to need to send, request of data transmit leg detects the operating state of first serial, second serial: when needing when there being data to send, and request of data transmit leg (MCU or the 2nd MCU or peripheral hardware) detects the operating state (in having time or communicating) of its first serial, second serial;
Step S13 is according to testing result, and request of data transmit leg sends request of data by free serial ports: request of data side sends request of data by free serial ports (first serial or second serial) to data receiver, and concrete handling process as shown in Figure 2;
Step S14 data receiver receives and processes the request of data received: data receiver receives the request of data that also deal with data transmit leg is sent, and concrete handling process as shown in Figure 3.
For the present embodiment, above-mentioned steps S13 particular flow sheet as shown in Figure 2, comprises step by step following:
Step S301 obtains the data that request sends: obtain the data will asking to send;
Step S302 judges whether these data write first serial: in this step, judges whether that if the result judged is yes, namely first serial is in idle condition, performs step S303 by these data write first serial; Otherwise, perform step S304;
Step S303 is by buffer area corresponding with this serial ports for the write of these data: the data asking to send are write the buffer area corresponding with this serial ports, completes the transmission of data;
Step S304 judges whether these data write second serial: in this step, judges whether that if the result judged is yes, namely second serial is in idle condition, performs step S303 by these data write second serial; Otherwise, perform step S305;
Step S305 request of data terminates: the request of data terminating this.
When data are in the middle of transmitting procedure, when having again data to need request to send, by detecting the operating state judging request of data transmit leg serial ports, and utilize free serial ports (first serial or second serial) to send data, two serial ports can be made to communicate simultaneously, effectively can improve the efficiency of transmission of serial ports, also can avoid the conflict occurred between serial ports.
In the middle of practical application, when carrying out a large amount of transfer of data between a MCU and the 2nd MCU or peripheral hardware, by detecting the communications status of first serial and second serial, the transmittability of Appropriate application two serial ports, can improve the transmission speed of data and the utilance of serial ports greatly.
For the present embodiment, above-mentioned steps S14 particular flow sheet as shown in Figure 3, comprises step by step following:
Step S401 detects first serial, second serial, when receiving DMA(Direct Memory Access, direct memory access) when interrupting, perform step S402;
Step S402 reads the DMA source address data received: read the DMA source address data received;
Step S403 judges whether these DMA data are the data that first serial receives: in this step, judge whether these DMA data are the data that first serial receives, if the result judged is yes, namely request of data transmit leg sends DMA interruption by first serial to data receiver, performs step S404; Otherwise, perform step S405;
Step S404 receives and processes data requests: the data received are carried out DMA transfer of data by corresponding serial ports between a MCU and the 2nd MCU or peripheral hardware; And DMA transmission means is without the need to the direct controls transfer of CPU, Interrupt Processing Model is not had to retain process that is on-the-spot and restoring scene like that yet, original position and the data length of the data that will transmit only need be provided when starting, be RAM(random access memory by hardware, random asccess memory) open up with I/O equipment the path that is directly transmitted data, the efficiency of CPU is greatly improved;
Step S405 judges whether these DMA data are the data that second serial receives: in this step, judge whether these DMA data are the data that second serial receives, if the result judged is yes, namely request of data transmit leg sends DMA interruption by second serial to data receiver, performs step S404; Otherwise, perform step S406;
Step S406 request of data terminates: the request of data terminating this.
For the present embodiment, above-mentioned steps S404 particular flow sheet as shown in Figure 4, comprises step by step following:
Step S404-1 detects the communications status of first serial, second serial, and judge whether to occur communication disruption: in this step, detect the communications status of first serial, second serial, and judge whether to occur communication disruption, if the result judged is yes, namely interrupting appears suddenly in data in transmitting procedure, performs step S404-2; Otherwise, perform step S404-8;
Step S404-2 judges that whether first serial is effective: in this step, judges that whether first serial is effective, if the result judged is yes, performs step S404-3; Otherwise, perform step S404-5;
Step S404-3 by these data write first serial, and sends data response to request of data transmit leg;
Step S404-4 judges whether request of data transmit leg receives data response in setting-up time: in this step, judge whether request of data transmit leg receives data response in setting-up time, if the result judged is yes, explanation first serial is normal, continue through first serial to communicate, perform step S404-3; Otherwise, perform step S404-5;
Step S404-5 by these data write second serial, and sends data response to request of data transmit leg;
Step S404-6 judges whether request of data transmit leg receives data response in setting-up time: in this step, judge whether request of data transmit leg receives data response in setting-up time, if the result judged is yes, explanation second serial is normal, continue through second serial to communicate, perform step S404-5; Otherwise, illustrate that first serial and second serial all cannot communicate, be that software stops, perform step S407;
Step S404-7 ceased communication: the communication stopping this;
Step S404-8 continues to receive DMA data: continue to receive DMA data.
In the middle of the process of transmission data, if a serial ports has broken down suddenly, another serial ports that is switched to seamless for transfer of data can transmit by the present invention: first, first to inquire about this serial ports when writing data toward a certain serial ports whether effective, if invalid, sending this request of data directly to another serial ports; If effectively, then send request of data to this serial ports, and increase a timer, if data sending request side does not receive data response within the time of setting, show that the other side does not receive data, now also send this request of data directly to an other serial ports.
Certainly, in the middle of data transmission procedure, if serial communication interrupts suddenly, actually also judge that or software stops serial ports and broken by method of the present invention and transmission AT order: first communicate by being switched to another one serial ports, if can communicate, explanation occurs that the serial ports of communication disruption has been broken, and software systems are normal; Now going some parameters of inquiring about bad serial ports by sending AT order again, judging which partial destruction of this serial ports further; If be switched to another one serial ports can not communicate, explanation is that software stops, serial ports no problem (occurring that in the middle of practical application the possibility that two serial ports damage simultaneously is very little, can ignore).
Fig. 5 is the schematic diagram of serial ports, wherein,
Data:
TXD: serial data exports (Transmit Data)
RXD: serial data input (Receive Data)
Shake hands:
RTS: send request of data (Request to Send)
CTS: clear to send (Clear to Send)
DSR: data ready for sending (Data Send Ready)
DCD: data carrier detects (Data Carrier Detect)
DTR: data terminal ready (Data Terminal Ready)
Ground wire:
GND: ground wire
Other
RI: the tinkle of bells indicates
As shown in Figure 6, described first serial or second serial are MIPI interface, and described MIPI interface comprises data wire (MIPI_HSI_RX_DATA) and markings (MIPI_HSI_RX_FLG); Described data wire is used as RXD, for the reception of data; Described markings are used as TXD, for the transmission of data.
In the middle of practical application, when first serial carry out mass data (as network data) transmit time, now can not respond AT command request in time, then can respond AT command request in time by second serial.In addition, when first serial is when carrying out mass data transmission, the state transmitted by second serial reported data and the progress of transmission, the data length namely printed by second serial just can judge that whether the data that first serial receives are normal.According to application needs, the present invention can be applicable to first serial and is used for sending request, and second serial is used for response request, and this data service can be widely used in as industrial information equipment such as PLC control, gate inhibition, medical treatment, measuring instrument, LED device for display of message.
Two serial ports of the present invention can carry out data communication simultaneously, separate, and the communication protocol of two serial ports is consistent, all supports RS232, the speed of serial ports and efficiency is all doubled, also the utilization rate of CPU be doubled; And double serial port communication also improves the stability of communication greatly, when a serial ports break can be seamless another serial ports that is switched to continue communication; In addition double serial port communication also contributes to the testing efficiency improving product, shortens the construction cycle of product.
Above content is in conjunction with concrete preferred implementation further description made for the present invention, can not assert that specific embodiment of the invention is confined to these explanations.For general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, some simple deduction or replace can also be made, all should be considered as belonging to protection scope of the present invention.
Claims (4)
1. the method that simultaneously communicates of double-serial port, is characterized in that, comprise the following steps:
A) first serial of a MCU, second serial are connected with the first serial of the 2nd MCU or peripheral hardware, second serial respectively;
B) when there being data to need to send, request of data transmit leg detects the operating state of first serial, second serial;
C) according to testing result, request of data transmit leg sends request of data by free serial ports;
D) data receiver receives and processes the request of data received;
Described step D comprises step by step following:
D1) detect first serial, second serial, when receiving DMA and interrupting, perform step D2;
D2) the DMA source address data received are read;
D3) judge whether these DMA source address data are the data that first serial receives, if so, perform step D4; Otherwise, perform step D5;
D4) also processes data requests is received;
D5) judge whether these DMA source address data are the data that second serial receives, if so, perform step D4; Otherwise, perform step D6;
D6) request of data terminates.
2. method according to claim 1, is characterized in that: described step C comprises step by step following:
C1) data that request sends are obtained;
C2) judge whether, by these data write first serial, if so, to perform step C3; Otherwise, perform step C4;
C3) by buffer area corresponding with this serial ports for the write of these data;
C4) judge whether, by these data write second serial, if so, to perform step C3; Otherwise, perform step C5;
C5) request of data terminates.
3. method according to claim 2, is characterized in that: described step D4 comprises step by step following:
D4-1) detect the communications status of first serial, second serial, and judge whether to occur communication disruption, if so, perform step D4-2; Otherwise, perform step D4-8;
D4-2) judge that whether first serial is effective, if so, perform step D4-3; Otherwise, perform step D4-5;
D4-3) by these data write first serial, and data response is sent to request of data transmit leg;
D4-4) judge whether request of data transmit leg receives data response in setting-up time, if so, performs step D4-3; Otherwise, perform step D4-5;
D4-5) by these data write second serial, and data response is sent to request of data transmit leg;
D4-6) judge whether request of data transmit leg receives data response in setting-up time, if so, performs step D4-5; Otherwise, perform step D4-7;
D4-7) ceased communication;
D4-8) continue to receive DMA data.
4. the method according to any one of claims 1 to 3 claim, is characterized in that: described first serial or second serial are MIPI interface, and described MIPI interface comprises data wire and markings; Described data wire is used as RXD, for the reception of data; Described markings are used as TXD, for the transmission of data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210554371.5A CN103024088B (en) | 2012-12-19 | 2012-12-19 | Method for simultaneous communication of double serial ports |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210554371.5A CN103024088B (en) | 2012-12-19 | 2012-12-19 | Method for simultaneous communication of double serial ports |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103024088A CN103024088A (en) | 2013-04-03 |
CN103024088B true CN103024088B (en) | 2015-04-22 |
Family
ID=47972210
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210554371.5A Active CN103024088B (en) | 2012-12-19 | 2012-12-19 | Method for simultaneous communication of double serial ports |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103024088B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI505247B (en) * | 2013-09-10 | 2015-10-21 | Himax Tech Ltd | Alignment system and method for a display serial interface |
CN106528476A (en) * | 2016-11-24 | 2017-03-22 | 微鲸科技有限公司 | Circuit capable of automatically realizing cross and direct connection serial port switching |
CN108985104B (en) * | 2018-07-20 | 2022-01-21 | 南昌黑鲨科技有限公司 | Encryption method of intelligent terminal and intelligent terminal |
CN112737789A (en) * | 2020-12-23 | 2021-04-30 | 上海芯钛信息科技有限公司 | Method for realizing high-speed cryptographic operation of vehicle-mounted communication gateway based on two-way SPI (Serial peripheral interface) concurrency |
CN115022163A (en) * | 2022-05-30 | 2022-09-06 | 深圳市遇贤微电子有限公司 | Log collection method and device, computer equipment and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN2879547Y (en) * | 2006-04-13 | 2007-03-14 | 华为技术有限公司 | Elastic grouping ring processing plate, back plate and nodes |
CN102082695A (en) * | 2011-03-07 | 2011-06-01 | 中控科技集团有限公司 | Hot standby redundancy network system and redundancy realization method |
CN202257553U (en) * | 2011-04-08 | 2012-05-30 | 昆明华奥航星电气有限公司 | Protocol converter for converting universal serial port to MODBUS |
CN202372976U (en) * | 2011-12-15 | 2012-08-08 | 福建鑫诺通讯技术有限公司 | Switching circuit of time-share multiplexing serial port |
CN102759891A (en) * | 2012-06-07 | 2012-10-31 | 中国航天科技集团公司第九研究院第七七一研究所 | Hard handover dual-redundancy CAN controller |
-
2012
- 2012-12-19 CN CN201210554371.5A patent/CN103024088B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN2879547Y (en) * | 2006-04-13 | 2007-03-14 | 华为技术有限公司 | Elastic grouping ring processing plate, back plate and nodes |
CN102082695A (en) * | 2011-03-07 | 2011-06-01 | 中控科技集团有限公司 | Hot standby redundancy network system and redundancy realization method |
CN202257553U (en) * | 2011-04-08 | 2012-05-30 | 昆明华奥航星电气有限公司 | Protocol converter for converting universal serial port to MODBUS |
CN202372976U (en) * | 2011-12-15 | 2012-08-08 | 福建鑫诺通讯技术有限公司 | Switching circuit of time-share multiplexing serial port |
CN102759891A (en) * | 2012-06-07 | 2012-10-31 | 中国航天科技集团公司第九研究院第七七一研究所 | Hard handover dual-redundancy CAN controller |
Also Published As
Publication number | Publication date |
---|---|
CN103024088A (en) | 2013-04-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103024088B (en) | Method for simultaneous communication of double serial ports | |
EP2676204B1 (en) | Serial interface | |
WO2007131101A2 (en) | Adapter to convert usb device into wireless usb device | |
US5958024A (en) | System having a receive data register for storing at least nine data bits of frame and status bits indicating the status of asynchronous serial receiver | |
WO2018182949A1 (en) | System and method for sending in band interrupt messages between devices on a bus | |
CN109739786A (en) | A kind of dma controller and isomery acceleration system | |
CN102156680B (en) | The host apparatus of multiple connector and transmission data method and agreement selecting arrangement | |
CN104104412A (en) | Direct memory access (DMA) based power line network system and communication method thereof | |
US8788734B2 (en) | Methods and devices for universal serial bus port event extension | |
US20150263793A1 (en) | Wireless device and near-field wireless communication method | |
JP5624997B2 (en) | Communication protocol for sharing memory resources among multiple components of a device | |
CN203933621U (en) | A kind of HID blue tooth voice communicator | |
KR20050010906A (en) | Bus system, station for use in a bus system, and bus interface | |
RU2510142C2 (en) | Method and system for transmitting message between extended processor and switch circuit | |
CN103856228A (en) | Wireless human-computer interaction method and system | |
CN108954702A (en) | A kind of control method of air-conditioning, device, air-conditioning and storage medium | |
CN106792466B (en) | Method for communication between equipment end and host end | |
US9619005B2 (en) | Apparatus and method for saving power of USB device | |
CN111930645B (en) | TCPIP-based universal USB equipment network transparent transmission system and method | |
CN104735821B (en) | A kind of wireless network card and its implementation turning serial port function with USB | |
WO2012019376A1 (en) | Method and apparatus for implementing network device function of wireless communication terminal | |
CN205405146U (en) | Control system of robot | |
CN203859747U (en) | Bluetooth communication card | |
JP3419385B2 (en) | Monitor system for portable wireless telephone device, portable wireless telephone device, monitor device, and method for monitoring portable wireless telephone device | |
WO2012151897A1 (en) | Method and device for switching between storage element and expansion element on mobile terminal |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
C56 | Change in the name or address of the patentee |
Owner name: SHENZHEN FIBOCOM WIRELESS INC. Free format text: FORMER NAME: SHENZHEN G+T INDUSTRIAL DEVELOPMENT CO., LTD. |
|
CP01 | Change in the name or title of a patent holder |
Address after: 518000 No. 501, building A, two, science and technology building, 1057 Nanhai Road, Guangdong, Shenzhen Patentee after: FIBOCOM WIRELESS INC. Address before: 518000 No. 501, building A, two, science and technology building, 1057 Nanhai Road, Guangdong, Shenzhen Patentee before: Shenzhen G&T Industrial Development Co., Ltd. |