Search code examples
c#.netindustrial

EEIP.NET Library


I use this library: https://github.com/rossmann-engineering/EEIP.NET to create an EtherNet/IP client and having a problem defining the O_T_Length data size.

This is the code I wrote. I expect it to insert the eeipClient.O_T_Length value of 34 to the data package, but the value I inspect on WireShark is 38

eeipClient.IPAddress = "192.168.2.172";

eeipClient.RegisterSession();

eeipClient.ConfigurationAssemblyInstanceID = 151;

eeipClient.O_T_InstanceID = 150;
eeipClient.O_T_Length = 32;
eeipClient.O_T_OwnerRedundant = false;
eeipClient.O_T_ConnectionType = Sres.Net.EEIP.ConnectionType.Point_to_Point;
eeipClient.RequestedPacketRate_O_T = 500000;

eeipClient.T_O_InstanceID = 100;
eeipClient.T_O_Length = 32;
eeipClient.T_O_OwnerRedundant = false;
eeipClient.T_O_ConnectionType = Sres.Net.EEIP.ConnectionType.Point_to_Point;
eeipClient.RequestedPacketRate_T_O = 500000;

eeipClient.ForwardOpen();

Going to the definition of ForwardOpen(), I see the following lines of code:

ushort num = 2;
if (O_T_RealTimeFormat == RealTimeFormat.Header32Bit) {
  num = 6;
}

if (O_T_RealTimeFormat == RealTimeFormat.Heartbeat) {
  num = 0;
}

ushort num4 = (ushort)(O_T_Length + num);

The initial value is 2, added to the O_T_Length I defined to be 32 will be 34. Somehow the result is 38.

[WireShark capture](https://i.sstatic.net/hVpI6.png)


Solution

  • Apparently, the libary assumes that you want to transmit a 32 Bit RUN/IDLE Header in O2T direction which would explain the four additional bytes you observe in the Wireshark trace.

    Without knowing the library specifically, you should try to set the O2T RealTimeFormat to "modeless" or something to prevent the client lib from doing this. What are the other possible values of the enum besides "heartbeat"? (you don't want that, since it resembles a null size transport).

    Having the RUN/IDLE header in O2T direction is very common for EtherNet/IP applications, so the library probably has this set as the default. Typically, PLCs have a key rotary switch which allows to switch between RUN (production mode) and IDLE (maintenance mode). Transmitted data must not be used by the application in the target device unless the system is in RUN. Might be any other application-level logic which controls this, though. Having no RUN/IDLE header in O2T direction is perfectly fine as well of course. Just make sure your originator and target are configured consistently (it is called implicit messaging for a reason).