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 2020/09/16 11:42:43 UTC
[plc4x] 01/02: - PLC4X-207 - No registered handler found for
message TPKTPacket[], ,
using default decode method - Communication with S7 and Modbus device hangs
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch feature/plc4c
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 8d1afb3ed2418e30e165d1e258f49348ef63d775
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Sep 16 13:42:13 2020 +0200
- PLC4X-207 - No registered handler found for message TPKTPacket[], , using default decode method - Communication with S7 and Modbus device hangs
Duplicated the Modbus fix for overflowing PDUs from the Modbus to the S7 protocol.
---
.../apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
index 0b6e4ec..133cffc 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7ProtocolLogic.java
@@ -206,6 +206,10 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> {
private CompletableFuture<S7Message> readInternal(S7MessageRequest request) {
CompletableFuture<S7Message> future = new CompletableFuture<>();
int tpduId = tpduGenerator.getAndIncrement();
+ // If we've reached the max value for a 16 bit transaction identifier, reset back to 1
+ if(tpduGenerator.get() == 0xFFFF) {
+ tpduGenerator.set(1);
+ }
// Create a new Request with correct tpuId (is not known before)
S7MessageRequest s7MessageRequest = new S7MessageRequest(tpduId, request.getParameter(), request.getPayload());
@@ -243,6 +247,11 @@ public class S7ProtocolLogic extends Plc4xProtocolBase<TPKTPacket> {
payloadItems.add(serializePlcValue(field, plcValue));
}
final int tpduId = tpduGenerator.getAndIncrement();
+ // If we've reached the max value for a 16 bit transaction identifier, reset back to 1
+ if(tpduGenerator.get() == 0xFFFF) {
+ tpduGenerator.set(1);
+ }
+
TPKTPacket tpktPacket = new TPKTPacket(new COTPPacketData(null,
new S7MessageRequest(tpduId,
new S7ParameterWriteVarRequest(parameterItems.toArray(new S7VarRequestParameterItem[0])),