Closed amacierzynski closed 7 years ago
Hi,
this Java library is based on what I've learned from implementing the original C library, https://github.com/EPICSTools/ether_ip . That C library has been in production use for about a decade. The Java version has not. String support was always iffy. There was no good documentation, only experimental evidence that strings are transferred as a special case of structure, see https://github.com/EPICSTools/etherip/blob/master/src/etherip/types/CIPData.java#L144
For the C version of the library, writing strings has only been supported about a year ago, without corresponding updates to the Java library. Since you have a PLC set up with string tags, maybe you can check which type code your struct returns for the string, compare with the C version (relevant code should be in https://github.com/EPICSTools/ether_ip/blob/master/ether_ipApp/src/ether_ip.c ), fix it, and make a pull request when done?
Thanks, Kay
Hello,
Can you give us any tips how we should start with Strings if we would like to implement it by our own?
Thanks, Adam
Basically it's about increasing the log level to the point where you see every byte sent and received, then observe what's happening when trying to read and write a string tag, compare with the source code for the C version that reads/writes strings as a certain type of STRUCT, and fix the java version.
I might find a PLC here in the next couple days where I can do that, will keep you posted.
Try an update.
testString()
in EtherIPDemo.java
now reads and writes a string.
Oh man, that's great news. We will test it tomorrow.
Hello kasemir,
Unfortunately it is still not working for us. Please find complete list of logs below. Maybe it can help:
And here is complete Exception Stack trace:
You think that can be something wrong with our PLC configuration. As I know it is not like a real device, but something more like MockUp, which should work exactly like normal device.
If you need any help from us, just let me know.
Regards, Adam
Comparing your protocol trace with mine, I have a ControlLogix setup
INFO: Device vendor=0x1, device_type=0xC, revision=0x304, serial=0xFBEC, name='1756-ENBT/A'
while you have a CompactLogix setup
INFO: Device vendor=0x1, device_type=0xC, revision=0x302, serial=0xD915, name='1768-ENBT/A'
I've tried it with a basic controller string tag.
You are trying to access an element of a structure tag CogProLink.ProgName
, and I'm not sure if that's a controller tag, a program tag, or even a string tag at all.
When I read a string, I get a reply of type A0 02 CE 0F
(0x02A0, STRUCT, of detailed type 0x0FCE, STRING).
You get A0 02 55 A0
(0x02A0, STRUCT, of detailed type 0xA055, ??).
Can you try with a plain string controller tag, not a structure element? If that also fails, the issue might be that CompactLogix handles strings differently from ControlLogix. The software was written for ControlLogix. It happens to work for CompactLogix for the most part, but maybe strings are incompatible at this time?
We changed STRUCT_STRING(0x0FCE, 0);
definition to the STRUCT_STRING(0xA055, 0);
. Now we are receiving no errors. But String is empty. Unfortunately I am not sure if it should be empty or not, cause I have no access to PLC configuration.
We will try to clarify the exact output of this TAG and will come back to you. Nevertheless thank you for your effort.
EDIT: We run few threads, where we were writing and reading asynchronously and to be honest it is working. We were managed to read data from String, when second thread was writing to it, so probably our PLC is overwriting this String Tag to the empty one...
Thank you one more time.
Yes, I would expect it to be empty, looking at your hex dump on https://pastebin.com/954pCXAe the reply to the read request is this:
FINEST: Data read (84 bytes):
0000 - 6F 00 3C 00 00 53 02 11 00 00 00 00 46 75 6E 73 - o.<..S......Funs
0010 - 74 75 66 66 00 00 00 00 00 00 00 00 00 00 02 00 - tuff............
0020 - 00 00 00 00 B2 00 2C 00 CC 00 00 00 A0 02 55 A0 - ......,.......U.
0030 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
0040 - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
0050 - 00 00 00 00 - ....
You get A0 02 55 A0
(0x02A0, STRUCT, of detailed type 0xA055, ??) followed by a whole bunch of zeroes, that makes for a pretty empty string.
Have you tried a plain controller tag? Like "STRING MyTestString" instead of CogProLink.ProgName which looks like a structure element, maybe inside a program. Note that at least for ControlLogix PLCs, program tags are not accessible. They're private to the program. Only controller tags are visible on the network.
Ok, so we made a request to change a value of this parameter to another and now it is working perfectly! Thank you for your support.
Hi, We have a String Tag in out Allen Bradley device. There is no problem with gathering data for BOOLEAN, INT etc, but for a String we are receiving this error:
Any ideas? Regards, Adam