https://github.com/digitalpetri/ethernet-ip
Asynchronous, non-blocking, EtherNet/IP client implementation for Java
https://github.com/digitalpetri/ethernet-ip
ethernet-ip java logix
Last synced: 9 months ago
JSON representation
Asynchronous, non-blocking, EtherNet/IP client implementation for Java
- Host: GitHub
- URL: https://github.com/digitalpetri/ethernet-ip
- Owner: digitalpetri
- License: apache-2.0
- Created: 2015-03-06T21:23:56.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-10T17:41:24.000Z (10 months ago)
- Last Synced: 2025-03-28T11:35:06.218Z (9 months ago)
- Topics: ethernet-ip, java, logix
- Language: Java
- Homepage:
- Size: 306 KB
- Stars: 154
- Watchers: 22
- Forks: 52
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - EtherNet/IP
README
# EtherNet/IP Client
[](https://travis-ci.org/digitalpetri/ethernet-ip)
[](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.digitalpetri.enip%22%20AND%20a%3A%22enip%22)
Asynchronous, non-blocking, EtherNet/IP client implementation for Java
# Maven
## EtherNet/IP Client
```xml
com.digitalpetri.enip
enip-client
1.4.1
```
## CIP Client
```xml
com.digitalpetri.enip
cip-client
1.4.1
```
# Quick Start
#### EtherNet/IP Example
```java
EtherNetIpClientConfig config = EtherNetIpClientConfig.builder("10.20.4.57")
.setSerialNumber(0x00)
.setVendorId(0x00)
.setTimeout(Duration.ofSeconds(2))
.build();
EtherNetIpClient client = new EtherNetIpClient(config);
client.connect().get();
client.listIdentity().whenComplete((li, ex) -> {
if (li != null) {
li.getIdentity().ifPresent(id -> {
System.out.println("productName=" + id.getProductName());
System.out.println("revisionMajor=" + id.getRevisionMajor());
System.out.println("revisionMinor=" + id.getRevisionMinor());
});
} else {
ex.printStackTrace();
}
});
client.disconnect().get();
// Call this before application / JVM shutdown
EtherNetIpShared.releaseSharedResources();
```
#### CIP Service Example
```java
EtherNetIpClientConfig config = EtherNetIpClientConfig.builder("10.20.4.57")
.setSerialNumber(0x00)
.setVendorId(0x00)
.setTimeout(Duration.ofSeconds(2))
.build();
// backplane, slot 0
PaddedEPath connectionPath = new PaddedEPath(
new PortSegment(1, new byte[]{(byte) 0}));
CipClient client = new CipClient(config, connectionPath);
client.connect().get();
GetAttributeListService service = new GetAttributeListService(
new PaddedEPath(new ClassId(0x01), new InstanceId(0x01)),
new int[]{4},
new int[]{2}
);
client.invokeUnconnected(service).whenComplete((as, ex) -> {
if (as != null) {
try {
ByteBuf data = as[0].getData();
int major = data.readUnsignedByte();
int minor = data.readUnsignedByte();
System.out.println(String.format("firmware v%s.%s", major, minor));
} catch (Throwable t) {
t.printStackTrace();
} finally {
Arrays.stream(as).forEach(a -> ReferenceCountUtil.release(a.getData()));
}
} else {
ex.printStackTrace();
}
});
client.disconnect().get();
// Call this before application / JVM shutdown
EtherNetIpShared.releaseSharedResources();
```
#### Logix Example
[See the logix-services README!](logix-services/README.md)
License
--------
Apache License, Version 2.0