JP2007141127A - Communication protocol - Google Patents
Communication protocol Download PDFInfo
- 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
Links
Images
Abstract
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
なお、特許文献1には、7ビットのASCIIコードを6ビットの短縮コードに変換することで、文字データを圧縮する方法が記載されている。特許文献2には、複数の文字列をASCIIコード中の制御コードに割り当てて符号化する方法が記載されている。
ところが、従来の通信プロトコルによると、データ列52中の数値データを二つのASCIIコードに変換しているので、1バイトの数値データを送るのに2バイトの電文長が必要になる。このため、多量の数値データを含むメッセージ51を送受信する際に、電文53の全長がいたずらに長くなり、通信時間がかかり、有料回線を使用する場合にパケット料等の通信費が高くつく問題点があった。また、多量の数値データをASCIIコードに変換すると、制御プログラムの負担が重くなるため、コンピュータによる他の処理が遅くなる不都合もあった。
However, according to the conventional communication protocol, the numerical data in the
そこで、本発明の目的は、コンピュータが数値データを含むメッセージの通信を効率よく行うことができる通信プロトコルを提供することにある。 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
図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
しかし、「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
この場合、実際の電文14がヘッダ13の表示に4バイトを必要とするため、“STX”にASCIIコードの「0x02」(図6参照)を指定する従来と比較し、ヘッダ13の電文長が4倍となる。しかし、実施例1の通信プロトコルによれば、例えば、ASCIIコードで200バイトを要したデータ列12の電文長が半分の100バイトまで圧縮される。このため、電文14の全長が差し引き96バイトに相当する長さだけ短くなる。従って、メッセージ11に含まれる数値データの量が増えるほど、通信時間を短縮でき、有料回線を利用する場合にパケット料等の通信費を節約できて、経済的かつ効率のよい通信を的確に行うことができる。
In this case, since the
図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
こうすれば、セル25のデータに基づいてコンピュータ3が受信した電文24の終わりを正しく認識できる。従って、ASCIIコードの“ETX”をメッセージ21から省略したとしても、通信になんらの支障をきたさない。その他の構成、作用効果は実施例1と同じである。
In this way, the end of the
図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
従って、実施例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
1 通信システム
2 ネットワーク
3 コンピュータ
4 通信プロトコル
11,21,31 メッセージ
12,22,32 データ列
13,23,33 ヘッダ
14,24,34 電文
DESCRIPTION OF SYMBOLS 1
Claims (1)
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.
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)
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 |
-
2005
- 2005-11-22 JP JP2005336869A patent/JP2007141127A/en active Pending
Cited By (3)
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 |