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 2021/11/17 23:56:26 UTC
[plc4x] branch develop updated: - Continued the work on the PROFINET driver after the big refactoring.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new a4a162a - Continued the work on the PROFINET driver after the big refactoring.
a4a162a is described below
commit a4a162abe22ac601547126f3fc44239abf122672
Author: cdutz <ch...@c-ware.de>
AuthorDate: Thu Nov 18 00:55:34 2021 +0100
- Continued the work on the PROFINET driver after the big refactoring.
---
.../apache/plc4x/java/profinet/ProfinetIoTest.java | 44 ++++++++++++++++++++++
.../apache/plc4x/java/profinet/ProfinetPoc.java | 9 +++--
.../resources/protocols/profinet/profinet.mspec | 33 ++++++++--------
3 files changed, 67 insertions(+), 19 deletions(-)
diff --git a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetIoTest.java b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetIoTest.java
new file mode 100644
index 0000000..49897dc
--- /dev/null
+++ b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetIoTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.plc4x.java.profinet;
+
+import org.apache.commons.codec.binary.Hex;
+import org.apache.plc4x.java.profinet.readwrite.DceRpc_Packet;
+import org.apache.plc4x.java.profinet.readwrite.io.DceRpc_PacketIO;
+import org.apache.plc4x.java.spi.generation.ReadBuffer;
+import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
+
+public class ProfinetIoTest {
+
+ public static void main(String[] args) throws Exception {
+ long val1 = -559939584;
+ long val2 = 3735027712l;
+ System.out.println(Long.toHexString(val1));
+ System.out.println(Long.toHexString(val2));
+ // -559939584 == ffffffffdea00000
+ // 3735027712l == 00000000dea00000
+
+ final byte[] rawResponse = Hex.decodeHex("04020a00100000000000a0de976cd111827100010904002a0100a0de976cd111827100a02442df7d29f2443745f2e246b8035e0ab26b8293a400000001000000000000000000ffffffff5a000000000000000000460000009401000000000000460000008101001e01000001654519352df3b6428f874371217c2b510002883f990006ef889281020008010000010001bbf08102000801000002000280008103000801000001000000c8");
+ ReadBuffer readBuffer = new ReadBufferByteBased(rawResponse);
+ final DceRpc_Packet dceRpc_packet = DceRpc_PacketIO.staticParse(readBuffer);
+ System.out.println(dceRpc_packet);
+ }
+
+
+}
diff --git a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetPoc.java b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetPoc.java
index b5c461a..1f09026 100644
--- a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetPoc.java
+++ b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetPoc.java
@@ -18,6 +18,7 @@
*/
package org.apache.plc4x.java.profinet;
+import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.profinet.readwrite.*;
import org.apache.plc4x.java.spi.generation.*;
@@ -35,16 +36,16 @@ public class ProfinetPoc {
// Send Profinet IO Context Manager (PNIO-CM) Connection Request (UDP)
DceRpc_Packet connectionRequest = new DceRpc_Packet(
- DceRpc_PacketType.REQUEST,
+ DceRpc_PacketType.REQUEST, true, false, false,
IntegerEncoding.BIG_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE,
- new DceRpc_ObjectUuid(0x0000, 0x0904, 0x002A),
+ new DceRpc_ObjectUuid(0x0001, 0x0904, 0x002A),
new DceRpc_InterfaceUuid_DeviceInterface(), generateActivityUuid(),
0, 0, DceRpc_Operation.CONNECT,
new PnIoCm_Packet_Req(404, 404, 0, 404,
Arrays.asList(
new PnIoCm_Block_ArReq((short) 1, (short) 0, PnIoCm_ArType.IO_CONTROLLER,
new Uuid(Hex.decodeHex("654519352df3b6428f874371217c2b51")), 2,
- new MacAddress(Hex.decodeHex("606D3C3DA9A3")),
+ new MacAddress(Hex.decodeHex("806d970ff777")),
new Uuid(Hex.decodeHex("dea000006c9711d1827100640008002a")),
false, false, false,
false, PnIoCm_CompanionArType.SINGLE_AR, false,
@@ -155,7 +156,7 @@ public class ProfinetPoc {
wb.writeLong(64, number.getLeastSignificantBits());
ReadBuffer rb = new ReadBufferByteBased(wb.getData());
- return new DceRpc_ActivityUuid(rb.readLong(32), rb.readInt(16), rb.readInt(16), rb.readBigInteger(64));
+ return new DceRpc_ActivityUuid(rb.readLong(32), rb.readInt(16), rb.readInt(16), rb.readByteArray(8));
} catch (SerializationException | ParseException e) {
// Ignore ... this should actually never happen.
}
diff --git a/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec b/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
index acd2054..543061b 100644
--- a/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
+++ b/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
@@ -96,30 +96,33 @@
// RPC Header {
// RPCVersion 4.10.3.2.1
[const uint 8 version '0x04' ]
- // RPCPacketType 4.10.3.2.2
+ // RPCPacketType 4.10.3.2.2 (8 bit)
[simple DceRpc_PacketType packetType ]
// PRCFlags 4.10.3.2.3
- [reserved bit 'false' ]
+ [reserved bit 'false' ]
[const bit broadcast 'false' ]
- [const bit idempotent 'false' ]
+ [simple bit idempotent ]
[const bit maybe 'false' ]
- [const bit noFragmentAcknowledgeRequested 'false' ]
+ [simple bit noFragmentAcknowledgeRequested ]
[const bit fragment 'false' ]
- [const bit lastFragment 'false' ]
- [reserved bit 'false' ]
+ [simple bit lastFragment ]
+ [reserved bit 'false' ]
// PRCFlags2 4.10.3.2.4
- [reserved uint 6 '0x00' ]
+ [reserved uint 6 '0x00' ]
[const bit cancelWasPending 'false' ]
- [reserved bit 'false' ]
- // RPCDRep 4.10.3.2.5
+ [reserved bit 'false' ]
+ // RPCDRep 4.10.3.2.5 (4 bit & 4 bit)
[simple IntegerEncoding integerEncoding ]
[simple CharacterEncoding characterEncoding ]
- // RPCDRep2 4.10.3.2.5
+ // RPCDRep2 4.10.3.2.5 (8 bit)
[simple FloatingPointEncoding floatingPointEncoding ]
+ // RPCDRep3 (8 bit shall be 0)
+ [reserved uint 8 '0x00' ]
// RPCSerialHigh 4.10.3.2.6
[const uint 8 serialHigh '0x00' ]
[batchSet byteOrder='integerEncoding ? "BIG_ENDIAN" : "LITTLE_ENDIAN"'
// RPCObjectUUID 4.10.3.2.8
+ // RPCObjectUUID 4.10.3.2.8
[simple DceRpc_ObjectUuid objectUuid ]
// RPCInterfaceUUID 4.10.3.2.9
[simple DceRpc_InterfaceUuid interfaceUuid ]
@@ -196,11 +199,11 @@
// the first parts are effected by endianess, and the last 8
// bytes are fixed big-endian. Therefore the complicated notation.
[type DceRpc_ActivityUuid
- [simple uint 32 data1 ]
- [simple uint 16 data2 ]
- [simple uint 16 data3 ]
+ [simple uint 32 data1 ]
+ [simple uint 16 data2 ]
+ [simple uint 16 data3 ]
// This part is described as a byte array, so the byte order is always big-endian
- [simple uint 64 data4 byteOrder='"BIG_ENDIAN"']
+ [array byte data4 count '8']
]
// There are some special MAC addresses reserved:
@@ -851,7 +854,7 @@
[enum uint 4 CharacterEncoding
['0x0' ASCII]
- ['0x0' EBCDIC]
+ ['0x1' EBCDIC]
]
[enum uint 8 FloatingPointEncoding