You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2021/04/02 17:40:32 UTC
[plc4x] branch feature/profinet2 updated (852d0b2 -> ddabbec)
This is an automated email from the ASF dual-hosted git repository.
ldywicki pushed a change to branch feature/profinet2
in repository https://gitbox.apache.org/repos/asf/plc4x.git.
from 852d0b2 Update frame length calculation logic.
add 1f7191b Add array of DeviceOptionsEntry for Device/Device Options case
add 03b52ca Add test for array setup of Device/Device Options
add 0a304a7 Fix array of DeviceOptionsEntry for Device/Device Options case
add a36efd3 Use minimum frame size 60 for ProfinetPacketEstimator
new ddabbec Fix raw socket transport ethernet frame size issues.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../utils/rawsockets/netty/RawSocketChannel.java | 6 +-
.../protocols/profinet/profinet.dcp.mspec | 90 +++++++++++++---------
.../java/profinet/dcp/ProfinetDCPPlcDriver.java | 26 +++++--
.../dcp/protocol/ProfinetDCPProtocolLogic.java | 3 +-
.../test/resources/testsuite/ProfinetDCPBlock.xml | 36 ++++++---
5 files changed, 104 insertions(+), 57 deletions(-)
[plc4x] 01/01: Fix raw socket transport ethernet frame size issues.
Posted by ld...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ldywicki pushed a commit to branch feature/profinet2
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit ddabbeca681310ffeeef47d34acf4176a39827e6
Author: Ćukasz Dywicki <lu...@code-house.org>
AuthorDate: Fri Apr 2 19:40:15 2021 +0200
Fix raw socket transport ethernet frame size issues.
Additionally small adjustments for Profinet DCP mspec to avoid extra variables.
This includes implicit sizes for arrays calculated from actual payload size.
Adjustment of padding bytes. Minimum size of PN DCP frame is 44 bytes.
---
.../utils/rawsockets/netty/RawSocketChannel.java | 6 ++--
.../protocols/profinet/profinet.dcp.mspec | 38 +++++++++++-----------
.../dcp/protocol/ProfinetDCPProtocolLogic.java | 3 +-
3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/RawSocketChannel.java b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/RawSocketChannel.java
index 098c21a..1d12958 100644
--- a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/RawSocketChannel.java
+++ b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/netty/RawSocketChannel.java
@@ -30,6 +30,8 @@ import org.apache.plc4x.java.utils.pcap.netty.exception.PcapException;
import org.apache.plc4x.java.utils.rawsockets.netty.address.RawSocketAddress;
import org.apache.plc4x.java.utils.rawsockets.netty.config.RawSocketChannelConfig;
import org.pcap4j.core.*;
+import org.pcap4j.packet.EthernetPacket;
+import org.pcap4j.packet.IllegalRawDataException;
import org.pcap4j.packet.Packet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -217,8 +219,8 @@ public class RawSocketChannel extends OioByteStreamChannel {
@Override
public void write(byte[] b, int off, int len) throws IOException {
try {
- handle.sendPacket(b);
- } catch (NotOpenException | PcapNativeException e) {
+ handle.sendPacket(EthernetPacket.newPacket(b, off, len));
+ } catch (IllegalRawDataException | NotOpenException | PcapNativeException e) {
throw new IOException(e);
}
}
diff --git a/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec b/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
index 9a52c9a..3870c73 100644
--- a/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
+++ b/protocols/profinet/src/main/resources/protocols/profinet/profinet.dcp.mspec
@@ -39,34 +39,34 @@
[type 'ProfinetFrame'
[enum FrameType 'frameType' ]
[simple ProfinetData 'frame' ['frameType']]
- [padding uint 8 'alignment' '0x00' '40 - frame.lengthInBytes']
+ [padding uint 8 'alignment' '0x00' '44 - frame.lengthInBytes']
]
[discriminatedType 'ProfinetData' [FrameType 'frameType']
[typeSwitch 'frameType'
['FrameType.IDENTIFY_MULTICAST_REQUEST' DcpIdentRequestPDU
- [enum DCPServiceID 'serviceId' ]
- [enum DCPServiceType 'serviceType' ]
- [simple uint 32 'xid' ]
- [simple uint 16 'responseDelay' ]
- [simple uint 16 'dcpDataLength' ]
- [array DCPBlock 'blocks' length 'dcpDataLength']
+ [enum DCPServiceID 'serviceId' ]
+ [enum DCPServiceType 'serviceType' ]
+ [simple uint 32 'xid' ]
+ [simple uint 16 'responseDelay' ]
+ [implicit uint 16 'dcpDataLength' 'ARRAY_SIZE_IN_BYTES(blocks)']
+ [array DCPBlock 'blocks' length 'dcpDataLength' ]
]
['FrameType.GET_SET' DcpGetSetPDU
- [enum DCPServiceID 'serviceId' ]
- [enum DCPServiceType 'serviceType' ]
- [simple uint 32 'xid' ]
- [reserved uint 16 '0x00' ]
- [simple uint 16 'dcpDataLength' ]
- [array DCPBlock 'blocks' length 'dcpDataLength']
+ [enum DCPServiceID 'serviceId' ]
+ [enum DCPServiceType 'serviceType' ]
+ [simple uint 32 'xid' ]
+ [reserved uint 16 '0x00' ]
+ [implicit uint 16 'dcpDataLength' 'ARRAY_SIZE_IN_BYTES(blocks)']
+ [array DCPBlock 'blocks' length 'dcpDataLength' ]
]
['FrameType.IDENTIFY_RESPONSE' DcpIdentResponsePDU
- [enum DCPServiceID 'serviceId' ]
- [enum DCPServiceType 'serviceType' ]
- [simple uint 32 'xid' ]
- [reserved uint 16 '0x00' ]
- [simple uint 16 'dcpDataLength' ]
- [array DCPBlock 'blocks' length 'dcpDataLength']
+ [enum DCPServiceID 'serviceId' ]
+ [enum DCPServiceType 'serviceType' ]
+ [simple uint 32 'xid' ]
+ [reserved uint 16 '0x00' ]
+ [implicit uint 16 'dcpDataLength' 'ARRAY_SIZE_IN_BYTES(blocks)']
+ [array DCPBlock 'blocks' length 'dcpDataLength' ]
]
]
]
diff --git a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
index 08930d3..e383d1c 100644
--- a/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
+++ b/sandbox/test-java-profinet-driver/src/main/java/org/apache/plc4x/java/profinet/dcp/protocol/ProfinetDCPProtocolLogic.java
@@ -89,9 +89,8 @@ public class ProfinetDCPProtocolLogic extends Plc4xProtocolBase<BaseEthernetFram
long xid = invokeId.incrementAndGet();
int responseDelay = 1000;
DCPBlock[] blocks = new DCPBlock[] { new AllSelector(DCPBlockOption.ALL_SELECTOR)};
- int dcpDataLength = blocks[0].getLengthInBytes();
- DcpIdentRequestPDU requestPDU = new DcpIdentRequestPDU(serviceId, serviceType, xid, responseDelay, dcpDataLength, blocks);
+ DcpIdentRequestPDU requestPDU = new DcpIdentRequestPDU(serviceId, serviceType, xid, responseDelay, blocks);
ProfinetFrame profiFrame = new ProfinetFrame(FrameType.IDENTIFY_MULTICAST_REQUEST, requestPDU);
EthernetFrame ethernetFrame = new EthernetFrame(PROFINET_BROADCAST, configuration.getSender(), PN_DCP,
profiFrame);