CN1570899A - Method for automatic matching communication of computer and serial port external module - Google Patents

Method for automatic matching communication of computer and serial port external module Download PDF

Info

Publication number
CN1570899A
CN1570899A CN 200410027032 CN200410027032A CN1570899A CN 1570899 A CN1570899 A CN 1570899A CN 200410027032 CN200410027032 CN 200410027032 CN 200410027032 A CN200410027032 A CN 200410027032A CN 1570899 A CN1570899 A CN 1570899A
Authority
CN
China
Prior art keywords
computer
serial
serial port
external module
port external
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.)
Granted
Application number
CN 200410027032
Other languages
Chinese (zh)
Other versions
CN1315072C (en
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.)
Shenzhen Fast Shadow Technology Co Ltd
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CNB2004100270327A priority Critical patent/CN1315072C/en
Publication of CN1570899A publication Critical patent/CN1570899A/en
Application granted granted Critical
Publication of CN1315072C publication Critical patent/CN1315072C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Information Transfer Systems (AREA)
  • Communication Control (AREA)

Abstract

It is a kind of automatic match communication method between computer and serial port external-connected module. The characteristic is: the computer serial port communication software can automatically identify the port number of serial port on which connected the serial port external-connected module by means of detecting the serial port receiving message package. The serial port external-connected module can automatically calculate the baud rate that matching computer RS232 serial port by detecting waveform.

Description

The method of computer and serial port external module automatic matching communication
Technical field the present invention relates to the communication technology, particularly relates to the RS232 communication technology of computer and serial port external module.
The RS232 communication technology of background technology computer and serial port external module is usually used in fields such as domestic electronic appliances, Industry Control, security identification.Because computer has a plurality of serial ports, external connection module can be connected on any one serial ports, in traditional RS232 communication technology, the automatic matching communication scheme is not provided, need the user to distinguish the port numbers of computer serial ports, manual configuration port numbers, baud rate, higher to customer requirements, the user uses inconvenience.
The summary of the invention the technical problem to be solved in the present invention is to avoid above-mentioned the deficiencies in the prior art part and the method that proposes a kind of computer and serial port external module automatic matching communication, need not the port numbers that the user distinguishes serial ports, need not manual configuration port numbers and baud rate, easy to use.
The present invention solve the technical problem can be by realizing by the following technical solutions:
Propose the method for a kind of computer and serial port external module automatic matching communication, include computer, computer serial communication software, serial port external module, when the baud rate communication that employing is made an appointment, may further comprise the steps:
1. serial port external module initialization I/O mouth is intercepted the data that the computer serial ports sends by the baud rate of agreement
2. computer serial communication software starts receiving thread by the baud rate of arranging all computer serial ports of initialization successively, sends handshake packet to each serial ports;
3. serial port external module receives handshake packet, replys the handshake response bag;
4. after computer serial communication software received the handshake response bag that certain serial ports returns, judging on this serial ports had external connection module, writes down the port numbers of this serial ports, uses this serial ports to communicate.
Such scheme is characterised in that: computer serial communication software receives the mode of suffering from bag that disappears by the detection serial ports and discerns the port numbers that serial port external module connects the RS232 serial ports of computer automatically.Also can initiatively send handshake packet by serial port external module, computer serial communication software receives the port numbers that the message bag judges that serial port external module connects by detecting certain serial ports.Why adopting the scheme that is initiatively sent handshake packet, detection handshake response bag by computer serial communication software, is to consider to unite with the technical scheme that serial port external module calculates the baud rate of computer RS232 serial ports automatically by detection waveform.
Such scheme is applicable to the situation that computer and serial port external module adopt the baud rate of making an appointment to communicate by letter.The user can be connected to serial port external module on arbitrary port of computer serial ports, need not user's manual configuration port numbers, and system can discern port numbers automatically and communicate.
Do not arrange to propose the method that a kind of serial port external module detects computer serial ports baud rate automatically under the situation of baud rate at computer and serial port external module, include computer, computer serial communication software, serial port external module, may further comprise the steps:
1. serial port external module initialization I/O mouth, circulation is intercepted the computer serial ports and whether is sent data;
2. computer serial communication software starts receiving thread by default baud rate all computer serial ports of initialization successively, sends handshake packet to each serial ports;
3. serial port external module with the counter measures low level retention time, calculates every bit time width when detecting computer serial ports transmission data, determines that computer sends the baud rate of data;
4. serial port external module is replied the handshake response bag according to the 3. definite baud rate of step to computer;
5. after computer serial communication software received the handshake response bag that certain serial ports returns, judging on this serial ports had external connection module, writes down the port numbers of this serial ports, uses this serial ports to communicate;
Compare with prior art, technique effect of the present invention is: the port numbers of the computer serial ports of discerning serial port external module automatically and being connected, and serial port external module detects the coupling baud rate automatically, need not the user and distinguishes the computer end slogan, need not manual configuration, easy to use.Technical scheme of the present invention realizes that cost is low, and interface is clear, can be embedded into easily in the schemes such as domestic electronic appliances, Industry Control, security identification.
Description of drawings
Fig. 1 is a general frame synoptic diagram of the present invention;
Fig. 2 is the circuit theory diagrams of serial port external module (2);
Fig. 3 software flow pattern that to be computer (1) communicate by letter with the agreement baud rate with serial port external module (2);
Fig. 4 is that computer (1) is not arranged baud rate with serial port external module (2), mates the software flow pattern of baud rate automatically; Fig. 4-the 1st, computer (1) and serial port external module (2) software main flow chart, Fig. 4-the 2nd, serial port external module (2) detects the level waveform synoptic diagram of baud rate according to handshake packet, Fig. 4-the 3rd, serial port external module (2) detects the baud rate software flow pattern;
Embodiment is described in further detail below in conjunction with the most preferred embodiment shown in the accompanying drawing.
As shown in Figure 1, computer (1) has four serial ports, comprises COM1 (13), COM2 (14), COM3 (15), COM4 (16); Serial communication software (12) is in charge of all serial initialization, data transmission/reception, and judges serial port external module (2) with which serial ports links to each other; Serial port external module (2) is connected any one serial ports of computer (1).Serial communication software provides the uniform communication interface to call for it to using software (11), and has shielded serial communication details such as port numbers, baud rate; Preferably, serial communication software (12) calls with software (11) as a dynamic link library supply, also can be packaged into a class and be embedded in the application software (11).
By the multi-serial-port card equipment of special use, computer (1) can provide the serial ports more than four, and serial communication software (12) adopts same management process to all serial ports.
Fig. 2 is the circuit theory diagrams of serial port external module (2).Serial port external module (2) is connected to any one serial ports of computer (1), obtains the 5V power supply by the stealing circuit from computer (1) serial ports; Circuit is a Central Control Module with 8 single-chip microcomputer EM78P156, realizes serial communication with software mode, and single-chip processor i/o pin P61 is responsible for sending data to computer (1) serial ports, and single-chip processor i/o pin P62 is responsible for receiving the serial data from computer (1).
Described serial port external module circuit is a preferred version cheaply, also has other to adopt special chip to realize the scheme of RS232 telecommunication circuit on the market, no longer describes in detail here.
Fig. 3 software flow pattern that to be computer (1) communicate by letter with the agreement baud rate with serial port external module (2), details are as follows for its flow process:
Serial port external module (2) initialization I/O mouth is intercepted the data that the computer serial ports sends by the baud rate of agreement;
Computer serial communication software (12) starts receiving thread by the baud rate of arranging initialization serial ports COM1 (13), COM2 (14), COM3 (15), COM4 (16) successively, sends handshake packet to each serial ports;
Serial port external module (2) receives handshake packet, replys the handshake response bag by the baud rate of agreement;
Computer serial communication software (12) is judged to be connected with serial port external module (2) on this serial ports after receiving the handshake response bag that certain serial ports returns, and writes down the port numbers of this serial ports, uses this serial ports to communicate; Other serial ports does not receive to shake hands and replys bag that computer serial communication software (12) judges on other serial ports there is not serial port external module, closes other port at the appointed time.
Fig. 4 is that computer (1) is not arranged baud rate with serial port external module (2), mates the software flow pattern of baud rate automatically; Fig. 4-the 1st, computer (1) and serial port external module (2) software main flow chart, Fig. 4-the 2nd, serial port external module (2) detects the level waveform synoptic diagram of baud rate according to handshake packet, Fig. 4-the 3rd, serial port external module (2) detects the baud rate software flow pattern;
Shown in Fig. 4-1, details are as follows with serial port external module (2) software main flow for computer (1):
Serial port external module (2) initialization I/O mouth is intercepted the computer serial ports and whether is sent data, and promptly whether cycle detection single-chip microcomputer input pin is low level (start bit that RS232 sends data is a low level);
Computer serial communication software (12) is pressed the default baud rate of computer initialization serial ports COM1 (13), COM2 (14), COM3 (15), COM4 (16) successively, starts receiving thread, sends handshake packet to each serial ports;
Serial port external module (2) detects the computer serial ports at the single-chip microcomputer input pin and sends data to when reaching, and calculates and the coupling baud rate according to the waveform of handshake packet; And reply the handshake response bag to computer (1) according to this baud rate;
Computer serial communication software (12) is then judged to be connected with serial port external module (2) on this serial ports after receiving the handshake response bag that certain serial ports returns, and writes down the port numbers of this serial ports, uses this serial ports to communicate; Other serial ports does not receive to shake hands and replys bag that computer serial communication software (12) judges on other serial ports there is not serial port external module, closes other port at the appointed time.
Fig. 4-2 is depicted as the waveform that the single-chip microcomputer input pin receives.Computer (1) is a byte to the handshake packet that serial port external module (2) sends, and is 0x00; Data layout is 1 start bit, 8 bit data positions, do not have parity check bit, 2 position of rests, 1 spare bits.At the single-chip microcomputer input pin, a lasting low level is formed in 1 start bit of handshake packet and 8 bit data positions; Serial ports receiver module (2) picks up counting at the negative edge that start bit begins, and to the rising edge end timing at end, the 8th bit data position, low level time width T is 9 bit time width, and every bit time width is T/9, and the calculating baud rate is 9/T.
In serial port external module (2) side circuit, because the influence of component parameter, negative edge and rising edge have the regular hour, baud rate 9/T is not accurate baud rate, but relatively near actual baud rate, serial ports receiver module (2) is adjusted compensation according to component parameter, is adapted for the baud rate of standard, as 300bps, 600bps, 1200bps, 2400bps, 4800bps, 9600bps, 19200bps, 38400bps etc.
Adopting the reason of 0x00 as handshake packet, mainly is to consider the influence of component parameter to negative edge and rising edge.0x00 can constitute 9 low level time widths, and every bit time width is mean value T/9, can drop to minimum to the influence of component parameter.By same baud rate computing method, also can adopt other byte value as handshake packet, only need calculate and adjust the compensation baud rate according to the low level time width that byte value forms.
Shown in Fig. 4-3, the software flow of serial port external module (2) detection handshake packet low level time width is as described below:
Serial port external module (2) software initialization I/O mouth is counter O reset; Whether cyclic query single-chip microcomputer input pin becomes low level, whether receives that promptly computer (1) serial ports sends the start bit of data; Become low level if detect the single-chip microcomputer input pin, the 10us that then delays time, counter adds 1, and whether inquiry single-chip microcomputer input pin becomes high level; If do not become high level, then continue time-delay, summary counter; After the single-chip microcomputer input pin became high level, according to width T=Counter Value computing time instruction time in Counter Value and the circulation * (other instruction time in the 10us+ circulation), the calculating baud rate was 9/T.Because negative edge and rising edge have the regular hour, baud rate 9/T is not accurate baud rate, and adjustment is compensated for as the standard baud rate to serial port external module (2) software according to component parameter, adopts baud rate and the computer (1) determined to communicate afterwards.

Claims (2)

1. the method for a computer (1) and serial port external module (2) automatic matching communication, include computer (1), serial port external module (2), it is characterized in that: computer serial communication software (12) is discerned the port numbers that serial port external module (2) connects (1) RS232 serial ports of computer automatically by the mode that detects serial ports reception message bag.
2. the method for computer as claimed in claim 1 (1) and serial port external module (2) automatic matching communication is characterized in that: serial port external module (2) calculates the baud rate of coupling computer (1) RS232 serial ports automatically by detection waveform.
CNB2004100270327A 2004-04-25 2004-04-25 Method for automatic matching communication of computer and serial port external module Expired - Fee Related CN1315072C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2004100270327A CN1315072C (en) 2004-04-25 2004-04-25 Method for automatic matching communication of computer and serial port external module

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2004100270327A CN1315072C (en) 2004-04-25 2004-04-25 Method for automatic matching communication of computer and serial port external module

Publications (2)

Publication Number Publication Date
CN1570899A true CN1570899A (en) 2005-01-26
CN1315072C CN1315072C (en) 2007-05-09

Family

ID=34480854

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2004100270327A Expired - Fee Related CN1315072C (en) 2004-04-25 2004-04-25 Method for automatic matching communication of computer and serial port external module

Country Status (1)

Country Link
CN (1) CN1315072C (en)

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101989250A (en) * 2010-11-03 2011-03-23 中兴通讯股份有限公司 Serial communication method and system
CN102197384A (en) * 2008-10-29 2011-09-21 晶像股份有限公司 Method and system for improving serial port memory communication latency and reliability
CN102270168A (en) * 2011-08-09 2011-12-07 西安辉炜信息科技有限公司 Method for automatically detecting serial port information
CN104536926A (en) * 2014-12-22 2015-04-22 深圳市科漫达智能管理科技有限公司 Control method and device of serial devices
CN104811359A (en) * 2015-04-10 2015-07-29 深圳市元征科技股份有限公司 Serial port communication method and terminal
CN105068947A (en) * 2015-08-20 2015-11-18 浪潮软件集团有限公司 Method for processing serial port communication based on driver layer
CN105553628A (en) * 2015-12-05 2016-05-04 中国航空工业集团公司洛阳电光设备研究所 Method and device for detecting serial communication baud rate
WO2018039879A1 (en) * 2016-08-29 2018-03-08 深圳市华阳信通科技发展有限公司 Serial port data sequence keeping method and system
CN112202528A (en) * 2020-08-17 2021-01-08 北京海泰方圆科技股份有限公司 Communication baud rate correction method and device, electronic equipment and storage medium
CN112235078A (en) * 2020-10-14 2021-01-15 四川长虹教育科技有限公司 Method for realizing Android and Windows communication under intelligent interactive large screen
CN114490487A (en) * 2022-02-16 2022-05-13 瀚云科技有限公司 Serial port information acquisition method, device, equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5490209A (en) * 1994-02-09 1996-02-06 Harris Corporation Autobaud rate detection mechanism
US7272211B2 (en) * 2002-01-03 2007-09-18 Intel Corporation Property management system protocol auto-detection

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102197384A (en) * 2008-10-29 2011-09-21 晶像股份有限公司 Method and system for improving serial port memory communication latency and reliability
US8892825B2 (en) 2008-10-29 2014-11-18 Silicon Image, Inc. Method and system for improving serial port memory communication latency and reliability
CN102197384B (en) * 2008-10-29 2014-12-10 晶像股份有限公司 Method and system for improving serial port memory communication latency and reliability
US10056123B2 (en) 2008-10-29 2018-08-21 Lattice Semiconductor Corporation Method and system for improving serial port memory communication latency and reliability
CN101989250B (en) * 2010-11-03 2014-12-17 中兴通讯股份有限公司 Serial communication method and system
CN101989250A (en) * 2010-11-03 2011-03-23 中兴通讯股份有限公司 Serial communication method and system
CN102270168A (en) * 2011-08-09 2011-12-07 西安辉炜信息科技有限公司 Method for automatically detecting serial port information
CN104536926B (en) * 2014-12-22 2018-05-01 深圳市科漫达智能管理科技有限公司 The control method and device of serial equipment
CN104536926A (en) * 2014-12-22 2015-04-22 深圳市科漫达智能管理科技有限公司 Control method and device of serial devices
CN104811359B (en) * 2015-04-10 2018-12-07 深圳市元征科技股份有限公司 A kind of serial port communication method and terminal
CN104811359A (en) * 2015-04-10 2015-07-29 深圳市元征科技股份有限公司 Serial port communication method and terminal
CN105068947B (en) * 2015-08-20 2018-01-16 浪潮软件集团有限公司 Method for processing serial port communication based on driver layer
CN105068947A (en) * 2015-08-20 2015-11-18 浪潮软件集团有限公司 Method for processing serial port communication based on driver layer
CN105553628A (en) * 2015-12-05 2016-05-04 中国航空工业集团公司洛阳电光设备研究所 Method and device for detecting serial communication baud rate
CN105553628B (en) * 2015-12-05 2018-11-16 中国航空工业集团公司洛阳电光设备研究所 A kind of serial communication baud rate detection method and device
WO2018039879A1 (en) * 2016-08-29 2018-03-08 深圳市华阳信通科技发展有限公司 Serial port data sequence keeping method and system
CN112202528A (en) * 2020-08-17 2021-01-08 北京海泰方圆科技股份有限公司 Communication baud rate correction method and device, electronic equipment and storage medium
CN112235078A (en) * 2020-10-14 2021-01-15 四川长虹教育科技有限公司 Method for realizing Android and Windows communication under intelligent interactive large screen
CN114490487A (en) * 2022-02-16 2022-05-13 瀚云科技有限公司 Serial port information acquisition method, device, equipment and storage medium
CN114490487B (en) * 2022-02-16 2023-12-19 瀚云科技有限公司 Method, device, equipment and storage medium for acquiring serial port information

Also Published As

Publication number Publication date
CN1315072C (en) 2007-05-09

Similar Documents

Publication Publication Date Title
CN1315072C (en) Method for automatic matching communication of computer and serial port external module
US8147326B2 (en) Secured inter-processor and virtual device communications system
CN102306136B (en) Baud rate self-adaption method based on input capture function of singlechip
CN101399635A (en) Baud rate adaptation method, apparatus and host for communication
WO2014168462A1 (en) Method, device, and system for controlling hydraulic pump of construction machine
US20040025099A1 (en) Method and system for optimizing polling in systems using negative acknowledgement protocols
JP2007151145A (en) Normalization of crc counter
CN107193697A (en) A kind of method for realizing the nonpolarity connections of RS485
CN107040386A (en) Power supply equipment and power supply method of Ethernet power supply system
CN107423196A (en) A kind of more neck condition detection method, detection device and mobile terminals
CN106569440A (en) Method for achieving communication between microprocessor and touch screen based on MODBUS-RTU protocol
CN107608711A (en) Upgrade method, device, system and electronic equipment
CN102780700B (en) Method and device for realizing baud rate and protocol self-adaption in video monitoring field
CN101655994A (en) Multi-path Wiegand signal input method and device
CN116541332A (en) Baud rate self-adaptive adjusting system and method for measuring switch
CN1893605A (en) Electronic apparatus and control method thereof
WO2022110899A1 (en) Remote motor control method based on wechat mini program
US20070171896A1 (en) Management system and management method for managing a communication apparatus
CN109981139B (en) Method, equipment and storage medium for reducing crosstalk of G.FAST port
CN103200248B (en) Based on the communication means of the power param eter supervision of embedded system
CN207319182U (en) One kind wears display device
CN107046541B (en) Wireless transceiving encryption communication method and device thereof
TWI705729B (en) Distributed access, data transmission and retransmission method and system for mobile internet of things terminals
CN115174429B (en) Network bandwidth detection method, device, system, equipment and storage medium
CN107066412B (en) Communication circuit and method thereof

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 CITY SHUYING TECHNOLOGY CO., LTD.

Free format text: FORMER NAME: ZHAO HONGGANG

CP03 Change of name, title or address

Address after: Room 1007/1008, east block, Nanshan Software Park, 10128 Shennan Road, Shenzhen, Guangdong, Nanshan District, China

Patentee after: Shenzhen fast shadow Technology Co., Ltd.

Address before: 3B, Victoria Park, Shekou Industrial seven Road Park area, Guangdong, Shenzhen

Patentee before: Zhao Honggang

C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070509

Termination date: 20110425