ornl-epics / etherip

Java lib. for Ethernet/IP (AllenBradley ControlLogix, Compact Logix PLCs)
Eclipse Public License 1.0
111 stars 69 forks source link

Read single tag from AB CompactLogix 5380 #32

Closed MichaelMS91 closed 4 years ago

MichaelMS91 commented 4 years ago

Hello!

I am using an Allen-Bradley CompactLogix 5380. I am able to connect with this device but when I try to read tags with readTag function, it happens an exception.

My connection is established just like:

EtherNetIP plc = new EtherNetIP(mIp,mId); try { plc.connectTcp(); } catch (CipException cipe){

And my reading code is like:

String message = "var1"; CIPData data = null; try { data = plc.readTag(message); } catch (CipException cipe){ ...

I am trying to read var1 variable which is its name in my PLC. I have declared it as Local Tag in my MainRoutine and later as Output Parameter and Public Parameter with Producer Type. I declared it also as a Tag in Controller Tags but always I receive the same error:

etherip.data.CipException: Status: 0x01 [Connection failure, A connection related service failed along the connection path.] - Extended: 0x312 [LINK ADDRESS NOT VALID, Link Address specified in Port Segment Not Valid This extended status code is the result of a port segment that specifies a link address that is not valid for the target network type. This extended status code shall not be used for link addresses that are valid for the target network type but do not respond.]

Could someone tell me how to read that tag? Must I do anything more before trying to read it?

Thanks in advance

kasemir commented 4 years ago

What is your 'mId' in new EtherNetIP(mIp,mId)?

kasemir commented 4 years ago

Also add something like Logger.getLogger("").setLevel(Level.ALL); to get a complete output of everything read and written to better see where it fails.

MichaelMS91 commented 4 years ago

What is your 'mId' in new EtherNetIP(mIp,mId)?

It was the Id that I assigned to the PLC. It was wrong, its value was 1 instead of 0. When I changed it, the program started to run normally.

Thanks a lot!

kasemir commented 4 years ago

Yeah, 'slot' needs to be the slot number, counting from 0, of the controller on the backplane.