JP2007141127A - Communication protocol - Google Patents

Communication protocol Download PDF

Info

Publication number
JP2007141127A
JP2007141127A JP2005336869A JP2005336869A JP2007141127A JP 2007141127 A JP2007141127 A JP 2007141127A JP 2005336869 A JP2005336869 A JP 2005336869A JP 2005336869 A JP2005336869 A JP 2005336869A JP 2007141127 A JP2007141127 A JP 2007141127A
Authority
JP
Japan
Prior art keywords
data
numerical
header
communication
message
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
JP2005336869A
Other languages
Japanese (ja)
Inventor
Takumi Morita
拓実 森田
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.)
Kawamura Electric Inc
Original Assignee
Kawamura Electric Inc
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 Kawamura Electric Inc filed Critical Kawamura Electric Inc
Priority to JP2005336869A priority Critical patent/JP2007141127A/en
Publication of JP2007141127A publication Critical patent/JP2007141127A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To surely perform economical and efficient communication in a communication system for transmitting and receiving a message including a large amount of numerical data. <P>SOLUTION: A communication message 11 is constituted of a data column 12 in which the numerical data is included and a header 13 added to the head of the data column 12. The numerical data in the data column 12 is expressed by hexadecimal numerals as it is without converting it into an ASCII code. However, an upper limit value is set to numerical values usable in the data column 12. Then, a specific numerical value, for example, "0xFF" which is the maximum value of 2 byte hexadecimal number, exceeding the upper limit value is continuously specified in the header 13 for four times. <P>COPYRIGHT: (C)2007,JPO&INPIT

Description

本発明は、通信メッセージをコンピュータが認識可能な形式に変換するプログラム、特に、数値データを含むメッセージの通信に適した通信プロトコルに関する。   The present invention relates to a program for converting a communication message into a format that can be recognized by a computer, and more particularly to a communication protocol suitable for communication of a message including numerical data.

従来、通信ソースをASCIIコードに変換し、多数のASCIIコードを並べて通信メッセージを構成する通信プロトコルが知られている。メッセージを送受信する上で、メッセージの始めと終わりを認識することは重要であり、特に、メッセージの始まりを認識できないと、コンピュータは受信したメッセージを解読することが困難となる。ASCIIコードでは、図5に示すように、メッセージの先頭に付される“STX”に「0x02」が用意され、メッセージの末尾に付される“ETX”に「0x03」が用意されている。このため、コンピュータは“STX”,“ETX”をデータ中の他の文字(数字:「0x3*」、英文字:「0x4*」,「0x5*」)と区別して認識できる。   Conventionally, a communication protocol is known in which a communication source is converted into an ASCII code and a number of ASCII codes are arranged to form a communication message. In transmitting and receiving a message, it is important to recognize the beginning and end of the message. In particular, if the beginning of the message cannot be recognized, it becomes difficult for the computer to decode the received message. In the ASCII code, as shown in FIG. 5, “0x02” is prepared for “STX” attached to the head of the message, and “0x03” is prepared for “ETX” attached to the end of the message. Therefore, the computer can recognize “STX” and “ETX” separately from other characters in the data (numerals: “0x3 *”, English characters: “0x4 *”, “0x5 *”).

しかし、ASCIIコード変換を行う通信プロトコルにおいて、16進数の数値をそのまま1バイトで表すと、コンピュータが16進数の数値データ「0x02」を“STX”として誤認する可能性がある。そこで、従来の通信プロトコルは、図6に示すように、メッセージ51の先頭に“STX”を付加し、末尾に“ETX”を付加し、データ列52中の複数の数値データをそれぞれ二つのASCIIコードに変換している。この方式によれば、例えば、“データ1”の数値「0x02」が「0」を表すASCIIコード「0x30」と、「2」を表すASCIIコード「0x32」とに分割されるため、“STX”を“データ1”と混同する可能性がなくなる。   However, in a communication protocol that performs ASCII code conversion, if a hexadecimal value is expressed as 1 byte as it is, the computer may misidentify the hexadecimal value data “0x02” as “STX”. Therefore, in the conventional communication protocol, as shown in FIG. 6, "STX" is added to the head of the message 51, "ETX" is added to the end, and a plurality of numerical data in the data string 52 are respectively set to two ASCII. It has been converted to code. According to this method, for example, the numerical value “0x02” of “data 1” is divided into an ASCII code “0x30” representing “0” and an ASCII code “0x32” representing “2”. Is no longer confused with “data 1”.

なお、特許文献1には、7ビットのASCIIコードを6ビットの短縮コードに変換することで、文字データを圧縮する方法が記載されている。特許文献2には、複数の文字列をASCIIコード中の制御コードに割り当てて符号化する方法が記載されている。
特開2005−31868号公報 特開平11−85459号公報
Patent Document 1 describes a method of compressing character data by converting a 7-bit ASCII code into a 6-bit shortened code. Patent Document 2 describes a method in which a plurality of character strings are assigned to control codes in ASCII codes and encoded.
JP-A-2005-31868 Japanese Patent Laid-Open No. 11-85459

ところが、従来の通信プロトコルによると、データ列52中の数値データを二つのASCIIコードに変換しているので、1バイトの数値データを送るのに2バイトの電文長が必要になる。このため、多量の数値データを含むメッセージ51を送受信する際に、電文53の全長がいたずらに長くなり、通信時間がかかり、有料回線を使用する場合にパケット料等の通信費が高くつく問題点があった。また、多量の数値データをASCIIコードに変換すると、制御プログラムの負担が重くなるため、コンピュータによる他の処理が遅くなる不都合もあった。   However, according to the conventional communication protocol, the numerical data in the data string 52 is converted into two ASCII codes, so that a 2-byte message length is required to send 1-byte numerical data. For this reason, when the message 51 including a large amount of numerical data is transmitted / received, the total length of the telegram 53 becomes unnecessarily long, it takes a long communication time, and a communication fee such as a packet fee increases when using a pay line was there. In addition, when a large amount of numerical data is converted into ASCII code, the burden on the control program becomes heavy, and other processing by the computer becomes slow.

そこで、本発明の目的は、コンピュータが数値データを含むメッセージの通信を効率よく行うことができる通信プロトコルを提供することにある。   SUMMARY OF THE INVENTION An object of the present invention is to provide a communication protocol that allows a computer to efficiently communicate messages including numerical data.

上記の課題を解決するために、本発明の通信プロトコルは、通信メッセージをコンピュータが認識可能な形式に変換するプログラムであって、通信メッセージを数値データが含まれるデータ列と、データ列の先頭に付加されるヘッダとで構成し、データ列中の数値データを特定値を除く16進数の数値で表し、ヘッダに該特定値を表す16進数の数値を指定することを特徴とする。   In order to solve the above problems, a communication protocol according to the present invention is a program for converting a communication message into a format that can be recognized by a computer. The communication message is a data string including numerical data and a head of the data string. The numerical value data in the data string is expressed by a hexadecimal value excluding a specific value, and a hexadecimal value indicating the specific value is specified in the header.

ここで、ヘッダに指定する16進数の数値は、データ列中に発生し得ない特定の数値である。該特定値の選定にあたり、好ましくは、次の手段を採用できる。
(1)データ列中で使用可能な数値に上限値を設定し、ヘッダにその上限値を超える特定値を指定する。この場合、上限値は、特定の数値や桁数に限定されず、通信プロトコルの適用分野、又は該プロトコルが扱う数値データの種類等に応じて適宜に設定できる。
(2)ヘッダに16進数の特定値を複数回連続させて指定する。特定値及びこれを連続させる回数は、特に限定されず、通信プロトコルの適用分野、又は数値データの種類等に応じて適宜に選択できる。
(3)例えば、特定値に2バイト16進数の最大値である「0xFF」を用い、ヘッダに該数値を複数回連続させて指定することができる。
Here, the hexadecimal numerical value specified in the header is a specific numerical value that cannot be generated in the data string. In selecting the specific value, preferably, the following means can be employed.
(1) An upper limit is set for a numerical value that can be used in the data string, and a specific value that exceeds the upper limit is specified in the header. In this case, the upper limit value is not limited to a specific numerical value or number of digits, and can be appropriately set according to the application field of the communication protocol, the type of numerical data handled by the protocol, or the like.
(2) A specific value in hexadecimal is specified in the header a plurality of times in succession. The specific value and the number of continuous times are not particularly limited, and can be appropriately selected according to the application field of the communication protocol or the type of numerical data.
(3) For example, “0xFF”, which is the maximum value of a 2-byte hexadecimal number, is used as the specific value, and the numerical value can be specified consecutively in the header a plurality of times.

また、本発明は上記通信プロトコルに次の手段を加えて実施することも可能である。
(4)データ列中にメッセージの長さを示す指標となる16進数の数値を付加する。
(5)データ列中にノイズ等による通信エラーを示す16進数の数値を付加する。
The present invention can also be implemented by adding the following means to the above communication protocol.
(4) A hexadecimal number serving as an index indicating the message length is added to the data string.
(5) A hexadecimal value indicating a communication error due to noise or the like is added to the data string.

本発明の通信プロトコルは、データ列中の数値データを16進数の数値で表すので、1バイトの数値データを分割することなく1バイトのままで送受信できる。このため、メッセージの長さを短くし、通信時間を短縮して、通信費を節約できるとともに、ASCIIコードへの変換処理を不要にして、コンピュータの負担を軽減できる。また、データ列中に発生し得ない特定値をヘッダに指定するので、コンピュータが数値データをヘッダと誤認する可能性もなくなる。従って、本発明の通信プロトコルによれば、特に多量の数値データを含むメッセージを送る場合に、経済的かつ効率のよい通信を的確に行うことができるという効果がある。   In the communication protocol of the present invention, numerical data in a data string is represented by hexadecimal numerical values, so that 1-byte numerical data can be transmitted and received as it is without dividing it. For this reason, the message length can be shortened, the communication time can be shortened, the communication cost can be saved, and the conversion process to the ASCII code is not required, thereby reducing the burden on the computer. In addition, since a specific value that cannot occur in the data string is specified in the header, there is no possibility that the computer mistakes numerical data as the header. Therefore, according to the communication protocol of the present invention, there is an effect that economical and efficient communication can be accurately performed particularly when a message including a large amount of numerical data is transmitted.

以下、本発明を実施するための最良の形態を図面に基づいて説明する。図1に示すように、この実施形態の通信システム1は、ネットワーク2に接続された複数のコンピュータ3が通信プロトコル4を用いて主に数値データからなるビジネスメッセージの送受信を行うように構成されている。通信プロトコル4は、通信プログラムの一部として各コンピュータ3に実装され、受信したメッセージを該コンピュータ3の他のプログラムが認識可能な形式に変換する。以下に、通信プロトコル4の具体的な機能について幾つかの実施例をあげて詳細に説明する。   Hereinafter, the best mode for carrying out the present invention will be described with reference to the drawings. As shown in FIG. 1, the communication system 1 of this embodiment is configured such that a plurality of computers 3 connected to a network 2 transmit and receive business messages mainly composed of numerical data using a communication protocol 4. Yes. The communication protocol 4 is implemented in each computer 3 as a part of the communication program, and converts the received message into a format that can be recognized by other programs of the computer 3. Hereinafter, specific functions of the communication protocol 4 will be described in detail with some examples.

図2に示すように、実施例1の通信プロトコルでは、メッセージ11が多数の数値データを並べたデータ列12と、データ列12の先頭に位置するヘッダ13とで構成されている。データ列12の数値データは、ASCIIコード等への変換を行わずに、そのまま16進数の数値で表されている。例えば、送信先の“アドレス”は「0x80」、“コマンド”は「0xA1」、“データ1”は「0x02」でそれぞれ表現されている。そして、ヘッダ13に2バイト16進数の最大値である「0xFF」が指定されている。   As shown in FIG. 2, in the communication protocol of the first embodiment, the message 11 is composed of a data string 12 in which a large number of numerical data are arranged, and a header 13 positioned at the head of the data string 12. The numerical data of the data string 12 is expressed as a hexadecimal number as it is without being converted into an ASCII code or the like. For example, the “address” of the transmission destination is represented by “0x80”, the “command” is represented by “0xA1”, and the “data 1” is represented by “0x02”. Then, “0xFF”, which is the maximum value of 2-byte hexadecimal numbers, is specified in the header 13.

しかし、「0xFF」はデータ列12の中に多数紛れ込んでいるはずであるから、実施例1の通信プロトコルは、データ列12で使用可能な数値に上限値を設定し、ヘッダ13にその上限値を超える特定の数値を指定する。具体的には、データ列12中の数値を10進数の8桁までに制限する。10進数の「99,999,999」は16進数の「0x5F5E0FF」である。これを上限値に設定すれば、データ列12に「0xFF」が連続して現れる最大値は「0x4FFFFFF」(83,886,079)であり、「FF」が3回連続する。従って、ヘッダ13に「FF」が4回連続する特定の数値、つまり「0xFFFFFFFF」を指定すれば、ヘッダ13と数値データとの混同を回避できる。   However, since many “0xFF” should be included in the data string 12, the communication protocol of the first embodiment sets an upper limit value for a numerical value that can be used in the data string 12 and sets the upper limit value in the header 13. Specify a specific number that exceeds. Specifically, the numerical value in the data string 12 is limited to 8 decimal digits. The decimal number “99,999,999” is the hexadecimal number “0x5F5E0FF”. If this is set as the upper limit value, the maximum value in which “0xFF” appears continuously in the data string 12 is “0x4FFFFFF” (83,886,079), and “FF” continues three times. Therefore, if a specific numerical value in which “FF” continues four times in the header 13, that is, “0xFFFFFFFF” is specified, confusion between the header 13 and numerical data can be avoided.

この場合、実際の電文14がヘッダ13の表示に4バイトを必要とするため、“STX”にASCIIコードの「0x02」(図6参照)を指定する従来と比較し、ヘッダ13の電文長が4倍となる。しかし、実施例1の通信プロトコルによれば、例えば、ASCIIコードで200バイトを要したデータ列12の電文長が半分の100バイトまで圧縮される。このため、電文14の全長が差し引き96バイトに相当する長さだけ短くなる。従って、メッセージ11に含まれる数値データの量が増えるほど、通信時間を短縮でき、有料回線を利用する場合にパケット料等の通信費を節約できて、経済的かつ効率のよい通信を的確に行うことができる。   In this case, since the actual message 14 requires 4 bytes to display the header 13, the message length of the header 13 is longer than that in the conventional case where the ASCII code “0x02” (see FIG. 6) is specified for “STX”. 4 times. However, according to the communication protocol of the first embodiment, for example, the message length of the data string 12 requiring 200 bytes in the ASCII code is compressed to 100 bytes, which is half. For this reason, the total length of the telegram 14 is shortened by a length corresponding to the subtraction of 96 bytes. Therefore, as the amount of numerical data included in the message 11 increases, the communication time can be shortened, and communication costs such as packet charges can be saved when using a pay line, so that economical and efficient communication can be performed accurately. be able to.

図3に示すように、実施例2の通信プロトコルでは、メッセージ21がデータ列22とヘッダ23とで構成され、データ列22の先頭付近に“データ長”を表すセル25が設けられている。“データ長”はデータ列22の全長をバイトで示すデータであり、データ列22の他の数値データと同様、16進数の数値でセル25に表されている。例えば、データ列22に99の数値データが含まれている場合、セル25に自身を含む“データ長”が「0x64」(10進数の100)で表記される。   As shown in FIG. 3, in the communication protocol of the second embodiment, the message 21 is composed of a data string 22 and a header 23, and a cell 25 representing “data length” is provided near the head of the data string 22. The “data length” is data indicating the total length of the data string 22 in bytes, and is represented in the cell 25 by a hexadecimal numerical value as in the other numerical data of the data string 22. For example, when 99 numeric data are included in the data string 22, the “data length” including itself in the cell 25 is represented by “0x64” (decimal number 100).

こうすれば、セル25のデータに基づいてコンピュータ3が受信した電文24の終わりを正しく認識できる。従って、ASCIIコードの“ETX”をメッセージ21から省略したとしても、通信になんらの支障をきたさない。その他の構成、作用効果は実施例1と同じである。   In this way, the end of the telegram 24 received by the computer 3 can be correctly recognized based on the data in the cell 25. Therefore, even if the ASCII code “ETX” is omitted from the message 21, there is no problem in communication. Other configurations and operational effects are the same as those of the first embodiment.

図4に示すように、実施例3の通信プロトコルでは、メッセージ31がデータ列32とヘッダ33とで構成され、データ列32の末尾に“BCC”を表すセル35が設けられている。“BCC”は電文34にノイズ等による通信エラーが生じていないかどうかを示すデータであり、データ列32の他の数値データと同様、16進数の数値でセル35に表記されている。ここで、“BCC”の計算結果が「0xFF」となる可能性がある。さらに偶然に、“BCC”直前の“データ99”が「0x4FFFFFF」であった場合、“BCC”と合わせて「FF」が4回連続し、これをコンピュータ3がヘッダ33と誤認するおそれがある。   As shown in FIG. 4, in the communication protocol of the third embodiment, the message 31 includes a data string 32 and a header 33, and a cell 35 representing “BCC” is provided at the end of the data string 32. “BCC” is data indicating whether or not a communication error due to noise or the like has occurred in the telegram 34, and is expressed in the cell 35 as a hexadecimal value, as with other numerical data of the data string 32. Here, the calculation result of “BCC” may be “0xFF”. Furthermore, if the “data 99” immediately before “BCC” is “0x4FFFFFF” by chance, “FF” is continued four times together with “BCC”, and the computer 3 may mistake this as the header 33. .

従って、実施例3の通信プロトコルは、“BCC”を付加する場合に、「FF」が5回連続する特定の数値、つまり「0xFFFFFFFFFF」をヘッダ33に指定する。こうすれば、“BCC”によるエラー表示機能を備えた通信システム1において、ヘッダ33と数値データとの混同を確実に回避することができる。その他の構成、作用効果は実施例1と同じである。   Therefore, in the communication protocol of the third embodiment, when “BCC” is added, a specific numerical value in which “FF” is continued five times, that is, “0xFFFFFFFFFF” is specified in the header 33. In this way, in the communication system 1 having the error display function by “BCC”, it is possible to reliably avoid the confusion between the header 33 and the numerical data. Other configurations and operational effects are the same as those of the first embodiment.

本発明の通信プロトコルが適用される通信システムの概略図である。It is the schematic of the communication system to which the communication protocol of this invention is applied. 実施例1の通信プロトコルを示す機能図である。FIG. 3 is a functional diagram illustrating a communication protocol according to the first embodiment. 実施例2の通信プロトコルを示す機能図である。FIG. 6 is a functional diagram illustrating a communication protocol according to a second embodiment. 実施例3の通信プロトコルを示す機能図である。It is a functional diagram which shows the communication protocol of Example 3. 従来の通信プロトコルが使用するASCIIコード表である。3 is an ASCII code table used by a conventional communication protocol. 従来の通信プロトコルを示す機能図である。It is a functional diagram which shows the conventional communication protocol.

符号の説明Explanation of symbols

1 通信システム
2 ネットワーク
3 コンピュータ
4 通信プロトコル
11,21,31 メッセージ
12,22,32 データ列
13,23,33 ヘッダ
14,24,34 電文
DESCRIPTION OF SYMBOLS 1 Communication system 2 Network 3 Computer 4 Communication protocol 11, 21, 31 Message 12, 22, 32 Data sequence 13, 23, 33 Header 14, 24, 34 Message

Claims (1)

通信メッセージをコンピュータが認識可能な形式に変換するプログラムであって、通信メッセージを数値データが含まれるデータ列と、データ列の先頭に付加されるヘッダとで構成し、データ列中の数値データを特定値を除く16進数の数値で表し、ヘッダに該特定値を表す16進数の数値を指定することを特徴とする通信プロトコル。
A program that converts a communication message into a format that can be recognized by a computer. The communication message is composed of a data string that includes numeric data and a header that is added to the beginning of the data string. A communication protocol expressed by a hexadecimal value excluding a specific value, and specifying a hexadecimal value indicating the specific value in a header.
JP2005336869A 2005-11-22 2005-11-22 Communication protocol Pending JP2007141127A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2005336869A JP2007141127A (en) 2005-11-22 2005-11-22 Communication protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2005336869A JP2007141127A (en) 2005-11-22 2005-11-22 Communication protocol

Publications (1)

Publication Number Publication Date
JP2007141127A true JP2007141127A (en) 2007-06-07

Family

ID=38203878

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2005336869A Pending JP2007141127A (en) 2005-11-22 2005-11-22 Communication protocol

Country Status (1)

Country Link
JP (1) JP2007141127A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009205369A (en) * 2008-02-27 2009-09-10 Omron Corp Communication control method in rfid system and communication controller for rfid tag
JP2020039115A (en) * 2018-08-31 2020-03-12 バイドゥ オンライン ネットワーク テクノロジー (ベイジン) カンパニー リミテッド Method, equipment and device for transmitting data of intelligent driving car

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009205369A (en) * 2008-02-27 2009-09-10 Omron Corp Communication control method in rfid system and communication controller for rfid tag
JP2020039115A (en) * 2018-08-31 2020-03-12 バイドゥ オンライン ネットワーク テクノロジー (ベイジン) カンパニー リミテッド Method, equipment and device for transmitting data of intelligent driving car
US11374688B2 (en) 2018-08-31 2022-06-28 Apollo Intelligent Driving Technology (Beijing) Co., Ltd. Data transmission method and device for intelligent driving vehicle, and device

Similar Documents

Publication Publication Date Title
Freed et al. Multipurpose internet mail extensions (MIME) part one: Format of internet message bodies
US5912752A (en) Method and apparatus for improving serial infrared asynchronous communication performance
CN106452607A (en) Method and device for transmitting and resolving information
JP2007141127A (en) Communication protocol
CN101196861A (en) DMA transfer apparatus, data transfer control method, and data transfer control program
CN111368508A (en) Data processing method, device, equipment and medium
JP2006211331A (en) Data encoder, data decoder, and data encoding/decode system
CN114070470A (en) Encoding and decoding method and device
CN111064560B (en) Data encryption transmission method and device, terminal and data encryption transmission system
CN111738266A (en) Image transmission method and device, electronic equipment and storage medium
CN102594989A (en) Data communication method, system and terminal
JP2008257564A (en) Print system and its firmware update method
JP2007274183A (en) Data transmission system, and data transmission/reception equipment
KR0170740B1 (en) Communication apparatus for programmable logic controller and data format thereof
JP3515526B2 (en) Coding method of control information in a communication system
KR20070014646A (en) Asc ii/unicode conversion method
KR20030033411A (en) Data conversion process binary to ASCII adaptable in serial interface
JP2009169798A (en) Data processing system, data conversion method, and program of this method
JPH0512154A (en) Data communication system
JP2786161B2 (en) Data transfer method
JPH0496108A (en) Nc program transfer method
JP2512031B2 (en) Data communication method
JP4618107B2 (en) Input device using keyboard and input method
CN115499523A (en) Service interaction system, method, electronic equipment and storage medium
CN105812861B (en) A kind of infrared transmitting method and system of module TV