Giter VIP home page Giter VIP logo

etherip's People

Contributors

aaron-bru avatar dependabot[bot] avatar kasemir avatar laszlopataki avatar spelletier avatar wz2b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etherip's Issues

Example for Boolean Array

I am trying to read bool[300] array, I read about the 500bytes limit for plc.
Ideally I'd like to read one at a time, but that fails due to the buffer limit. What is the best way to read an array? I couldn't find an example on the test classes.

I tried, reading a smaller array of 32 indices:
plc.readTag("Bools", short(32))
plc.readTag("Bools")

Should I use another method for arrays?

[question] Maybe you consider joining forces with Apache PLC4X?

I am throwing this as an issue since I have no contact to you and would like to see opinion of others. Apache PLC4X has support for Ethernet/IP which was done a while ago. Primary maintainer who did it is currently inactive. Given that I noticed some new patches on your end I wanted to check with you whether you would be interested to see cooperation with bigger project. For clarity - I did not audit your library to deeply - I saw it is categorized under ethernet-ip and have bunch of stars.

Apache PLC4X offers unified API to access industrial equipment. Currently it does support S7 (Siemens)/ADS (Beckhoff)/Modbus/CANopen/OPC UA (currently through Eclipse Milo but on the way to be swapped) and couple more. For developer API is same for each of above standards.

On benefit side for you, what PLC4X can offer to you:

Regardless of your answer we welcome your opinion! Team is mix of EU and US people who are loosely coupled. There is no direct association with any major hardware manufacturer. Code is licensed under Apache License v2 (a bit more liberal than EPL you use). Community health is supervised by Apache Software Foundation.

Request for RSWho like capability

Dear developer,
Great piece of code!

I'm looking for a java code that simulates RSWho. In other words I'm looking for an application that broadcast a "CIP-ping" request (similar to what RSWho does) and get a list of all Rockwell PLCs includes its device info (such as device name, type, version etc).
I know this currently does not exist but I wonder if it is something you can developed?

Thanks

Error writing more than 7 tags in a batch

Hello,

I am seeing an exception when attempting to Write batches of tags when the batch size exceeds 7 tags.

For all tags attempted, the tag data is all of type BOOL. Writing to the tags individually works and in batch groups of 2-7 the transactions is successful. Attempting to write a batch of 8 or more tags throws an exception with the following stack:

java.nio.BufferOverflowException at java.base/java.nio.Buffer.nextPutIndex(Unknown Source) at java.base/java.nio.DirectByteBuffer.put(Unknown Source) at etherip.types.CNSymbolPath$PathElement.encodeElementName(CNSymbolPath.java:114) at etherip.types.CNSymbolPath$PathElement.encode(CNSymbolPath.java:92) at etherip.types.CNSymbolPath.encode(CNSymbolPath.java:209) at etherip.protocol.MessageRouterProtocol.encode(MessageRouterProtocol.java:70) at etherip.protocol.CIPMultiRequestProtocol.encode(CIPMultiRequestProtocol.java:82) at etherip.protocol.MessageRouterProtocol.encode(MessageRouterProtocol.java:79) at etherip.protocol.UnconnectedSendProtocol.encode(UnconnectedSendProtocol.java:79) at etherip.protocol.SendRRDataProtocol.encode(SendRRDataProtocol.java:72) at etherip.protocol.Encapsulation.encode(Encapsulation.java:129) at etherip.protocol.TcpConnection.write(TcpConnection.java:62) at etherip.protocol.Connection.execute(Connection.java:120) at etherip.EtherNetIP.writeTags(EtherNetIP.java:589) ... Error in Writing tags: java.nio.BufferOverflowException

The line throwing the error in CNSymbolPath is:
buf.put((byte) path.length());

Are there any intended limits to writing batches larger than 7 tags?

Thank you for your help and for developing this library!

edit: added code block styling

Read Tags from my AB Micrologix 1400

Hi All,
I want to use your library to read tags from my PLC AB Micrologix 1400
whenever I try to read tag "N7:0" my code goes in exeception.

What do you think?

this is my code:

package testplc;

import etherip.types.CIPData;
import etherip.types.CIPData.Type;
import etherip.*;

/**
*

  • @author Luca
    */
    public class TestPLC {

    /**

    • @param args the command line arguments
      /
      public static void main(String[] args) {
      EtherNetIP plc = new EtherNetIP("172.16.1.1", 0);
      try{
      plc.connect();
      System.out.println("\n
      \n* Connected:\n_\n");
      System.out.println(plc);
      System.out.println("\n_\n* Individual read/write:\n*\n");

      CIPData value = plc.readTag("N7:0");
      System.out.println(value);
      }

      catch(Exception ex)
      {
      System.out.println(ex.getMessage());
      }

    }
    }

And this is my output:
EtherIP address '172.16.1.1', session 0x75c83718
Device vendor=0x1, device_type=0xE, revision=0xA02, serial=0x30ED, name='1766-L32BXB B/10.00'

  • Individual read/write:
    *

Expected CIP_ReadData_Reply (0xCC), got CM_Unconnected_Send_Reply (0xD2)

Unable to read Strings

Hi,

I am trying to read strings but I get "Type STRING (0x00D0) not handled" message. Please, would you help me to implement this new type?

Using EtherNetIP and Connection

Hello, I need to be able to use the EtherNetIP class, as well as its underlying Connection, specifically the execute() and getSession() methods. I'm using a simple accessor, but I'm happy to submit a different pull request. Some ideas are:

  • getConnection() accessor
  • exposing execute() and getSession() in EtherNetIP
  • Adding a dependency injection constructor or initializer to allow passing in a Connection object

Thanks

Unable to write STRUCT value

Hi,

I am not able to write Message type data to PLC, When i read the value and check the Type , it says "STRUCT" and when I use the same to write it says "(CIP type does not match object type)"

final byte[] data = new byte[] { (byte)0xCE, (byte)0x0F, 7, 0, 0, 0, 'w', 'j', 'h', ' ', '1', '2', '4' };
CIPData value1 = new CIPData(Type.STRUCT, data);
plc.writeTag("S1_ScreenId", value1);

Below is the finest logs.

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection write
FINER: Protocol Encoding
Encapsulation Header
UINT command : SendRRData (0x006F)
UINT length : 64
UDINT session : 0x1002D600
UDINT status : 0x00000000
USINT context[8] : 'Funstuff'
UDINT options : 0x00000000
Send RR Data
UDINT interface handle : 0
UINT timeout : 0
UINT count (addr., data): 2
UINT address type : 0x0 (UCMM)
UINT address length : 0x00
UINT data type : 0xB2 (Unconnected Message)
UINT data length : 48
MR Request
USINT service : CM_Unconnected_Send (0x52)
USINT path : Path (2 el) Class(0x20) 0x6 (ConnectionManager), instance(0x24) 1
CM_Unconnected_Send
USINT tick_time : 10
USINT ticks : -16
UINT message size : 33
/// embedded message /// (33 bytes)
MR Request
USINT service : CIP_WriteData (0x4D)
USINT path : Path Symbol(0x91) 'S1_ScreenId', 0x00
USINT type, data : 'wjh 124'
///\ embedded message ///
USINT pad : 0 (odd length message)
USINT path size : 1 words
USINT reserved : 0
USINT port 1, slot 0

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection write
FINEST: Data sent (88 bytes):
0000 - 6F 00 40 00 00 D6 02 10 00 00 00 00 46 75 6E 73 - [email protected]
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 30 00 52 02 20 06 24 01 0A F0 - ......0.R. .$...
0030 - 21 00 4D 07 91 0B 53 31 5F 53 63 72 65 65 6E 49 - !.M...S1_ScreenI
0040 - 64 00 A0 02 01 00 CE 0F 07 00 00 00 77 6A 68 20 - d...........wjh
0050 - 31 32 34 00 01 00 01 00 - 124.....

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection read
FINEST: Data read (46 bytes):
0000 - 6F 00 16 00 00 D6 02 10 00 00 00 00 46 75 6E 73 - o...........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 06 00 CD 00 FF 01 07 21 - .............!

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection read
FINER: Protocol Decoding
Encapsulation Header
UINT command : SendRRData (0x006F)
UINT length : 22
UDINT session : 0x1002D600
UDINT status : 0x00000000 (OK)
USINT context[8] : 'Funstuff'
UDINT options : 0x00000000
Received RR Data
UDINT interface handle : 0
UINT timeout : 0
UINT count (addr., data): 2
UINT address type : 0x0 (UCMM)
UINT address length : 0
UINT data type : 0xB2 (Unconnected Message)
UINT data length : 6
MR Response
USINT service : CIP_WriteData_Reply (0xCD)
USINT reserved : 0x0
USINT status : 0xffffffff ()
USINT ext. stat. size : 0x1
USINT ext status : 0x2107 (CIP type does not match object type)

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection write
FINER: Protocol Encoding
Encapsulation Header
UINT command : UnRegisterSession (0x0066)
UINT length : 0
UDINT session : 0x1002D600
UDINT status : 0x00000000
USINT context[8] : 'Funstuff'
UDINT options : 0x00000000

Jun 21, 2016 4:32:07 PM etherip.protocol.Connection write
FINEST: Data sent (24 bytes):
0000 - 66 00 00 00 00 D6 02 10 00 00 00 00 46 75 6E 73 - f...........Funs
0010 - 74 75 66 66 00 00 00 00 - tuff....

Bad decoding of revision & serial (?)

Dear developer,
In your project, as part of the connect procedure we get the device info, in particular the revision and serial of the PLC.
I noted that these two values, while running etherip are different then it displayed in RSLinx.
As for the revision - you considered the revision's 2 bytes as a short, while RSLinx are using each byte as a number the first is kind of major revision number and the second is minor revision number, so eventually they display it as, for instance, 2.4 and I wonder from your experience what data type the revision number is?
In regards to the serial - while sniffing the network (wireshark) I see that the revision number is 4 bytes long while you consider it as short.

Please note that I'm using MicroLogic PLC (the connect phase is no different than the PLCs you do support) and all I care is connecting to the PLC not reading tags from it.
I saw that every thing works fine besides these 2 exceptions.

I'm new with CIP and I would appreciate your help.
Many thanks!

90 Length of String

Hello, when I try to write less than 90 length of string I got '0x13 Not enough data, The service did not supply enough data to perform the specified operation.' Exception and when I try to write more than 90 length of string there is no problem but when try to read it I got BufferUnderflowException my device is a CompactLogix 5380, 5069-L320ER.

Do you have any idea about it? thank you.

I have some questions about this library for CJ2-M PLC

Hello everyone,

I created a java project for using your library, and also I have a CJ2-M PLC (CPU34).

I have some questions:

  1. It looks like there is an limitation in the PLC. I mean, I can declarate only 2000 vars in the PLC. So is it possible to access to the PLC with the zone and position? for instance: DM102, DM106?
  2. If my previous question is not possible, in that case is it possible to access to an array in the PLC for setting values? myarrayinthePLC[2] = MY_INTEGER_VALUE; or myarrayinthePLC = MY_INTEGER_VALUES;

Problems compiling etherip classes

Hi, I'm having problems compiling the classes, I've tried putting the files like in the package structure, each file inside its directory but I'm always getting import errors when compiling, could you please tell me how to compile all the classes, how to locate them in the directories, thanks in advance

Issues with getting an array from a tag.

Hello

I have tried to get an array of Real or DINT by doing this:

CIPData cip = plc.readTag("Cycle_Data_Time[1]");

and it gives me this
`Exception in thread "main" java.lang.NullPointerException
at etherip.protocol.CIPReadDataProtocol.decode(CIPReadDataProtocol.java:43)
at etherip.protocol.MessageRouterProtocol.decode(MessageRouterProtocol.java:103)
at etherip.protocol.UnconnectedSendProtocol.decode(UnconnectedSendProtocol.java:92)
at etherip.protocol.SendRRDataProtocol.decode(SendRRDataProtocol.java:94)
at etherip.protocol.Encapsulation.decode(Encapsulation.java:190)
at etherip.protocol.Connection.read(Connection.java:142)
at etherip.protocol.Connection.execute(Connection.java:158)
at etherip.EtherNetIP.readTag(EtherNetIP.java:153)
at data_collection.Data_Collection.(Data_Collection.java:27)

It works fine when i do not use the brackets and it only gives me the first item in the array.

Am i missing something?

Help with BOOL write

I've been trying to use this library for a write and I can't seem to get it to write the values successfully. The read seems to work fine, but the write has no effect on the PLC. I"ve successfully done a write using Advanced HMI, so I know that the PLC is okay. Here is the code I was using:

plc.connect();
CIPData tag = new CIPData(CIPData.Type.BOOL, 2);
tag.set(0, 1);
plc.writeTag(PLC_BOOL_TIMER_ENABLE, tag);
plc.close();

Any help is appreciated.

reconnection with PLC

Hi,

I am using the tcp(etherneIp) connection with plc at the start of the initialization, but if the plc is stopped then we are getting the exception as 

java.util.concurrent.ExecutionException: java.io.IOException: An existing connection was forcibly closed by the remote host
at sun.nio.ch.PendingFuture.get(PendingFuture.java:202)[:1.8.0_151]
at etherip.protocol.TcpConnection.write(TcpConnection.java:70)[EthernetIp-0.0.1-SNAPSHOT.jar:]
at etherip.protocol.Connection.execute(Connection.java:120)[EthernetIp-0.0.1-SNAPSHOT.jar:]
at etherip.EtherNetIP.executeMultiMessages(EtherNetIP.java:509)[EthernetIp-0.0.1-SNAPSHOT.jar:]
at etherip.EtherNetIP.sendMultiMessages(EtherNetIP.java:491)[EthernetIp-0.0.1-SNAPSHOT.jar:]
at etherip.EtherNetIP.readTags(EtherNetIP.java:449)[EthernetIp-0.0.1-SNAPSHOT.jar:]
at etherip.EtherNetIP.readTags(EtherNetIP.java:411)[EthernetIp-0.0.1-SNAPSHOT.jar:]

So , I implemented the reconncetion with TCP, if i will get the above exception message, but after few times tried to connecting to PLC, still the PLC is not up then i got the exception related to the Exceutor threads.

Please help me for reconnection of PLC, if it is down.

it may block here when the ethernetip server never reply

public void read(final ProtocolDecoder decoder) throws Exception
{
    // Read until protocol has enough data to decode
    this.buffer.clear();
    do
    {
        this.channel.read(this.buffer).get(this.timeout_ms, MILLISECONDS);
    }
    while (this.buffer.position() < decoder.getResponseSize(this.buffer));

---------------------------------------------------> I fix that by the code below
int readTryCount = 0;
do
{
readTryCount++;
if(readTryCount >= maxReadTryCount){
throw new TimeoutException("read time out");
}
this.channel.read(this.buffer).get(this.timeout_ms, MILLISECONDS);
}
while (this.buffer.position() < decoder.getResponseSize(this.buffer));

No licence information

I'd like to use some of this code, but can't find a Licence file.

What open source licence is this shared under? If it's not open source, you may want to make the library private. If it is open source, providing a licence file lets everyone know what rules to follow regarding important it. For example, my company won't allow certain open source licenses to be used internally (GPL3, etc).

communicate with Allen Bradley Micro850

Hi, I like to use this driver for communicate with Allen Bradley Micro850. The bigest difference with a CompactLogix is the Micro850 doesn't have slot number. I found in other driver the connection path is ConnectionPath = [0x20, 0x02, 0x24, 0x01] not ConnectionPath = [0x01, self.ProcessorSlot, 0x20, 0x02, 0x24, 0x01] like CompactLogix. I don't have many experience with java programation but do you think this program need many modification to be able to communicate?

Add to CNService enum

Hello, I need to add some values to the CNService enum, I'm not sure if this is something you'd want merged in or not. If so the ones I need are ForwardOpen(0x54) and ForwardClose(0x4E) which I can submit.

Alternatively, I've read the easiest way to allow adding at runtime is to have the enum implement an interface which is used throughout the library, which other applications can then implement as needed. I don't mind attempting this if it's preferred.

Read single tag from AB CompactLogix 5380

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

Lambda in Protocol/Transaction class

Is there any particular reason why one class out of the whole project is using lambda?
Project might reach more people that are still running in java 1.7

The only sole reason why the project doesn't compile in java 1.7 is because the lambda function which then gets converted to regular anonymous function, problem is LongBinaryOperation class doesn't exist in 1.7

Modified code, ran Transaction unittest and passed:

static long nextTransaction()
    {

        if(transaction.get() > 0xffffffffL){
            transaction.set(1);
        } else{
            transaction.incrementAndGet();
        }

        return transaction.get();

Original code below:


        return transaction.incrementAndGet(1, new LongBinaryOperator() {
            @Override
            public long applyAsLong(long value, long plus) {
                long result = value + plus;
                if (result > 0xffffffffL)
                    return 1;
                return result;
            }
        });
    }

I will test in the plc lab, anyways my usage doesn't require tons of transactions I highly doubt I will ever get to the max,I just need to read some tags for a backup utility I am building, and all our servers run on 1.7 and I don't foresee IT's updating anytime soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.