EtherNet/IP (Industrial Protocol) .NET Library

时间:2016-03-02 10:53:21

标签: c# io protocols ethernet industrial

I have a I/O remote device (EIP-2017) with 8 analog inputs and it implements EtherNet/IP protocol for reading I/O values. I found on codeplex (https://eipnet.codeplex.com/) a library written in .net c# but it does not have documentation or example how to use it.

So, this is the target (I/O remote device) documentation:

We suggest users using Implicit Message communicate with EIP-2000. Implicit Messages are applied only for accessing the Input Instance 65 hex (101) and Output Instance 66 (102) of the Assembly Object in the object model. Before using Implicit Messages, you must use the Forward Open service with correct “Instance ID” and “Data length” settings of the Connection Manager Object to build a connection between the EtherNet/IP scanner and the EIP-2000. Afterwards, the Implicit Message can be used. The “Instance ID” of EIP-2000 modules are shown below, but the “Data length” is different from modules.

This device has the following,
Input (T->O) Instance ID: 0x65, Length: 53 bytes Out (O->T) Instance ID: 0x66, Length: 22 bytes Configuration Instance ID: 0x64, Length: 0 bytes

And I wrote these lines of code:

static void Main(string[] args)
        {
            byte[] sc = new byte[8] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
            byte[] path = new byte[] { 0x20, 0x04, 0x24, 0x64, 0x2C, 0x66, 0x2C, 0x65 };

            SessionInfo si = SessionManager.CreateAndRegister("192.168.2.227", senderContext: sc);
            si.SetConnectionParameters(101, 3000, 101, 803, 888);

            EIPNET.ConnectionManager.ForwardOpen(si, path);

            bool CIPok = EIPNET.EIP.SessionManager.VerifyCIP(si);

            EIPNET.EIP.EncapsPacket p = new EncapsPacket();
            p.Command = (ushort)EncapsCommand.ListIdentity;
            p.SessionHandle = si.SessionHandle;
            p.SenderContext = sc;
            p.Length = 0;
            //p.EncapsData = new byte[53];
            byte[] rec = si.SendData_WaitReply(p.Pack());
}

I'm registering the session and then open connection with Forward Open command and then...nothing...

Any information how to continue would be greatly appreciated. Thank you!

2 个答案:

答案 0 :(得分:1)

您是连接到PLC / CompactLogix还是通过以太网/ IP连接的任何设备? 此外,隐式消息传递(UDP)应仅用于关键任务。如果您只是从设备中的数据表中读取寄存器,则应使用显式消息传递(TCP / IP)。

答案 1 :(得分:0)

还有德国Hilscher公司的EtherNet / IP测试工具和库,可以在这里找到:https://kb.hilscher.com/pages/viewpage.action?pageId=97444743

编辑这些天似乎有多个图书馆。这是另一个似乎也正在积极维护的系统:http://eeip-library.de/

基本上,对于CIP类0/1,应打开一个封装会话,发送ForwardOpen,然后设备应开始向您发送输入数据UDP帧,并应开始将输出数据发送至该设备。这些可能是多播传输。 Wireshark跟踪对于告诉正在发生的事情非常有用。