CN100444595C - A method of master-slave equipment communication - Google Patents

A method of master-slave equipment communication Download PDF

Info

Publication number
CN100444595C
CN100444595C CNB200410102538XA CN200410102538A CN100444595C CN 100444595 C CN100444595 C CN 100444595C CN B200410102538X A CNB200410102538X A CN B200410102538XA CN 200410102538 A CN200410102538 A CN 200410102538A CN 100444595 C CN100444595 C CN 100444595C
Authority
CN
China
Prior art keywords
character string
master
data
packet
slave
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.)
Expired - Fee Related
Application number
CNB200410102538XA
Other languages
Chinese (zh)
Other versions
CN1633125A (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.)
Vimicro Corp
Original Assignee
Vimicro Corp
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 Vimicro Corp filed Critical Vimicro Corp
Priority to CNB200410102538XA priority Critical patent/CN100444595C/en
Publication of CN1633125A publication Critical patent/CN1633125A/en
Application granted granted Critical
Publication of CN100444595C publication Critical patent/CN100444595C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • Communication Control (AREA)

Abstract

The present invention provides a method of master-slave equipment communication in order to solve the problem of complicated communication mechanism in the prior art. The method of master-slave equipment communication comprises the steps: A. master equipment converts the data needing to the sent to slave equipment into character strings and sends the character strings to the slave equipment; B. the slave equipment converts the received character strings into the data sent by the master equipment. The adoption of the method of the present invention can simply realize the data communication between the master equipment and the slave equipment in short distance.

Description

A kind of method of master-slave equipment communication
Technical field
The present invention relates to data communication, refer to the data communications method between a kind of master-slave equipment especially.
Background technology
Generally speaking, the communication protocol between the equipment has a variety of, such as TCP etc., these communication protocol more complicated, but also error code, verification, repeating transmission or the like mechanism is arranged, system is very huge, is the application scenario of this communication protocol the best at the easy disturbed environment of communication channel.
In fact, when communicating between the very near equipment for distance, because two communication equipments are separated by very near (generally in 2 meters), communication channel is stable, be difficult to be subjected to external interference and cause error code, therefore, do not need the communication mechanism of complexity such as verification, repeating transmission to ensure the reliability and the correctness of communication.Particularly for the communication between the master-slave equipment, because main equipment is fixed as command originator, slave unit is passive reception order or data, between the master-slave equipment seldom or do not have the mutual of signaling, in such application, use communication protocols such as TCP to communicate and to bring very big raising on the performance as system, and make system become complicated huge, for this reason, can seek a kind of better simply relatively communication mechanism and realize data communication between the in-plant master-slave equipment.
During communication between the reliable equipment of this communication channel, tend to adopt following similarly communication protocol, this communication protocol generally is to increase a signaling head (generally the length of this signaling head is 4 bytes) in the front of each packet, follow the length information (generally also being 4 bytes) of this signaling then, represent this length of data package, also use a signaling at last and represent that packet finishes, as shown in Figure 1.Similarly communication protocol has some following shortcomings:
1, adding the purpose of signaling head, is in order to represent the beginning of packet, because appearance is very low with the probability of signaling 4 an identical byte data in the data of being transmitted, therefore this communication mechanism still can not take place in the situation of makeing mistakes of fundamentally avoiding communicating by letter;
2,,, may cause the communication recovery of comparison difficulty owing to the existence of length information when a garble occurring;
3, this communication protocol is lower to the communication efficiency of a small amount of valid data.
Summary of the invention
The invention provides a kind of method of master-slave equipment communication, to solve communication mechanism complicated problems in the prior art.
Method of master-slave equipment communication provided by the invention comprises the following steps:
A, main equipment convert the content-data that needs send to slave unit to character string, insert the separator of distinguishing the different pieces of information group, in the end the end of a character string adds the end sign of expression ED, the character string of inserting described separator and finish to identify is broken into packet send to slave unit;
B, slave unit convert the described character string that receives to content-data that main equipment sends according to described separator that comprises in the packet that receives and end sign.
Described character string is the character string with the ASCII character definition.
Slave unit is according to the separator that comprises in the packet that receives and finish sign, converts the described character string that receives to data that main equipment sends, specifically comprises:
Slave unit is changed the data before and after the separator respectively according to the separator that receives, and finishes the data transaction that sign finishes current data packet according to packet.Described separator is the space.
Described packet finishes to be designated the carriage return character.
Be provided with a character string array in the described slave unit, the character string that receives is deposited in this character string array; When receiving a carriage return character, read the character string of storing in this character string array and change, and empty this character string array.
Described packet is the identical or different packet of length.
Adopt method of the present invention, the communication between can the simple realization master-slave equipment, with respect to prior art, the advantage of the inventive method is as follows:
1, the carriage return character has guaranteed correctly beginning of each packet;
If 2 mistake occurs at certain packet, the recovery communication that its next packet is just correct;
3, when low volume data was communicated by letter, its efficient was than higher.
Description of drawings
Fig. 1 is a prior art data packet format schematic diagram;
Fig. 2 is a main equipment data transaction flow chart in the embodiment of the invention;
Fig. 3 is slave unit receiving data stream journey figure in the embodiment of the invention;
Fig. 4 is a slave unit data transaction flow chart in the embodiment of the invention.
Embodiment
The inventive method is applicable to two the very near master-slave equipments of being separated by, and is connected by communication interface (serial ports or parallel port) between them.Suppose that main equipment will send 16 system data 0x112233 to slave unit, it carries parameter 0x44, then need carry out data transaction at main equipment, converts 16 system data 0x112233 to the ASCII character character string and sends.In order to make slave unit correctly the character string that receives is reduced into the initial data that main equipment sends, need the identifier of agreement expression end of signaling in master-slave equipment in advance, adopt the carriage return character to represent the packet of a signaling to finish in the present embodiment; Because signaling might have one or more parameters, need to be separated between parameter and the signaling or between the parameter, therefore, the argumnent separator of need making an appointment adopts the space to separate in the present embodiment.According to above-mentioned agreement, the idiographic flow that the data transaction that main equipment will need to transmit becomes character string comprises the following steps: as shown in Figure 2
At first convert 16 system data 0x112233 to character string, obtain " 112233 ";
Increase the space, and parameter 0x44 is converted to the parameter character string, obtain " 11223344 ";
Increase the carriage return character, represent this signaling data end-of-packet, obtain " 11223344 n ", wherein " n " expression carriage return character;
Data after this conversion are sent to slave unit by the communication interface between main equipment and the slave unit.
Slave unit receiving data stream journey figure comprises the following steps: as shown in Figure 3
S31: slave unit constantly detects the communication interface with main equipment;
S32: arrive if detect new data, then execution in step S33; Otherwise, return step S31, continue the wait main equipment and send new data;
S33: the data message that reads reception;
S34: whether the data of judging current reception are the carriage return character of a data end-of-packet of expression, if not, and execution in step S35; If, execution in step S36;
S35: preserved in storage to the character string array of in slave unit, opening up with current reception, return step S31, wait for that the character late string of packet is sent to the slave unit from interface;
S36: read the data of preserving in the character string array, promptly the alphabet string of current data packet prepares to enter the character string flow path switch, converts the character string that receives to 16 system data.
Concrete conversion method comprises the following steps: as shown in Figure 4
S41: the data that from the character string array, read a packet; In the present embodiment, the data of reading are character string " 112,233 44 ", and string length was 9 (comprising the space);
S42: judge between each character string of this packet whether have the space, if having, execution in step S43 then, otherwise, go to step S44;
S43: with the space is boundary, and the character string that receives is divided into the separate character string of some strings; In the present embodiment, obtain two string character strings, the first string character string is " 112233 "; The second string character string is " 44 ";
S44: convert each character string to 16 system data, can obtain signaling data 0x112233 and 0x44 that main equipment sends.
Among the above embodiment, the packet end identifier can be made an appointment in master-slave equipment and is any character.Separator between the character string also can be made an appointment in master-slave equipment and is any character.
Among the present invention, the data that main equipment need send are not limited to 16 system data among the embodiment, can be the arbitrary carry system data.
Character string after the present invention's conversion can be the character string of ASCII character definition, but is not limited thereto.

Claims (7)

1, a kind of method of master-slave equipment communication is characterized in that, comprises the following steps:
A, main equipment convert the content-data that needs send to slave unit to character string, insert the separator of distinguishing the different pieces of information group, in the end the end of a character string adds the end sign of expression ED, the character string of inserting described separator and finish to identify is broken into packet send to slave unit;
B, slave unit convert the described character string that receives to content-data that main equipment sends according to described separator that comprises in the packet that receives and end sign.
2, method of master-slave equipment communication as claimed in claim 1 is characterized in that, described character string is the character string with the ASCII character definition.
3, method of master-slave equipment communication as claimed in claim 1 is characterized in that, described slave unit is according to the described separator that comprises in the packet that receives and finish sign, converts the described character string that receives to data that main equipment sends, specifically comprises:
Described slave unit is changed the data before and after the described separator respectively according to the described separator that receives, and finishes the data transaction that sign finishes current data packet according to described packet.
4, method of master-slave equipment communication as claimed in claim 1 is characterized in that, described separator is the space.
5, method of master-slave equipment communication as claimed in claim 1 is characterized in that, described packet finishes to be designated the carriage return character.
6, method of master-slave equipment communication as claimed in claim 5 is characterized in that, is provided with a character string array in the described slave unit, and the character string that receives is deposited in this character string array; When receiving a carriage return character, read the character string of storing in this character string array and change, and empty this character string array.
7, method of master-slave equipment communication as claimed in claim 1 is characterized in that, described packet is the identical or different packet of length.
CNB200410102538XA 2004-12-24 2004-12-24 A method of master-slave equipment communication Expired - Fee Related CN100444595C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB200410102538XA CN100444595C (en) 2004-12-24 2004-12-24 A method of master-slave equipment communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB200410102538XA CN100444595C (en) 2004-12-24 2004-12-24 A method of master-slave equipment communication

Publications (2)

Publication Number Publication Date
CN1633125A CN1633125A (en) 2005-06-29
CN100444595C true CN100444595C (en) 2008-12-17

Family

ID=34848120

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB200410102538XA Expired - Fee Related CN100444595C (en) 2004-12-24 2004-12-24 A method of master-slave equipment communication

Country Status (1)

Country Link
CN (1) CN100444595C (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9507930B2 (en) 2003-04-25 2016-11-29 Z124 Physical key secure peripheral interconnection
US20130198867A1 (en) 2011-12-09 2013-08-01 Z124 A Docking Station for Portable Devices Providing Authorized Power Transfer and Facility Access
CN101453313B (en) * 2007-12-06 2013-03-20 鸿富锦精密工业(深圳)有限公司 Communication circuit for master-slave equipment
EP2622492A4 (en) * 2010-10-01 2015-08-12 Z124 Systems and methods for docking portable electronics devices
US9383770B2 (en) 2011-08-31 2016-07-05 Z124 Mobile device that docks with multiple types of docks
US9244491B2 (en) 2011-08-31 2016-01-26 Z124 Smart dock for auxiliary devices
CN104486034B (en) * 2014-12-08 2017-12-01 江西洪都航空工业集团有限责任公司 A kind of RS422/485 serial port communication datas group bag method

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5481675A (en) * 1992-05-12 1996-01-02 International Business Machines Corporation Asynchronous serial communication system for delaying with software dwell time a receiving computer's acknowledgement in order for the transmitting computer to see the acknowledgement
US5936540A (en) * 1995-12-13 1999-08-10 Eric Bauer Process for the management of concurrent access and device for practicing the same
CN1337629A (en) * 2000-08-05 2002-02-27 三星电子株式会社 Bus system and its instruct transmission method
US20040013123A1 (en) * 2002-07-17 2004-01-22 Lsi Logic Corporation Active FIFO threshold adjustment
JP2004187006A (en) * 2002-12-03 2004-07-02 Matsushita Electric Ind Co Ltd Data structure, slave instrument, and master instrument

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5481675A (en) * 1992-05-12 1996-01-02 International Business Machines Corporation Asynchronous serial communication system for delaying with software dwell time a receiving computer's acknowledgement in order for the transmitting computer to see the acknowledgement
US5936540A (en) * 1995-12-13 1999-08-10 Eric Bauer Process for the management of concurrent access and device for practicing the same
CN1337629A (en) * 2000-08-05 2002-02-27 三星电子株式会社 Bus system and its instruct transmission method
US20040013123A1 (en) * 2002-07-17 2004-01-22 Lsi Logic Corporation Active FIFO threshold adjustment
JP2004187006A (en) * 2002-12-03 2004-07-02 Matsushita Electric Ind Co Ltd Data structure, slave instrument, and master instrument

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
C语言程序设计. 谭浩强,138-144,科学出版社,龙门书局. 2001
C语言程序设计. 谭浩强,138-144,科学出版社,龙门书局. 2001 *

Also Published As

Publication number Publication date
CN1633125A (en) 2005-06-29

Similar Documents

Publication Publication Date Title
CN101146102B (en) HDLC data uplink and downlink method and communication device in RRU network
CN112187789B (en) Data link protocol conversion system
CN102624738B (en) Serial port server, protocol conversion chip and data transmission method
US10396921B2 (en) Multi-lane synchronization method, synchronization apparatus and system, and computer storage medium
CN100444595C (en) A method of master-slave equipment communication
CN108123775A (en) The method and apparatus of transmission packet
CN104156334A (en) Serial port self-adaption data transparent transmission protocol for multimachine communication
CN108809618B (en) Clock recovery method for 8b10b coded serial data
CN111211863A (en) MAC transmitting terminal, MAC receiving terminal and circuit, FPGA chip and data transmission system
CN103281773A (en) System and method for processing data
CN102158282B (en) Optical fiber longitudinal difference protection device and synchronous communication method thereof
CN104360988B (en) The recognition methods of the coded system of Chinese character and device
CN106941430A (en) A kind of programmable precision net message construction and transmitting element based on FPGA
CN108833321A (en) Code CPM signal code block synchronization method based on differential phase waveform matching
CN102420675B (en) Methods and devices for transmitting and receiving using state information of buffer of data message
CN1972163B (en) A signaling data transmission apparatus in radio frequency widening module and its frame synchronization method
CN102737208B (en) Method for decoding MMC type data by ultrahigh frequency electronic tag
US20130016762A1 (en) Data communication system, method of optimizing preamble length, and communication apparatus
CN104009823B (en) Dislocation detection and error correction circuit in a kind of SerDes technologies
CN104735551B (en) ADVB receives fault-tolerant and processing method
CN110838892A (en) High-reliability merging and forwarding method for multi-path full-duplex serial port
CN105227544B (en) Realize the device and method of different agreement message conversion
CN101572658A (en) Method, device and system for processing wireless relay massage transmission
CN100389583C (en) A command transmission method
CN102761486A (en) Low-discreteness GOOSE point to multipoint and multipoint to point receiving and transmitting method

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
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20081217

Termination date: 20111224