CIPメッセージ通信 UCMM
注意事項
ここで説明する内容とサンプルは「NJ/NXシリーズ CPUユニット内蔵 EtherNet/IPポート」(SBCD-377?)のユーザーズマニュアルとCX-Compoletで実際に通信した伝文を解析した内容を元に作成しています
EthernetIPのユーザーズマニュアルに記載のない内容も含まれており伝文の一部が不明な箇所があるため、ここでの説明はCIPメッセージ通信のプロトコルのイメージを掴む程度の内容になります
ここでダウンロードできるアプリは変数の読出し書込みは出来ますがテスト程度で使用してください
正式にCIPメッセージ通信をするときはCX-Compoletを使用してください
OMRON CX-Compolet
CX-Compoletの解説ページ
概略
PCはEthernet経由でネットワーク上のPLCなどのデバイスに対してCIP(Common Industrial Protocol)コマンドを送信することでメモリの値を読み書きすることができます
ここではCIPメッセージ通信のCLASS3とUCMM通信のうちUCMMを使ってPLCのメモリの値を読み出します
ちなみにCLASS3とUCMMはどちらもコネクション型のTCP/IPでの接続の上で、CIPコネクション型がCLASS3でCIP非コネクション型がUCMMというように区別されます
ここでは下記の構成で変数の値を読み出す手順を説明します
UCMMのメッセージの流れ
![]() |
TCP-IPで接続した後に |
IPのコネクションを開始する準備をするためにListServiceコマンドを送信します(カッコ内はコマンドコード) |
|
次にResisterSessionコマンドを送ってハンドル(Session Handle)を取得します このハンドルを次からのSendRRDataで使います |
|
SendRRDataの中のServiceに変数の読出しコマンドや書込みコマンドをセットして送信します | |
UnRegisterSessionを送って終了します |
メッセージのフォーマット
名称 | バイト数 | |
---|---|---|
Encapsulation Header | ||
Command | 2 | |
Length | 2 | |
SessionHandle | 4 | |
Status | 4 | |
Sender | 8 | |
Options | 4 | |
Command Specific Data | ||
コマンド | 可変長 |
NOTE
データはリトルエンディアンでセットします
各コマンドの送受信データ
名称 | バイト数 | データ | |||
---|---|---|---|---|---|
Encapsulation Header | |||||
Command | 2 | 0x0004 (ListService) | |||
Length | 2 | 0 | |||
SessionHandle | 4 | 0x00000000 | |||
Status | 4 | 0x00000000 | |||
Sender Context | 8 | 0x0000000000000000 | |||
Options | 4 | 0x00000000 |
受信データ例
名称 | バイト数 | データ | |||
---|---|---|---|---|---|
Encapsulation Header | |||||
Command | 2 | 0x0004 | |||
Length | 2 | 26 | |||
SessionHandle | 4 | 0x00000000 | |||
Status | 4 | 0x00000000 | |||
Sender Context | 8 | 0x0000000000000000 | |||
Options | 4 | 0x00000000 | |||
Command Specific Data | |||||
Item Count | 2 | 1 | |||
Item1 | Type ID | 2 | 0x0100 = List Service Response | ||
length | 2 | 20 | |||
Capability Flags | 2 |
0x0120 5bit=Support CIP Encapsulation 8bit=Supports CIP Class 0 or 1 |
|||
Name of Service | 16 | "Communications",0x0000 |
名称 | バイト数 | データ | |
---|---|---|---|
Encapsulation Header | |||
Command | 2 | 0x0065 (RegisterSession) | |
Length | 2 | 4 | |
SessionHandle | 4 | 0x00000000 | |
Status | 4 | 0x00000000 | |
Sender Context | 8 | 0x0000000000000000 | |
Options | 4 | 0x0000000000 | |
Command Specific Data | |||
Protcol Version | 2 | 1 | |
Option Flags | 2 | 0x0000 |
受信データ例
名称 | バイト数 | データ | |
---|---|---|---|
Encapsulation Header | |||
Command | 2 | 0x0065 | |
Length | 2 | 4 | |
SessionHandle | 4 |
0x0001016d ハンドルが入ります |
|
Status | 4 | 0x00000000 | |
Sender Context | 8 | 0x0000000000000000 | |
Options | 4 | 0x0000000000 | |
Command Specific Data | |||
Protcol Version | 2 | 1 | |
Option Flags | 2 | 0x0000 |
名称 | バイト数 | データ | ||||||
---|---|---|---|---|---|---|---|---|
Encapsulation Header | ||||||||
Command | 2 | 0x006f (SendRRData) | ||||||
Length | 2 | 30 | ||||||
SessionHandle | 4 | 0x0001016d | ||||||
Status | 4 | 0x00000000 | ||||||
Sender Context | 8 | 0x0100000000000000 | ||||||
Options | 4 | 0x0000000000 | ||||||
Command Specific Data | ||||||||
Interface Handle | 4 | 0x00000000 | ||||||
Timeout | 2 | 0x0000 | ||||||
Item Count | 2 | 2 | ||||||
Item1 | Type ID | 2 | 0x0000 (Null Address Item) | |||||
length | 2 | 0 | ||||||
Item2 | Type ID | 2 | 0x00b2 (Unconnected Data Item) | |||||
length | 2 | 14 | ||||||
Common Industrial Protocol | ||||||||
Service Code | 1 | 0x4c | ||||||
Request Path Length | 1 | 5 (word) | ||||||
Request Path | 10 |
0x9107+"testInt"+0x00 (奇数byteのときは0パディング) |
||||||
CIP Class Generic | ||||||||
Request Service Data | 2 | 0x0100 |
受信データ例
名称 | バイト数 | データ | ||||||
---|---|---|---|---|---|---|---|---|
Encapsulation Header | ||||||||
Command | 2 | 0x006f (SendRRData) | ||||||
Length | 2 | 24 | ||||||
SessionHandle | 4 | 0x0001016d | ||||||
Status | 4 | 0x00000000 | ||||||
Sender Context | 8 | 0x0100000000000000 | ||||||
Options | 4 | 0x0000000000 | ||||||
Command Specific Data | ||||||||
Interface Handle | 4 | 0x00000000 | ||||||
Timeout | 2 | 0 | ||||||
Item Count | 2 | 2 | ||||||
Item1 | Type ID | 2 | 0x0000 (Null Address Item) | |||||
length | 2 | 0 | ||||||
Item2 | Type ID | 2 | 0x00b2 (Unconnected Data Item) | |||||
length | 2 | 8 | ||||||
Common Industrial Protocol | ||||||||
Service | 1 | 0xcc (最上位ビットON + 0x4c) | ||||||
(Fixed) | 1 | 0x00 | ||||||
Status | General Status | 1 | 0x00 | |||||
Additional Status | 1 | 0x00 | ||||||
CIP Class Generic | ||||||||
Responce Service Data | ||||||||
Data Type | 1 | 0xc3 | ||||||
AddInfoLength | 1 | 0x00 | ||||||
Data | 2 | 0x3412 |
名称 | バイト数 | データ | |
---|---|---|---|
Encapsulation Header | |||
Command | 2 | 0x0066 (UnregisterSession) | |
Length | 2 | 0 | |
SessionHandle | 4 |
0x0001016d 切断するハンドルをセットします |
|
Status | 4 | 0x00000000 | |
Sender Context | 8 | 0x0000000000000000 | |
Options | 4 | 0x0000000000 |
受信データはありません
アプリケーション
![]() |
EtherntのSocket通信を使ってメッセージを送信するアプリケーションです |
![]() |
CIPコマンドの作成支援と対応機器にメッセージを送信するアプリケーションです |