CN102270168A - Method for automatically detecting serial port information - Google Patents

Method for automatically detecting serial port information Download PDF

Info

Publication number
CN102270168A
CN102270168A CN201110226480XA CN201110226480A CN102270168A CN 102270168 A CN102270168 A CN 102270168A CN 201110226480X A CN201110226480X A CN 201110226480XA CN 201110226480 A CN201110226480 A CN 201110226480A CN 102270168 A CN102270168 A CN 102270168A
Authority
CN
China
Prior art keywords
serial
serial port
port information
host computer
serial ports
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201110226480XA
Other languages
Chinese (zh)
Inventor
周晓辉
武斌
陈磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XI'AN GUANGXIANG INFORMATION TECHNOLOGY CO., LTD.
Original Assignee
XI'AN HUIWEI INFORMATION TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by XI'AN HUIWEI INFORMATION TECHNOLOGY Co Ltd filed Critical XI'AN HUIWEI INFORMATION TECHNOLOGY Co Ltd
Priority to CN201110226480XA priority Critical patent/CN102270168A/en
Publication of CN102270168A publication Critical patent/CN102270168A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Transfer Systems (AREA)

Abstract

The invention discloses a method for automatically detecting serial port information. The method comprises the steps that: a handshake protocol is respectively preloaded in a serial communication terminal and an upper computer; when the serial communication terminal is connected with the upper computer by serial ports, the upper computer sequentially transmits a handshake request to all the useable serial ports at a preset Baud rate according to the useable serial port information pre-stored in a storage unit; if at least one of the serial ports feeds back a handshake response, the upper computer is successful handshake with the serial port and communicated with the serial communication terminal connected below the serial port; simultaneously, the serial port information is deleted from the useable serial ports stored in the storage unit; and the serial port number and the Baud rate value for accepting the handshake response are stored together in the storage unit, and the serial port number and the Baud rate value are fed back through a human-computer interface. The method for automatically detecting the serial port information can greatly reduce the time of a technicist for equipment debugging without testing serial port information one after another, and can be applied to various situations of serial port communication.

Description

Automatically detect the method for Serial Port Information
Technical field
The present invention relates to communication technical field, particularly detect the method for Serial Port Information automatically, comprise string slogan and baud rate.
Background technology
At present, at instrument and meter and communication technical field, particularly use under the situations such as serial communication equipment is debugged, operation, usually need in equipment manager, check serial ports that computing machine has manual unlocking successively, if not knowing the baud rate of equipment also will test baud rate commonly used in turn, causing the reduction and the insignificant duplication of labour of work efficiency, will be a no small workload if there are a lot of equipment to connect simultaneously.
Summary of the invention
The objective of the invention is to overcome the deficiencies in the prior art, a kind of method of automatic detection Serial Port Information is provided, its step is as follows:
At first, in serial communication terminal and host computer, pre-install Handshake Protocol respectively;
When the serial communication terminal connects host computer by serial ports, host computer is according to the available Serial Port Information that is pre-stored in storage unit, send handshake request to all available serial ports successively with default baud rate, if having the serial ports feedback of at least one to shake hands replys, then shake hands successfully, and set up with the serial communication terminal that this serial ports is connected down and to communicate by letter, delete in the available serial ports that this Serial Port Information will be stored from storage unit simultaneously, the shake hands baud rate value of replying of this string slogan and receiving is preserved in the lump by in storage unit and by man-machine interface feedback string slogan and baud rate value;
Further, the method for aforesaid automatic detection Serial Port Information, the judgement of wherein said available serial ports is as follows:
Host computer is opened all serial ports successively, if can successfully be opened, illustrates that this serial ports can use, and the storage unit that simultaneously the string slogan of available serial ports is kept at host computer is standby.
The method of described automatic detection Serial Port Information wherein also comprises:
After a serial communication endpoint registration was finished, host computer can repeat to send a handshake request to all available serial ports, if shake hands response feedback, and the then renewal of registration, otherwise, finish.
Automatically detect the method for Serial Port Information as preferred version, host computer receives that the response time of shaking hands of serial communication terminal is between 0 millisecond to 5000 milliseconds.
Automatically detect the method for Serial Port Information as preferred version, host computer receives that the response time of shaking hands of serial communication terminal is between 0 millisecond to 200 milliseconds.
Automatically detect the method for Serial Port Information as preferred version, all serial ports numbers of host computer self are no less than 1.
Automatically detect the method for Serial Port Information as preferred version, all serial ports numbers of host computer self are 2 to 10.
Described default baud rate order is as follows successively:
300 bits per seconds, 600 bits per seconds, 1200 bits per seconds, 2400 bits per seconds, 4800 bits per seconds, 9600 bits per seconds, 19200 bits per seconds, 38400 bits per seconds, 43000 bits per seconds, 56000 bits per seconds, 115200 bits per seconds.
Described Handshake Protocol is as follows:
Serial communication terminal and host computer communication protocol are the ASCII character of 10 byte regular lengths, and protocol format is: AAA#BBB#CC, and wherein AAA is an instruction type, and BBB is operation, and CC is a parameter, and # is a blank character, can not have.
Instruction type comprises two kinds: CMD and DAT, CMD representative sends is instruction, the transmission of DAT representative be data.
When beginning to shake hands, host computer sends to the serial communication terminal:
CMD#CHK#00 represents whether host computer inspection serial communication terminal is normal
After the serial communication terminal is received instruction, if the serial communication terminal normally sends to host computer:
CMD#CHK#OK
If the serial communication terminal is wrong, send to host computer:
CMD#ERR#XX
Annotate: XX is an error code.
Receive the CMD#CHK#OK of serial communication terminal transmission when host computer after, send Address requests to the serial communication terminal:
CMD#ADD#RE
When the serial communication terminal is received Address requests, send:
CMD#ADD#XX
Annotate: XX is the ASCII character address, serial port terminal device address 00-99
Host computer sends the log-on message request code to the serial communication terminal:
CMD#VER#RE
When the serial communication terminal is received above-mentioned request, send:
CMD#?VER?#XX
Annotate: XX is the ASCII character address, serial communication terminal code 00-99
Host computer is to serial communication terminal transmits data request code:
CMD#REQ#XX
Annotate: XX is the request of ASCII character data type:
When the serial communication terminal is received request of data, send the data length bag:
DAT#NUMXXX
Annotate: XXX is an ASCII character packet number
Next serial communication terminal transmission length is 10 packet, sends the back that finishes and sends:
CMD#DAT#OK
The expression data send and finish.
Description of drawings
The process flow diagram of Fig. 1 embodiment of the invention 1;
The process flow diagram of Fig. 2 embodiment of the invention 2.
Embodiment
The present invention will be further described below in conjunction with embodiment.
Embodiment 1
Shown in Fig. 1, the serial ports number of the host computer in the present embodiment is 10, logic flow of the present invention is as follows: the host computer start is to start to open own serial ports according to serial ports number preface, if can successfully be opened, illustrate that this serial ports can use, after serial ports all is opened, judge whether the string slogan of opening for the last time is 10, if host computer is standby with the storage unit that the string slogan of available serial ports is kept at host computer, otherwise return step S101.When the serial communication terminal connects host computer by serial ports, host computer is according to the available Serial Port Information that is pre-stored in storage unit, send handshake request to all available serial ports successively with default baud rate, if having the serial ports of at least one to shake hands 200 milliseconds of internal feedbacks replys, then shake hands successfully, and set up with the serial communication terminal that this serial ports is connected down and to communicate by letter, delete in the available serial ports that this Serial Port Information will be stored from storage unit simultaneously, this string slogan and receiving shakes hands that the baud rate value of replying is stored in storage unit in the lump and by man-machine interface feedback string slogan and baud rate value; Otherwise repeat this step S104.
After communication is set up successfully, the serial communication terminal can send to host computer in log-on message wherein and registers solidifying, host computer is stored in the storage unit of host computer in the lump with the information of the log-on message of serial communication terminal and the serial ports that connected thereof, and registration is finished automatically.
Described log-on message comprises at least a in the address, product type, production code member, firmware version number, product producer of communication terminal.
After a serial communication endpoint registration was finished, host computer can repeat to send a handshake request to all available serial ports, if shake hands response feedback, then return step S104, otherwise, enter step S109, statistics and preserve answering equipment information such as the string slogan of corresponding serial ports and baud rate value.
Embodiment 2
Shown in Fig. 2, the serial ports number of the host computer in the present embodiment is 2, logic flow of the present invention is as follows: the host computer start is to start to open own serial ports according to serial ports number preface, if can successfully be opened, illustrate that this serial ports can use, after serial ports all is opened, judge whether the string slogan of opening for the last time is 2, if host computer is standby with the storage unit that the string slogan of available serial ports is kept at host computer, otherwise return step S201.When the serial communication terminal connects host computer by serial ports, host computer is according to the available Serial Port Information that is pre-stored in storage unit, send handshake request to all available serial ports successively with default baud rate, if having the serial ports of at least one to shake hands 5000 milliseconds of internal feedbacks replys, then shake hands successfully, and set up with the serial communication terminal that this serial ports is connected down and to communicate by letter, delete in the available serial ports that this Serial Port Information will be stored from storage unit simultaneously, this string slogan and receiving shakes hands that the baud rate value of replying is kept at storage unit in the lump and by man-machine interface feedback string slogan and baud rate value, otherwise repeats this step S204.
After a serial communication endpoint registration was finished, host computer can repeat to send a handshake request to available serial ports, if shake hands response feedback, then return step S204, otherwise, enter step S209, statistics and preserve answering equipment information such as the string slogan of corresponding serial ports and baud rate value.
Embodiment 3
Present embodiment is a kind of software program that utilizes method of the present invention to finish, said procedure operates in the host computer, this program not only can be finished technique effect of the present invention, the Serial Port Information of host computer can also be reported to operating personnel by man-machine interface simultaneously.
When the serial ports automatic identification procedure moves, open on the computing machine serial ports 1 at first respectively to serial ports 10, if opening, serial ports illustrates that successfully serial ports exists and do not have occupied.After the been scanned, available serial ports is preserved storage unit.Afterwards, program can be opened available serial ports successively, and sends handshake request, replys if receive shaking hands of serial communication terminal in 1000 milliseconds, then thinks and communicates by letter successfully.Shake hands after the success, the serial communication terminal sends the address to host computer, registers on host computer, and host computer is also preserved the Serial Port Information of this equipment connection simultaneously, finishes automatic identifying.Host computer among this embodiment is an X86 framework PC.Software development environment Microsoft Visual Studio 2008; Programming language is a C# language.This program major function and characteristics: this program is applied to various serial communication equipment, obtains the Serial Port Information of connection device automatically.Characteristics such as this program has simply, and is easy to operate have also been saved people's working time simultaneously greatly, have saved human cost.
The above, it only is preferred embodiment of the present invention, be not that the present invention is done any pro forma restriction, though the present invention has disclosed with preferred embodiment as is above-mentioned, yet be not to be used to limit the present invention, any those skilled in the art, in not breaking away from technical scheme scope of the present invention, can utilize the technology contents of above-mentioned disclosure to make the equivalent embodiment that a little change is considered as equivalent variations, all contents that does not break away from technical solution of the present invention, according to technical spirit of the present invention above embodiment is made any simple modification, equivalent variations and modification all belong to technical scope of the present invention.

Claims (7)

1. detect the method for Serial Port Information automatically, its step is as follows:
In serial communication terminal and host computer, pre-install Handshake Protocol respectively;
When the serial communication terminal connects host computer by serial ports, host computer is according to the available Serial Port Information that is pre-stored in storage unit, send handshake request to all available serial ports successively with default baud rate, if having the serial ports feedback of at least one to shake hands replys, then shake hands successfully, and set up with the serial communication terminal that this serial ports is connected down and to communicate by letter, delete in the available serial ports that this Serial Port Information will be stored from storage unit simultaneously, this string slogan and receiving shakes hands that the baud rate value of replying is stored in storage unit in the lump and by man-machine interface feedback string slogan and baud rate value.
2. the method for automatic detection Serial Port Information according to claim 1, the judgement of wherein said available serial ports is as follows:
Host computer is opened all serial ports successively, if can successfully be opened, illustrates that this serial ports can use, and the storage unit that simultaneously the string slogan of available serial ports is kept at host computer is standby.
3. the method for automatic detection Serial Port Information according to claim 1 and 2 wherein also comprises:
After a Serial Port Information detection was finished, host computer can repeat to send a handshake request to all available serial ports, if shake hands response feedback, and the then renewal of registration, otherwise, finish.
4. the method for automatic detection Serial Port Information according to claim 1, host computer receive that the response time of shaking hands of serial communication terminal is between 0 millisecond to 5000 milliseconds.
5. the method for automatic detection Serial Port Information according to claim 5, host computer receive that the response time of shaking hands of serial communication terminal is between 0 millisecond to 200 milliseconds.
6. the method for automatic detection Serial Port Information according to claim 1 and 2, all serial ports numbers of host computer self are no less than 1.
7. the method for automatic detection Serial Port Information according to claim 7, all serial ports numbers of host computer self are 2 to 10.
CN201110226480XA 2011-08-09 2011-08-09 Method for automatically detecting serial port information Pending CN102270168A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110226480XA CN102270168A (en) 2011-08-09 2011-08-09 Method for automatically detecting serial port information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110226480XA CN102270168A (en) 2011-08-09 2011-08-09 Method for automatically detecting serial port information

Publications (1)

Publication Number Publication Date
CN102270168A true CN102270168A (en) 2011-12-07

Family

ID=45052477

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110226480XA Pending CN102270168A (en) 2011-08-09 2011-08-09 Method for automatically detecting serial port information

Country Status (1)

Country Link
CN (1) CN102270168A (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103389960A (en) * 2013-07-26 2013-11-13 山东康威通信技术股份有限公司 Method and device for self-adapting of Baud rate in field of power monitoring
CN103514127A (en) * 2012-06-15 2014-01-15 中国航天科工集团第三研究院第八三五八研究所 Implementation method for achieving self-adaption of baud rate
CN103905381A (en) * 2012-12-26 2014-07-02 苏州工业园区新宏博通讯科技有限公司 Method for electricity meter to realize baud rate adaptive communication
CN106201974A (en) * 2016-08-29 2016-12-07 深圳市华阳信通科技发展有限公司 A kind of serial data order keeping method and system
CN106649165A (en) * 2016-12-30 2017-05-10 湖南国科微电子股份有限公司 Method for establishingcommunication connection of embedded system and PC host
CN106790382A (en) * 2016-11-24 2017-05-31 深圳市新威尔电子有限公司 Battery tester slave computer management method and system
WO2018039879A1 (en) * 2016-08-29 2018-03-08 深圳市华阳信通科技发展有限公司 Serial port data sequence keeping method and system
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN108415857A (en) * 2018-03-01 2018-08-17 合肥威艾尔智能技术有限公司 A kind of universal process method of serial data
WO2018184143A1 (en) * 2017-04-05 2018-10-11 深圳中兴力维技术有限公司 Intelligent device access method and system
CN108809832A (en) * 2017-04-27 2018-11-13 四零四科技股份有限公司 The devices and methods therefor serially routeing is safeguarded when sending work request
CN109451070A (en) * 2018-12-29 2019-03-08 重庆华渝电气集团有限公司 A kind of communication means and middleware of multifunctional console
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium
CN111913894A (en) * 2020-08-18 2020-11-10 广州市紫晶通信科技有限公司 Serial port configuration method and device and IEC61850 protocol converter
CN112199307A (en) * 2020-10-26 2021-01-08 英业达科技有限公司 Processing device with serial communication interface processing function and method thereof
CN112306915A (en) * 2020-10-26 2021-02-02 英业达科技有限公司 Communication interface control system and method thereof
CN112732618A (en) * 2021-01-08 2021-04-30 歌尔股份有限公司 Serial port communication method, device and system
CN113177013A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Baud rate-based serial communication method and multi-serial chip

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0281251A (en) * 1988-09-19 1990-03-22 Sanyo Electric Co Ltd Serial interface of microcomputer
CN1570899A (en) * 2004-04-25 2005-01-26 赵红刚 Method for automatic matching communication of computer and serial port external module
CN101882120A (en) * 2009-05-06 2010-11-10 上海华虹集成电路有限责任公司 Device capable of automatically detecting micro controller unit (MCU) interfaces and realizing interface conversion
CN101894086A (en) * 2010-06-08 2010-11-24 昆山三泰新电子科技有限公司 Serial hub and multi-serial high-speed communication method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0281251A (en) * 1988-09-19 1990-03-22 Sanyo Electric Co Ltd Serial interface of microcomputer
CN1570899A (en) * 2004-04-25 2005-01-26 赵红刚 Method for automatic matching communication of computer and serial port external module
CN101882120A (en) * 2009-05-06 2010-11-10 上海华虹集成电路有限责任公司 Device capable of automatically detecting micro controller unit (MCU) interfaces and realizing interface conversion
CN101894086A (en) * 2010-06-08 2010-11-24 昆山三泰新电子科技有限公司 Serial hub and multi-serial high-speed communication method

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103514127A (en) * 2012-06-15 2014-01-15 中国航天科工集团第三研究院第八三五八研究所 Implementation method for achieving self-adaption of baud rate
CN103905381A (en) * 2012-12-26 2014-07-02 苏州工业园区新宏博通讯科技有限公司 Method for electricity meter to realize baud rate adaptive communication
CN103389960A (en) * 2013-07-26 2013-11-13 山东康威通信技术股份有限公司 Method and device for self-adapting of Baud rate in field of power monitoring
CN103389960B (en) * 2013-07-26 2016-08-10 山东康威通信技术股份有限公司 Power monitoring field realizes the method and device of baud rate self-adapting
CN106201974A (en) * 2016-08-29 2016-12-07 深圳市华阳信通科技发展有限公司 A kind of serial data order keeping method and system
WO2018039879A1 (en) * 2016-08-29 2018-03-08 深圳市华阳信通科技发展有限公司 Serial port data sequence keeping method and system
CN106790382A (en) * 2016-11-24 2017-05-31 深圳市新威尔电子有限公司 Battery tester slave computer management method and system
CN106790382B (en) * 2016-11-24 2020-06-12 深圳市新威尔电子有限公司 Lower computer management method and system of battery testing device
CN106649165A (en) * 2016-12-30 2017-05-10 湖南国科微电子股份有限公司 Method for establishingcommunication connection of embedded system and PC host
WO2018184143A1 (en) * 2017-04-05 2018-10-11 深圳中兴力维技术有限公司 Intelligent device access method and system
CN108809832A (en) * 2017-04-27 2018-11-13 四零四科技股份有限公司 The devices and methods therefor serially routeing is safeguarded when sending work request
CN107967229A (en) * 2017-12-22 2018-04-27 安徽博微长安电子有限公司 A kind of serial ports automatic identifying method, system and computer-readable recording medium
CN108415857A (en) * 2018-03-01 2018-08-17 合肥威艾尔智能技术有限公司 A kind of universal process method of serial data
CN109597779A (en) * 2018-11-21 2019-04-09 Oppo(重庆)智能科技有限公司 A kind of serial-port inquiring method and equipment and computer storage medium
CN109451070B (en) * 2018-12-29 2022-03-25 重庆华渝电气集团有限公司 Communication method and middleware of multifunctional display and control console
CN109451070A (en) * 2018-12-29 2019-03-08 重庆华渝电气集团有限公司 A kind of communication means and middleware of multifunctional console
CN111913894A (en) * 2020-08-18 2020-11-10 广州市紫晶通信科技有限公司 Serial port configuration method and device and IEC61850 protocol converter
CN112199307A (en) * 2020-10-26 2021-01-08 英业达科技有限公司 Processing device with serial communication interface processing function and method thereof
CN112306915A (en) * 2020-10-26 2021-02-02 英业达科技有限公司 Communication interface control system and method thereof
CN112732618A (en) * 2021-01-08 2021-04-30 歌尔股份有限公司 Serial port communication method, device and system
CN112732618B (en) * 2021-01-08 2022-12-09 歌尔股份有限公司 Serial port communication method, device and system
CN113177013A (en) * 2021-05-24 2021-07-27 石家庄通合电子科技股份有限公司 Baud rate-based serial communication method and multi-serial chip
CN113177013B (en) * 2021-05-24 2022-09-02 石家庄通合电子科技股份有限公司 Baud rate-based serial communication method and multi-serial chip

Similar Documents

Publication Publication Date Title
CN102270168A (en) Method for automatically detecting serial port information
CN102279831A (en) Automatic registering method of serial communication terminal
CN108763086B (en) Script recording method, terminal and computer readable storage medium based on remote true machine
CN204759403U (en) System based on data pass realization equipment internal module thoroughly and upgrade
CN100576935C (en) Embedded set top box debugging, method of testing
CN102075389B (en) Debugging method and equipment
CN104601402B (en) The internet of things functional online test method and device of a kind of internet of things home appliance
CN107678949B (en) Automatic testing method for realizing different communication modes of embedded equipment
CN109981360B (en) Internet of things equipment site opening method, device and system and storage medium
CN109981747B (en) Device control method, device, electronic device and storage medium
CN102064964A (en) Method for rapidly switching gigabit network cards in gigabit switching environment
CN103198007A (en) Multi-process log output method and system
CN101170438A (en) A remote serial port debugging method and its system
CN105263155A (en) Method and system for remotely monitoring running state of intelligent mobile terminal baseband processor in real-time manner
CN109246628B (en) Wireless dispatching desk based on air bus digital trunking system and implementation method
CN113238951A (en) Software barrier-free automatic test system and test method thereof
JP2007082078A (en) Data relay device
CN101242305B (en) Parameter configuration method and device for network device
CN103841587A (en) Method, apparatus, and system for realization of internet-of-things converged gateway
CN101136756B (en) Electric self-checking method, system and BMC chip on network long-range control host machine
CN109634856B (en) IOS intelligent terminal remote real machine debugging system and method based on cloud service
CN103176877A (en) Method and system for debugging peripheral of embedded device
CN110753363A (en) Intelligent device wireless debugging system and method
CN109725621A (en) A kind of secondary bus program based on 1553B bus and CAN bus is in line writing method
CN113094059A (en) Firmware system data transmission method and burning device thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
ASS Succession or assignment of patent right

Owner name: XI'AN GOSHINE INFORMATION TECHNOLOGY CO., LTD.

Free format text: FORMER OWNER: XI'AN HUIWEI INFORMATION TECHNOLOGY CO., LTD.

Effective date: 20131225

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20131225

Address after: 5, N501 building, floor 710075, hi tech innovation building, Xi'an hi tech Zone, Shaanxi, China

Applicant after: XI'AN GUANGXIANG INFORMATION TECHNOLOGY CO., LTD.

Address before: 710075, E, block 508, pioneer research & Development Park, 69 Kam Yip Road, Shaanxi, Xi'an

Applicant before: Xi'an Huiwei Information Technology Co., Ltd.

C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20111207

WD01 Invention patent application deemed withdrawn after publication