CN1633126A - A command transmission method - Google Patents
A command transmission method Download PDFInfo
- Publication number
- CN1633126A CN1633126A CN 200410102540 CN200410102540A CN1633126A CN 1633126 A CN1633126 A CN 1633126A CN 200410102540 CN200410102540 CN 200410102540 CN 200410102540 A CN200410102540 A CN 200410102540A CN 1633126 A CN1633126 A CN 1633126A
- Authority
- CN
- China
- Prior art keywords
- command
- order
- character string
- parameter
- receives
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 26
- 230000005540 biological transmission Effects 0.000 title claims abstract description 22
- 230000000153 supplemental effect Effects 0.000 claims description 27
- 238000006243 chemical reaction Methods 0.000 claims description 13
- 238000012545 processing Methods 0.000 claims description 2
- 238000004891 communication Methods 0.000 description 15
- 230000006870 function Effects 0.000 description 3
- 238000010586 diagram Methods 0.000 description 2
- 238000012795 verification Methods 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 1
- 230000011664 signaling Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
Images
Landscapes
- Communication Control (AREA)
- Computer And Data Communications (AREA)
Abstract
This invention relates to a transmission method including: dividing the order into different kinds and designing different process ways related to the kind orders. When transmitting the orders, the transmitting end converts the words of order into an alphabetic string then to process the parameter based on the attributed kind of the current order, the receiving end converts the alphabetic string received into the corresponding order and converts the parameter data based on the kind of the order.
Description
Technical field
The present invention relates to the communication between the equipment, refer to transmit between a kind of equipment the method for order data 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 that the order data between the in-plant master-slave equipment transmits.
Summary of the invention
The invention provides a kind of command transmission method, need adopt the problem of complex communication agreement when communicating by letter between the near field communication devices in the prior art to solve.
Command transmission method of the present invention comprises: order is divided into different command types, set the processing mode of the parameter correspondence of dissimilar orders, when carrying out the order transmission, the order transmitting terminal at first converts the command word of the current command to character string, according to command type under the current command its parameter is carried out sending after the respective handling again; The order receiving terminal is converted to corresponding order with the command word character string that receives, and according to the type that receives order the supplemental characteristic that receives is carried out corresponding conversion process.
According to said method of the present invention, order is divided into following three types:
The first kind: command parameter is a character string;
Second type: command parameter is non-character string, and supplemental characteristic is less than preset threshold;
The 3rd type: command parameter is non-character string, and supplemental characteristic is more than or equal to preset threshold;
Store the described order and the affiliated command type table of comparisons thereof respectively at order transmitting terminal and order receiving terminal;
When carrying out the order transmission, carry out the following step:
A, judge whether the current command is first kind order, if, then command word character string, parameter character string and order end identifier are sent to the order receiving terminal in proper order, go to step D; Otherwise, execution in step B;
B, judge whether the current command is second type command, if, then its parameter is converted to character string, parameter character string after command word character string, the conversion and order end identifier are sent to the order receiving terminal in proper order, go to step D; Otherwise, execution in step C;
C, calculate the supplemental characteristic length of the current command, and the length value that calculates is converted to character string, length value character string after command word character string, the conversion and order end identifier are sent to the order receiving terminal in proper order, and after being sent completely, send described supplemental characteristic continuously; Go to step D;
After D, order receiving terminal receive a complete order, at first the command word character string that receives is converted to the corresponding command; According to the command type table of comparisons of storage, judge the command type under the current reception order again, if first kind order, then with the parameter character string that receives parameter as the current command; If second type command then is converted to corresponding supplemental characteristic with the parameter character string that receives; If the 3rd type command then is converted to length numerical value with the length value character string that receives, and receives the supplemental characteristic of the data of equal length as the current command continuously.
Described character string is the character string with the ASCII character definition.
According to said method of the present invention,, then only its command word is converted to character string and sends if described order does not have command parameter.
If described order has command parameter, then between command word character string after the conversion and parameter character string, insert separator; The separator of whether having an agreement in the order that the receiving terminal analysis receives, if having, the data message before first separator that then will receive is converted to command word.
If more than one of described parameter character string is then inserted separator, in order to distinguish different parameters between the parameter character string; Receiving terminal carries out respective handling according to the command type that receives with the data before and after the separator.
Described separator is the space.
Described order end identifier is the carriage return character.
Adopt method of the present invention can realize simply, quickly that the order data between the near field communication devices transmits.
Description of drawings
Fig. 1 is that the inventive method order transmitting terminal sends the order flow chart;
The command string schematic diagram that Fig. 2 sends for the inventive method;
Fig. 3 is the schematic diagram data that passes a parameter in the embodiment of the invention;
Fig. 4 is that the inventive method order receiving terminal receives the order flow chart.
Embodiment
Command transmission method of the present invention needs at first to arrange the command word of complete order at order transmitting terminal and receiving terminal, and makes the command word of each order unique.Because use the C language to carry out requiring in the software development each function name not repeat, the command word of therefore corresponding this function can be its function name, guaranteed the uniqueness of order like this.According to the difference of each order, can have parameter or not be with parameter.The parameter of some order can have a plurality of, can be even a lot of supplemental characteristic.
According to order with the difference of parameter, the present invention is divided into following three types with order:
The first kind: command parameter is a character string;
Second type: command parameter is non-character string, and supplemental characteristic is less than preset threshold;
The 3rd type: command parameter is non-character string, and supplemental characteristic is more than or equal to preset threshold.
The present invention is storing the complete order and the affiliated command type table of comparisons thereof respectively at order transmitting terminal and order receiving terminal in advance.When transmitting terminal when receiving terminal sends order, the order transmitting terminal at first converts the command word of the current command to character string, its transmission flow comprises the following steps: as shown in Figure 1
Step S11: search command type under the current order to be sent according to the command type table of comparisons of storage;
Step S12: judge whether the current command is first kind order, and promptly whether the parameter of the current command is character string, if, execution in step S13, otherwise, execution in step S14;
Step S13: the command word character string after will changing, parameter character string and order end identifier send to the order receiving terminal in proper order, and insert separator between command word character string and parameter character string; If it is a plurality of that the parameter character string has, then also separated between the parameter character string, to distinguish different parameters with separator; Separator can be any character of arranging between transmitting terminal and receiving terminal, as space etc.; The command character string structure that sends as shown in Figure 2; For example: want to call void SendString (char*str); Call statement is SendString (" abcdef "); Then the whole order data of Fa Songing is " SendStringabcdef n ", and wherein, " n " expression carriage return character is as the order end identifier;
Step S14: judge whether the current command is second type command, and promptly the parameter of the current command is non-character string, and supplemental characteristic is less than preset threshold, if, execution in step S15 then; Otherwise execution in step S16;
Step S15: command parameter is converted to character string, then parameter character string after command word character string, the conversion and order end identifier is sent to the order receiving terminal in proper order; Equally, between command word character string and parameter character string, insert separator; If it is a plurality of that the parameter character string after the conversion has, between the parameter character string, also separated, to distinguish different parameters with separator; For example: write register command SetReg (0x100,0x200); 0x100 wherein, 0x200 is the parameter of system call, is that character string is with these two parameters by 16 system number conversions then: " 100 ", " 200 "; Then the whole order data of Fa Songing is: " SetReg 100200 n ";
Step S16: if the current command does not belong to first and second type command, then must be the three class order of supplemental characteristic more than or equal to setting threshold, for this class order, because supplemental characteristic is more, send receiving terminal to if all convert character string to, then the delivery time of whole order is longer, in order effectively to save data transfer time, improve transmission efficiency, when the supplemental characteristic of order (greater than certain threshold value of setting) more for a long time, then no longer supplemental characteristic is carried out the character string conversion, and take directly supplemental characteristic to be sent to the load mode of receiving terminal; In order to make receiving terminal can receive command parameter like clockwork, calculate the supplemental characteristic length of the current command at transmitting terminal, and the length value that calculates is converted to character string, then length value character string after command word character string, the conversion and order end identifier are sent to the order receiving terminal in proper order, and after being sent completely, send whole supplemental characteristics continuously; For example: transmitting terminal wishes to transmit array buf[100] give receiving terminal, then send order and be: " WriteBuf 100 n ", and then send buf[100] content, as shown in Figure 3.
The present invention according to the order with the parameter difference, be divided into three kinds of modes order sent to receiving terminal.Correspondingly, receiving terminal is according to command type, undo command accordingly under the order that receives.Concrete method of reseptance comprises the following steps: as shown in Figure 4
Step S31: the receiving terminal memory command type table of comparisons;
Step S32: receiving terminal is received a complete command packet according to the order end identifier, and at first converts the command word character string that receives to corresponding order;
Step S33: receiving terminal is determined the command type of the current command according to the command type table of comparisons of the command lookup storage that receives; If first kind order, then execution in step S34; If second type command, then execution in step S35; If the 3rd type command, then execution in step S36;
Step S34: with the parameter character string that receives parameter as the current command;
Step S35: the parameter character string that receives is converted to corresponding supplemental characteristic, is the parameter of the current command;
Step S36: the length value character string that receives is converted to length numerical value, and receives the supplemental characteristic of the data of equal length continuously as the current command.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of claims.
Claims (8)
1, a kind of command transmission method, it is characterized in that, order is divided into different command types, set the processing mode of the parameter correspondence of dissimilar orders, when carrying out the order transmission, the order transmitting terminal at first converts the command word of the current command to character string, according to command type under the current command its parameter is carried out sending after the respective handling again; The order receiving terminal is converted to corresponding order with the command word character string that receives, and according to the type that receives order the supplemental characteristic that receives is carried out corresponding conversion process.
2, command transmission method as claimed in claim 1 is characterized in that, order is divided into following three types:
The first kind: command parameter is a character string;
Second type: command parameter is non-character string, and supplemental characteristic is less than preset threshold;
The 3rd type: command parameter is non-character string, and supplemental characteristic is more than or equal to preset threshold;
Store the described order and the affiliated command type table of comparisons thereof respectively at order transmitting terminal and order receiving terminal;
When carrying out the order transmission, carry out the following step:
A, judge whether the current command is first kind order, if, then command word character string, parameter character string and order end identifier are sent to the order receiving terminal in proper order, go to step D; Otherwise, execution in step B;
B, judge whether the current command is second type command, if, then its parameter is converted to character string, parameter character string after command word character string, the conversion and order end identifier are sent to the order receiving terminal in proper order, go to step D; Otherwise, execution in step C;
C, calculate the supplemental characteristic length of the current command, and the length value that calculates is converted to character string, length value character string after command word character string, the conversion and order end identifier are sent to the order receiving terminal in proper order, and after being sent completely, send described supplemental characteristic continuously; Go to step D;
After D, order receiving terminal receive a complete order, at first the command word character string that receives is converted to the corresponding command; According to the command type table of comparisons of storage, judge the command type under the current reception order again, if first kind order, then with the parameter character string that receives parameter as the current command; If second type command then is converted to corresponding supplemental characteristic with the parameter character string that receives; If the 3rd type command then is converted to length numerical value with the length value character string that receives, and receives the supplemental characteristic of the data of equal length as the current command continuously.
3, command transmission method as claimed in claim 1 is characterized in that, described character string is the character string with the ASCII character definition.
4, command transmission method as claimed in claim 2 is characterized in that, if described order does not have command parameter, then only its command word is converted to character string and sends.
5, command transmission method as claimed in claim 2 is characterized in that, if described order has command parameter, then inserts separator between command word character string after the conversion and parameter character string; The separator of whether having an agreement in the order that the receiving terminal analysis receives, if having, the data message before first separator that then will receive is converted to command word.
6, command transmission method as claimed in claim 5 is characterized in that, as if more than one of described parameter character string, then inserts separator between the parameter character string, in order to distinguish different parameters; Receiving terminal carries out respective handling according to the command type that receives with the data before and after the separator.
7, command transmission method as claimed in claim 6 is characterized in that, described separator is the space.
8, command transmission method as claimed in claim 2 is characterized in that, described order end identifier is the carriage return character.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004101025407A CN100389583C (en) | 2004-12-24 | 2004-12-24 | A command transmission method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004101025407A CN100389583C (en) | 2004-12-24 | 2004-12-24 | A command transmission method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1633126A true CN1633126A (en) | 2005-06-29 |
CN100389583C CN100389583C (en) | 2008-05-21 |
Family
ID=34848121
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004101025407A Expired - Fee Related CN100389583C (en) | 2004-12-24 | 2004-12-24 | A command transmission method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100389583C (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101686198A (en) * | 2008-09-28 | 2010-03-31 | 新奥特(北京)视频技术有限公司 | Command transmitting method is a virtual studio system |
CN101197959B (en) * | 2007-12-29 | 2010-12-08 | 北京创毅视讯科技有限公司 | Terminal control method, system and equipment |
CN103049244A (en) * | 2012-12-06 | 2013-04-17 | 北京小米科技有限责任公司 | Method and device for transmitting operating instructions |
CN103955195A (en) * | 2014-05-05 | 2014-07-30 | 中国安全生产科学研究院 | Sending and responding method and device of control instruction |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5778223A (en) * | 1992-03-17 | 1998-07-07 | International Business Machines Corporation | Dictionary for encoding and retrieving hierarchical data processing information for a computer system |
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 |
FI100497B (en) * | 1995-04-13 | 1997-12-15 | Nokia Telecommunications Oy | Adaptive interface |
CH689881A8 (en) * | 1995-12-13 | 2000-02-29 | Bauer Eric | Concurrent access management method and device for its implementation. |
GB9800900D0 (en) * | 1998-01-17 | 1998-03-11 | Philips Electronics Nv | Graphic image generation and coding |
KR100329860B1 (en) * | 1999-09-17 | 2002-03-22 | 서평원 | A method of processing human relationship instruction for communication system |
US7477649B2 (en) * | 2002-07-17 | 2009-01-13 | Lsi Corporation | Active FIFO threshold adjustment |
-
2004
- 2004-12-24 CN CNB2004101025407A patent/CN100389583C/en not_active Expired - Fee Related
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101197959B (en) * | 2007-12-29 | 2010-12-08 | 北京创毅视讯科技有限公司 | Terminal control method, system and equipment |
CN101686198A (en) * | 2008-09-28 | 2010-03-31 | 新奥特(北京)视频技术有限公司 | Command transmitting method is a virtual studio system |
CN103049244A (en) * | 2012-12-06 | 2013-04-17 | 北京小米科技有限责任公司 | Method and device for transmitting operating instructions |
CN103049244B (en) * | 2012-12-06 | 2017-04-12 | 小米科技有限责任公司 | Method and device for transmitting operating instructions |
CN103955195A (en) * | 2014-05-05 | 2014-07-30 | 中国安全生产科学研究院 | Sending and responding method and device of control instruction |
CN103955195B (en) * | 2014-05-05 | 2016-09-14 | 中国安全生产科学研究院 | The transmission of a kind of control instruction, response method and device |
Also Published As
Publication number | Publication date |
---|---|
CN100389583C (en) | 2008-05-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6920125B1 (en) | IP adaptation layer on backhaul connection of cellular network | |
CN1593051A (en) | Extension header compression | |
CN1219361C (en) | Bluetooth adaptor for infrared interface and communication method therefor | |
CN1180603C (en) | Method and system for user interface of mobile terminal | |
CN1650584A (en) | Method and apparatus for header compression in a wireless LAN | |
CN1816170A (en) | Code-conversion method for shortmessage receiving and transmitting and network apparatus used thereof | |
CN1339131A (en) | Method enabling communications between an electronic device and a battery, an apparatus comprising an electronic device and a battery, and a battery enabling communication | |
US20130254462A1 (en) | Method and apparatus to reduce flash memory device programming time over a c.a.n. bus | |
CN1753402A (en) | Method of using simple network management protocol to act multirariant block inquiry | |
CN1633126A (en) | A command transmission method | |
CN1368798A (en) | Radio communication equipment and its method and radio communication system using it | |
CN1306753C (en) | Method of realizing RS485 master slave multi machine communication using universal asynchronous recerver transmitter | |
CN1499751A (en) | Data transmitting device and method for transmitting and receiving data and data communication system | |
CN105827441A (en) | SOAP message transmission method and system | |
CN1633125A (en) | A method of master-slave equipment communication | |
CN1838665A (en) | Adapting method between different byte sequence styles in network communication | |
CN1132105C (en) | Method enabling communication between an electronic device and a battery, and apparatus comprising an electronic device and a battery, and a battery enabling communication | |
CN1243431C (en) | Analysis of universal route platform command lines | |
CN101039323A (en) | Multi-rate multi-protocol bit stream processor | |
CN1152583C (en) | Reset controller and its implementation method | |
CN1867194A (en) | Method and system for carrying out telemanagement on mobile terminal | |
CN1747483A (en) | Wireless terminal with double mode and realization thereof | |
CN101047721A (en) | Method for data filter process using DMA controller | |
CN1249970C (en) | Method for clock signal compatibility between data communication equipment and data terminal equipment | |
CN1741461A (en) | Method and system for processing equipment information in network management system |
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: 20080521 Termination date: 20111224 |