You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2023/02/04 09:34:14 UTC
[plc4x] branch develop updated: fix(plc4j/profinet): Fixed some issues around parsing gsd files and vendor id formats
This is an automated email from the ASF dual-hosted git repository.
hutcheb 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 077219813d fix(plc4j/profinet): Fixed some issues around parsing gsd files and vendor id formats
077219813d is described below
commit 077219813d94068ea340cadf05f226546f56388d
Author: Ben Hutcheson <be...@gmail.com>
AuthorDate: Sat Feb 4 10:31:03 2023 +0100
fix(plc4j/profinet): Fixed some issues around parsing gsd files and vendor id formats
---
.../PnDcp_Block_DevicePropertiesNameOfStation.java | 22 ++++++++++++++++++++--
.../plc4x/java/profinet/device/ProfinetDevice.java | 10 +++++-----
.../java/profinet/gsdml/ProfinetDataItem.java | 7 +++++++
.../resources/protocols/profinet/profinet.mspec | 1 +
4 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Block_DevicePropertiesNameOfStation.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Block_DevicePropertiesNameOfStation.java
index 7a3226e372..d2445e8867 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Block_DevicePropertiesNameOfStation.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnDcp_Block_DevicePropertiesNameOfStation.java
@@ -51,6 +51,8 @@ public class PnDcp_Block_DevicePropertiesNameOfStation extends PnDcp_Block imple
// Arguments.
protected final Integer blockLength;
+ // Reserved Fields
+ private Integer reservedField0;
public PnDcp_Block_DevicePropertiesNameOfStation(byte[] nameOfStation, Integer blockLength) {
super();
@@ -68,6 +70,12 @@ public class PnDcp_Block_DevicePropertiesNameOfStation extends PnDcp_Block imple
int startPos = positionAware.getPos();
writeBuffer.pushContext("PnDcp_Block_DevicePropertiesNameOfStation");
+ // Reserved Field (reserved)
+ writeReservedField(
+ "reserved",
+ reservedField0 != null ? reservedField0 : (int) 0x0000,
+ writeUnsignedInt(writeBuffer, 16));
+
// Array Field (nameOfStation)
writeByteArrayField("nameOfStation", nameOfStation, writeByteArray(writeBuffer, 8));
@@ -94,6 +102,9 @@ public class PnDcp_Block_DevicePropertiesNameOfStation extends PnDcp_Block imple
int lengthInBits = super.getLengthInBits();
PnDcp_Block_DevicePropertiesNameOfStation _value = this;
+ // Reserved Field (reserved)
+ lengthInBits += 16;
+
// Array field
if (nameOfStation != null) {
lengthInBits += 8 * nameOfStation.length;
@@ -119,6 +130,9 @@ public class PnDcp_Block_DevicePropertiesNameOfStation extends PnDcp_Block imple
int startPos = positionAware.getPos();
int curPos;
+ Integer reservedField0 =
+ readReservedField("reserved", readUnsignedInt(readBuffer, 16), (int) 0x0000);
+
byte[] nameOfStation =
readBuffer.readByteArray("nameOfStation", Math.toIntExact((blockLength) - (2)));
@@ -131,23 +145,27 @@ public class PnDcp_Block_DevicePropertiesNameOfStation extends PnDcp_Block imple
readBuffer.closeContext("PnDcp_Block_DevicePropertiesNameOfStation");
// Create the instance
- return new PnDcp_Block_DevicePropertiesNameOfStationBuilderImpl(nameOfStation, blockLength);
+ return new PnDcp_Block_DevicePropertiesNameOfStationBuilderImpl(
+ nameOfStation, blockLength, reservedField0);
}
public static class PnDcp_Block_DevicePropertiesNameOfStationBuilderImpl
implements PnDcp_Block.PnDcp_BlockBuilder {
private final byte[] nameOfStation;
private final Integer blockLength;
+ private final Integer reservedField0;
public PnDcp_Block_DevicePropertiesNameOfStationBuilderImpl(
- byte[] nameOfStation, Integer blockLength) {
+ byte[] nameOfStation, Integer blockLength, Integer reservedField0) {
this.nameOfStation = nameOfStation;
this.blockLength = blockLength;
+ this.reservedField0 = reservedField0;
}
public PnDcp_Block_DevicePropertiesNameOfStation build() {
PnDcp_Block_DevicePropertiesNameOfStation pnDcp_Block_DevicePropertiesNameOfStation =
new PnDcp_Block_DevicePropertiesNameOfStation(nameOfStation, blockLength);
+ pnDcp_Block_DevicePropertiesNameOfStation.reservedField0 = reservedField0;
return pnDcp_Block_DevicePropertiesNameOfStation;
}
}
diff --git a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java
index dc076a9094..fc1c6c8a3e 100644
--- a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java
+++ b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/device/ProfinetDevice.java
@@ -424,7 +424,7 @@ public class ProfinetDevice implements PlcSubscriber{
ProfinetDeviceContext.ARUUID,
deviceContext.getSessionKey(),
deviceContext.getLocalMacAddress(),
- new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.valueOf(deviceId), Integer.valueOf(vendorId)),
+ new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.decode("0x" + deviceId), Integer.decode("0x" + vendorId)),
false,
deviceContext.isNonLegacyStartupMode(),
false,
@@ -537,7 +537,7 @@ public class ProfinetDevice implements PlcSubscriber{
IntegerEncoding.BIG_ENDIAN,
CharacterEncoding.ASCII,
FloatingPointEncoding.IEEE,
- new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.valueOf(deviceId), Integer.valueOf(vendorId)),
+ new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.decode("0x" + deviceId), Integer.decode("0x" + vendorId)),
new DceRpc_InterfaceUuid_DeviceInterface(),
deviceContext.getUuid(),
0,
@@ -678,7 +678,7 @@ public class ProfinetDevice implements PlcSubscriber{
return new DceRpc_Packet(
DceRpc_PacketType.REQUEST, true, false, false,
IntegerEncoding.BIG_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE,
- new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.valueOf(deviceId), Integer.valueOf(vendorId)),
+ new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.decode("0x" + deviceId), Integer.decode("0x" + vendorId)),
new DceRpc_InterfaceUuid_DeviceInterface(),
deviceContext.getUuid(),
0,
@@ -742,7 +742,7 @@ public class ProfinetDevice implements PlcSubscriber{
return new DceRpc_Packet(
DceRpc_PacketType.REQUEST, true, false, false,
IntegerEncoding.BIG_ENDIAN, CharacterEncoding.ASCII, FloatingPointEncoding.IEEE,
- new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.valueOf(deviceId), Integer.valueOf(vendorId)),
+ new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.decode("0x" + deviceId), Integer.decode("0x" + vendorId)),
new DceRpc_InterfaceUuid_DeviceInterface(),
deviceContext.getUuid(),
0,
@@ -824,7 +824,7 @@ public class ProfinetDevice implements PlcSubscriber{
IntegerEncoding.BIG_ENDIAN,
CharacterEncoding.ASCII,
FloatingPointEncoding.IEEE,
- new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.valueOf(deviceId), Integer.valueOf(vendorId)),
+ new DceRpc_ObjectUuid((byte) 0x00, 0x0001, Integer.decode("0x" + deviceId), Integer.decode("0x" + vendorId)),
new DceRpc_InterfaceUuid_ControllerInterface(),
activityUuid,
0,
diff --git a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/gsdml/ProfinetDataItem.java b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/gsdml/ProfinetDataItem.java
index 1889622e9d..7a0d67249e 100644
--- a/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/gsdml/ProfinetDataItem.java
+++ b/plc4j/drivers/profinet/src/main/java/org/apache/plc4x/java/profinet/gsdml/ProfinetDataItem.java
@@ -40,6 +40,9 @@ public class ProfinetDataItem {
@JacksonXmlProperty(isAttribute=true, localName="TextId")
private String textId;
+ @JacksonXmlProperty(isAttribute=true, localName="Length")
+ private int length;
+
@JacksonXmlProperty(isAttribute=true, localName="UseAsBits")
private boolean useAsBits;
@@ -51,6 +54,10 @@ public class ProfinetDataItem {
return textId;
}
+ public int getLength() {
+ return length;
+ }
+
public boolean isUseAsBits() {
return useAsBits;
}
diff --git a/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec b/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
index 95da70617a..09fb0cbf4d 100644
--- a/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
+++ b/protocols/profinet/src/main/resources/protocols/profinet/profinet.mspec
@@ -554,6 +554,7 @@
[padding uint 8 pad '0x00' 'STATIC_CALL("arrayLength", deviceVendorValue) % 2']
]
['DEVICE_PROPERTIES_OPTION','2' PnDcp_Block_DevicePropertiesNameOfStation(uint 16 blockLength)
+ [reserved uint 16 '0x0000' ]
[array byte nameOfStation count 'blockLength-2' ]
[padding uint 8 pad '0x00' 'STATIC_CALL("arrayLength", nameOfStation) % 2']
]