You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/08/20 19:36:50 UTC
[incubator-plc4x] branch feature/ethernet-ip updated: Adjusted the
poc to latest changes in the enip driver
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/ethernet-ip
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git
The following commit(s) were added to refs/heads/feature/ethernet-ip by this push:
new 8bec538 Adjusted the poc to latest changes in the enip driver
8bec538 is described below
commit 8bec538edd85a667f2830d0b5decdd5e7c1959a3
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Aug 20 21:36:47 2018 +0200
Adjusted the poc to latest changes in the enip driver
---
.../org/apache/plc4x/java/ethernetip/EnipTest.java | 46 +---------------------
1 file changed, 2 insertions(+), 44 deletions(-)
diff --git a/plc4j/protocols/ethernetip/src/test/java/org/apache/plc4x/java/ethernetip/EnipTest.java b/plc4j/protocols/ethernetip/src/test/java/org/apache/plc4x/java/ethernetip/EnipTest.java
index 9cd6c69..41edb06 100644
--- a/plc4j/protocols/ethernetip/src/test/java/org/apache/plc4x/java/ethernetip/EnipTest.java
+++ b/plc4j/protocols/ethernetip/src/test/java/org/apache/plc4x/java/ethernetip/EnipTest.java
@@ -1,21 +1,15 @@
package org.apache.plc4x.java.ethernetip;
-import com.digitalpetri.enip.EtherNetIpClient;
import com.digitalpetri.enip.EtherNetIpClientConfig;
import com.digitalpetri.enip.cip.CipClient;
import com.digitalpetri.enip.cip.epath.EPath;
import com.digitalpetri.enip.cip.epath.LogicalSegment;
import com.digitalpetri.enip.cip.epath.PortSegment;
-import com.digitalpetri.enip.cip.services.GetAttributeListService;
import com.digitalpetri.enip.cip.services.GetAttributeSingleService;
-import com.digitalpetri.enip.commands.ListIdentity;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import io.netty.buffer.UnpooledDirectByteBuf;
-import io.netty.util.ReferenceCountUtil;
import java.time.Duration;
-import java.util.Arrays;
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -55,55 +49,19 @@ public class EnipTest {
GetAttributeSingleService service = new GetAttributeSingleService(
new EPath.PaddedEPath(new LogicalSegment.ClassId(0x04), new LogicalSegment.InstanceId(0x69), new LogicalSegment.AttributeId(0x03)));
- ////////////////////////////////////////////////////////////////
- // Doesn't work:
- client.invokeUnconnected(service).whenComplete((as, ex) -> {
+ client.invoke(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();
- }
- });
-
- ////////////////////////////////////////////////////////////////
- // Works:
- ByteBuf buf = Unpooled.buffer();
- service.encodeRequest(buf);
- client.sendUnconnectedData(buf).whenComplete((as, ex) -> {
- if (as != null) {
- try {
- byte serviceId = as.readByte();
- boolean response = (serviceId & 128) != 0;
- serviceId = (byte) (serviceId & (byte) 127);
- if((serviceId != 0x0E) || !response) {
- System.out.println("Error");
- }
- // Reserved
- as.readByte();
- byte status = as.readByte();
- byte statusSize = as.readByte();
short value = as.readShort();
-
System.out.println(String.format("Value is %s", value));
} catch (Throwable t) {
t.printStackTrace();
- } finally {
-
}
} else {
ex.printStackTrace();
}
});
+
}
}