technician94
Hi, I'm trying to get a program to work that interfaces with OpenPLC Runtime on Windows. It uses the EtherNet/IP protocol via PLC4x https://plc4x.apache.org/users/protocols/ethernet-ip.html

I can't seem to get the address format right, however. The PLC4x driver accepts the tag, but in the runtime log I see "ENIP: Received unsupported EtherNet/IP Type" and OpenPLC doesnt return anything at all. 

Can someone point me in the right direction? 

Thanks!
Quote 0 0
thiagoralves
EtherNet/IP on OpenPLC is still very experimental and might not support all types of communications. From the PLC4X documentation it says that "The PLC4X driver currently only supports the protected typed logical read with a limited number of data types". This type of message is supported by the OpenPLC driver, but perhaps the way PLC4X is assembling the message is not implemented on OpenPLC. Can provide a pcap capture of the requests PLC4X is trying to make?
Quote 0 0
technician94

Sure thing. I tried to make it as clean as possible. I'm also pretty sure that I'm getting that address wrong (especially after watching the traffic in this capture), but I hope this can at least give you an idea of how PLC4x assembles the message.

EDIT
Removed Google Drive link and replaced with .zip per recommendation below ðŸ˜

Quote 0 0
thiagoralves
Thanks! I'll check them out once I have some free time and see what's going on. Tip for future uploads, you can post a pcap here as long as you compress them first. The forum accepts .zip attachments 😉 
Quote 0 0
technician94
Thanks a bunch! I really appreciate the fast response time! Keep up the good work, I've learned a lot from OpenPLC so far!
Quote 0 0
thiagoralves
I checked the pcap quickly and it seems that I found the issue. OpenPLC needs the Rockwell addressing to be able to process the tags. Instead, it seems that you're sending IEC61131-3 locations in there as ASCII text (like "%QX0.0"). This makes PLC4X build an invalid request based on the ASCII name of the tag. Instead of doing this, try sending direct Rockwell addresses like I:1/0 or O:2/0
Quote 0 0
technician94
It seems as though the % sign is required. Checking the source code for PLC4x, the regex for eip tags is as follows:

^%(?<tag>[a-zA-Z_.0-9]+\[?[0-9]*\]?):?(?<dataType>[A-Z]*):?(?<elementNb>[0-9]*)


or according to the documentation:

%{tagname}[{startIndex}]:{numberOfElements}
%{tagname}[{startIndex}]:{numberOfElements}:{DataType}


Unfortunately Rockwell addresses don't fit this scheme and are rejected. 

I found it odd that they don't end their regex with a $, which means that something like %I:0/0 is a partial match, but nonetheless throws an exception 

org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException: Invalid field %I:0/0 invalid


Stripping off the /0 (as in %Q:0) isn't rejected by PLC4x but instead OpenPLC rejects it as unsupported.

Thanks!
Quote 0 0
thiagoralves
Try using something like AdvanceHMI with their Rockwell PLC5 driver. I know that works with OpenPLC. Check the request that AdvanceHMI is doing and compare it with PLC4x. Then post here the discrepancies you find. This might help us improve the enip driver on OpenPLC. Or even, if you want to "walk the second mile", you can help improve the enip driver directly. These are the files related with enip requests:

https://github.com/thiagoralves/OpenPLC_v3/blob/master/webserver/core/enipStruct.h
https://github.com/thiagoralves/OpenPLC_v3/blob/master/webserver/core/enip.cpp
https://github.com/thiagoralves/OpenPLC_v3/blob/master/webserver/core/pccc.cpp

They were written by college students on a project. Even though they did a good job, there is a lot to improve on them, and I don't have time to go over everything. If you find ways to improve, please let us know. Thanks!
Quote 0 0