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 2022/03/28 12:30:21 UTC
[plc4x] branch develop updated: feat(modbus): Added some initial tests for Modbus-RTU and Modbus-ASCII
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 48839ac feat(modbus): Added some initial tests for Modbus-RTU and Modbus-ASCII
48839ac is described below
commit 48839acfcf5be2bab2bb47e7661cde7a9e6dad83
Author: cdutz <ch...@c-ware.de>
AuthorDate: Mon Mar 28 14:30:10 2022 +0200
feat(modbus): Added some initial tests for Modbus-RTU and Modbus-ASCII
---
.../knxnetip/readwrite/model/KnxManufacturer.go | 26 +++++--
.../ModbusAsciiParserSerializerTest.java} | 8 +-
.../ModbusRtuParserSerializerTest.java} | 8 +-
.../ModbusTcpDriverIT.java} | 8 +-
.../ModbusTcpParserSerializerTest.java} | 8 +-
.../knxnetip/readwrite/model/KnxManufacturer.cs | 19 +++--
.../modbus/ascii/ParserSerializerTestsuite.xml | 84 +++++++++++++++++++++
.../modbus/rtu/ParserSerializerTestsuite.xml | 84 +++++++++++++++++++++
.../protocols/modbus/{ => tcp}/DriverTestsuite.xml | 0
.../modbus/{ => tcp}/ParserSerializerTestsuite.xml | 0
.../modbus/{ => tcp}/manual-test-capture.pcapng | Bin
11 files changed, 218 insertions(+), 27 deletions(-)
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
index 6e5ebe0..d6cf0dc 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
@@ -621,8 +621,9 @@ const (
KnxManufacturer_M_SHENZHEN_CONGXUN_INTELLIGENT_TECHNOLOGY_CO___LTD KnxManufacturer = 583
KnxManufacturer_M_ANDAS KnxManufacturer = 584
KnxManufacturer_M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD KnxManufacturer = 585
- KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 586
- KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 587
+ KnxManufacturer_M_LARFE KnxManufacturer = 586
+ KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 587
+ KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 588
)
var KnxManufacturerValues []KnxManufacturer
@@ -1216,6 +1217,7 @@ func init() {
KnxManufacturer_M_SHENZHEN_CONGXUN_INTELLIGENT_TECHNOLOGY_CO___LTD,
KnxManufacturer_M_ANDAS,
KnxManufacturer_M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD,
+ KnxManufacturer_M_LARFE,
KnxManufacturer_M_ABB___RESERVED,
KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED,
}
@@ -3389,10 +3391,14 @@ func (e KnxManufacturer) Number() uint16 {
}
case 586:
{ /* '586' */
- return 43954
+ return 644
}
case 587:
{ /* '587' */
+ return 43954
+ }
+ case 588:
+ { /* '588' */
return 43959
}
case 59:
@@ -5759,10 +5765,14 @@ func (e KnxManufacturer) Name() string {
}
case 586:
{ /* '586' */
- return "ABB - reserved"
+ return "Larfe"
}
case 587:
{ /* '587' */
+ return "ABB - reserved"
+ }
+ case 588:
+ { /* '588' */
return "Busch-Jaeger Elektro - reserved"
}
case 59:
@@ -7045,8 +7055,10 @@ func KnxManufacturerByValue(value uint16) KnxManufacturer {
case 585:
return KnxManufacturer_M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD
case 586:
- return KnxManufacturer_M_ABB___RESERVED
+ return KnxManufacturer_M_LARFE
case 587:
+ return KnxManufacturer_M_ABB___RESERVED
+ case 588:
return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED
case 59:
return KnxManufacturer_M_ELECTRAK
@@ -8226,6 +8238,8 @@ func KnxManufacturerByName(value string) KnxManufacturer {
return KnxManufacturer_M_ANDAS
case "M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD":
return KnxManufacturer_M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD
+ case "M_LARFE":
+ return KnxManufacturer_M_LARFE
case "M_ABB___RESERVED":
return KnxManufacturer_M_ABB___RESERVED
case "M_BUSCH_JAEGER_ELEKTRO___RESERVED":
@@ -9447,6 +9461,8 @@ func (e KnxManufacturer) name() string {
return "M_ANDAS"
case KnxManufacturer_M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD:
return "M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD"
+ case KnxManufacturer_M_LARFE:
+ return "M_LARFE"
case KnxManufacturer_M_ABB___RESERVED:
return "M_ABB___RESERVED"
case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED:
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiParserSerializerTest.java
similarity index 78%
copy from plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
copy to plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiParserSerializerTest.java
index d31ffa3..d5af3c6 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiParserSerializerTest.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.modbus;
+package org.apache.plc4x.java.modbus.ascii;
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
-public class ModbusParserSerializerTest extends ParserSerializerTestsuiteRunner {
+public class ModbusAsciiParserSerializerTest extends ParserSerializerTestsuiteRunner {
- public ModbusParserSerializerTest() {
- super("/protocols/modbus/ParserSerializerTestsuite.xml");
+ public ModbusAsciiParserSerializerTest() {
+ super("/protocols/modbus/ascii/ParserSerializerTestsuite.xml");
}
}
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/rtu/ModbusRtuParserSerializerTest.java
similarity index 78%
copy from plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
copy to plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/rtu/ModbusRtuParserSerializerTest.java
index d31ffa3..714f135 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/rtu/ModbusRtuParserSerializerTest.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.modbus;
+package org.apache.plc4x.java.modbus.rtu;
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
-public class ModbusParserSerializerTest extends ParserSerializerTestsuiteRunner {
+public class ModbusRtuParserSerializerTest extends ParserSerializerTestsuiteRunner {
- public ModbusParserSerializerTest() {
- super("/protocols/modbus/ParserSerializerTestsuite.xml");
+ public ModbusRtuParserSerializerTest() {
+ super("/protocols/modbus/rtu/ParserSerializerTestsuite.xml");
}
}
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusDriverIT.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpDriverIT.java
similarity index 81%
rename from plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusDriverIT.java
rename to plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpDriverIT.java
index 9ee2734..7856dc0 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusDriverIT.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpDriverIT.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.modbus;
+package org.apache.plc4x.java.modbus.tcp;
import org.apache.plc4x.test.driver.DriverTestsuiteRunner;
-public class ModbusDriverIT extends DriverTestsuiteRunner {
+public class ModbusTcpDriverIT extends DriverTestsuiteRunner {
- public ModbusDriverIT() {
- super("/protocols/modbus/DriverTestsuite.xml");
+ public ModbusTcpDriverIT() {
+ super("/protocols/modbus/tcp/DriverTestsuite.xml");
}
}
diff --git a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpParserSerializerTest.java
similarity index 78%
rename from plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
rename to plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpParserSerializerTest.java
index d31ffa3..f5d0b62 100644
--- a/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/ModbusParserSerializerTest.java
+++ b/plc4j/drivers/modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpParserSerializerTest.java
@@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.modbus;
+package org.apache.plc4x.java.modbus.tcp;
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
-public class ModbusParserSerializerTest extends ParserSerializerTestsuiteRunner {
+public class ModbusTcpParserSerializerTest extends ParserSerializerTestsuiteRunner {
- public ModbusParserSerializerTest() {
- super("/protocols/modbus/ParserSerializerTestsuite.xml");
+ public ModbusTcpParserSerializerTest() {
+ super("/protocols/modbus/tcp/ParserSerializerTestsuite.xml");
}
}
diff --git a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs
index 706264e..f3b669e 100644
--- a/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs
+++ b/plc4net/drivers/knxnetip/src/drivers/knxnetip/readwrite/model/KnxManufacturer.cs
@@ -610,8 +610,9 @@ namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
M_SHENZHEN_CONGXUN_INTELLIGENT_TECHNOLOGY_CO___LTD = 583,
M_ANDAS = 584,
M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD = 585,
- M_ABB___RESERVED = 586,
- M_BUSCH_JAEGER_ELEKTRO___RESERVED = 587,
+ M_LARFE = 586,
+ M_ABB___RESERVED = 587,
+ M_BUSCH_JAEGER_ELEKTRO___RESERVED = 588,
}
public static class KnxManufacturerInfo
@@ -2244,10 +2245,13 @@ namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
case KnxManufacturer.M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD: { /* '585' */
return 643;
}
- case KnxManufacturer.M_ABB___RESERVED: { /* '586' */
+ case KnxManufacturer.M_LARFE: { /* '586' */
+ return 644;
+ }
+ case KnxManufacturer.M_ABB___RESERVED: { /* '587' */
return 43954;
}
- case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '587' */
+ case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '588' */
return 43959;
}
case KnxManufacturer.M_ELECTRAK: { /* '59' */
@@ -4018,10 +4022,13 @@ namespace org.apache.plc4net.drivers.knxnetip.readwrite.model
case KnxManufacturer.M_HEFEI_CHUANG_YUE_INTELLIGENT_TECHNOLOGY_CO__LTD: { /* '585' */
return "Hefei Chuang Yue Intelligent Technology Co.,LTD";
}
- case KnxManufacturer.M_ABB___RESERVED: { /* '586' */
+ case KnxManufacturer.M_LARFE: { /* '586' */
+ return "Larfe";
+ }
+ case KnxManufacturer.M_ABB___RESERVED: { /* '587' */
return "ABB - reserved";
}
- case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '587' */
+ case KnxManufacturer.M_BUSCH_JAEGER_ELEKTRO___RESERVED: { /* '588' */
return "Busch-Jaeger Elektro - reserved";
}
case KnxManufacturer.M_ELECTRAK: { /* '59' */
diff --git a/protocols/modbus/src/test/resources/protocols/modbus/ascii/ParserSerializerTestsuite.xml b/protocols/modbus/src/test/resources/protocols/modbus/ascii/ParserSerializerTestsuite.xml
new file mode 100644
index 0000000..7e305c2
--- /dev/null
+++ b/protocols/modbus/src/test/resources/protocols/modbus/ascii/ParserSerializerTestsuite.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
+ byteOrder="BIG_ENDIAN">
+
+ <name>Modbus-ASCII</name>
+
+ <protocolName>modbus</protocolName>
+ <outputFlavor>read-write</outputFlavor>
+
+ <testcase>
+ <name>Read Holding Registers Request</name>
+ <raw>01030000000AF2</raw>
+ <root-type>ModbusADU</root-type>
+ <parser-arguments>
+ <driverType>MODBUS_ASCII</driverType>
+ <response>false</response>
+ </parser-arguments>
+ <xml>
+ <ModbusADU>
+ <ModbusAsciiADU>
+ <address dataType="uint" bitLength="8">1</address>
+ <pdu>
+ <ModbusPDU>
+ <errorFlag dataType="bit" bitLength="1">false</errorFlag>
+ <functionFlag dataType="uint" bitLength="7">3</functionFlag>
+ <ModbusPDUReadHoldingRegistersRequest>
+ <startingAddress dataType="uint" bitLength="16">0</startingAddress>
+ <quantity dataType="uint" bitLength="16">10</quantity>
+ </ModbusPDUReadHoldingRegistersRequest>
+ </ModbusPDU>
+ </pdu>
+ <crc dataType="uint" bitLength="8">242</crc>
+ </ModbusAsciiADU>
+ </ModbusADU>
+ </xml>
+ </testcase>
+
+ <testcase>
+ <name>Read Holding Registers Response</name>
+ <raw>0103140000000000000000000000000000000000000000E8</raw>
+ <root-type>ModbusADU</root-type>
+ <parser-arguments>
+ <driverType>MODBUS_ASCII</driverType>
+ <response>true</response>
+ </parser-arguments>
+ <xml>
+ <ModbusADU>
+ <ModbusAsciiADU>
+ <address dataType="uint" bitLength="8">1</address>
+ <pdu>
+ <ModbusPDU>
+ <errorFlag dataType="bit" bitLength="1">false</errorFlag>
+ <functionFlag dataType="uint" bitLength="7">3</functionFlag>
+ <ModbusPDUReadHoldingRegistersResponse>
+ <byteCount dataType="uint" bitLength="8">20</byteCount>
+ <value dataType="byte" bitLength="160">0x0000000000000000000000000000000000000000</value>
+ </ModbusPDUReadHoldingRegistersResponse>
+ </ModbusPDU>
+ </pdu>
+ <crc dataType="uint" bitLength="8">232</crc>
+ </ModbusAsciiADU>
+ </ModbusADU>
+ </xml>
+ </testcase>
+
+</test:testsuite>
diff --git a/protocols/modbus/src/test/resources/protocols/modbus/rtu/ParserSerializerTestsuite.xml b/protocols/modbus/src/test/resources/protocols/modbus/rtu/ParserSerializerTestsuite.xml
new file mode 100644
index 0000000..e4aa7c8
--- /dev/null
+++ b/protocols/modbus/src/test/resources/protocols/modbus/rtu/ParserSerializerTestsuite.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
+ byteOrder="BIG_ENDIAN">
+
+ <name>Modbus-ADU</name>
+
+ <protocolName>modbus</protocolName>
+ <outputFlavor>read-write</outputFlavor>
+
+ <testcase>
+ <name>Read Holding Registers Request</name>
+ <raw>01030000000ac5cd</raw>
+ <root-type>ModbusADU</root-type>
+ <parser-arguments>
+ <driverType>MODBUS_RTU</driverType>
+ <response>false</response>
+ </parser-arguments>
+ <xml>
+ <ModbusADU>
+ <ModbusRtuADU>
+ <address dataType="uint" bitLength="8">1</address>
+ <pdu>
+ <ModbusPDU>
+ <errorFlag dataType="bit" bitLength="1">false</errorFlag>
+ <functionFlag dataType="uint" bitLength="7">3</functionFlag>
+ <ModbusPDUReadHoldingRegistersRequest>
+ <startingAddress dataType="uint" bitLength="16">0</startingAddress>
+ <quantity dataType="uint" bitLength="16">10</quantity>
+ </ModbusPDUReadHoldingRegistersRequest>
+ </ModbusPDU>
+ </pdu>
+ <crc dataType="uint" bitLength="16">50637</crc>
+ </ModbusRtuADU>
+ </ModbusADU>
+ </xml>
+ </testcase>
+
+ <testcase>
+ <name>Read Holding Registers Response</name>
+ <raw>0103140000000000000000000000000000000000000000a367</raw>
+ <root-type>ModbusADU</root-type>
+ <parser-arguments>
+ <driverType>MODBUS_RTU</driverType>
+ <response>true</response>
+ </parser-arguments>
+ <xml>
+ <ModbusADU>
+ <ModbusRtuADU>
+ <address dataType="uint" bitLength="8">1</address>
+ <pdu>
+ <ModbusPDU>
+ <errorFlag dataType="bit" bitLength="1">false</errorFlag>
+ <functionFlag dataType="uint" bitLength="7">3</functionFlag>
+ <ModbusPDUReadHoldingRegistersResponse>
+ <byteCount dataType="uint" bitLength="8">20</byteCount>
+ <value dataType="byte" bitLength="160">0x0000000000000000000000000000000000000000</value>
+ </ModbusPDUReadHoldingRegistersResponse>
+ </ModbusPDU>
+ </pdu>
+ <crc dataType="uint" bitLength="16">41831</crc>
+ </ModbusRtuADU>
+ </ModbusADU>
+ </xml>
+ </testcase>
+
+</test:testsuite>
diff --git a/protocols/modbus/src/test/resources/protocols/modbus/DriverTestsuite.xml b/protocols/modbus/src/test/resources/protocols/modbus/tcp/DriverTestsuite.xml
similarity index 100%
rename from protocols/modbus/src/test/resources/protocols/modbus/DriverTestsuite.xml
rename to protocols/modbus/src/test/resources/protocols/modbus/tcp/DriverTestsuite.xml
diff --git a/protocols/modbus/src/test/resources/protocols/modbus/ParserSerializerTestsuite.xml b/protocols/modbus/src/test/resources/protocols/modbus/tcp/ParserSerializerTestsuite.xml
similarity index 100%
rename from protocols/modbus/src/test/resources/protocols/modbus/ParserSerializerTestsuite.xml
rename to protocols/modbus/src/test/resources/protocols/modbus/tcp/ParserSerializerTestsuite.xml
diff --git a/protocols/modbus/src/test/resources/protocols/modbus/manual-test-capture.pcapng b/protocols/modbus/src/test/resources/protocols/modbus/tcp/manual-test-capture.pcapng
similarity index 100%
rename from protocols/modbus/src/test/resources/protocols/modbus/manual-test-capture.pcapng
rename to protocols/modbus/src/test/resources/protocols/modbus/tcp/manual-test-capture.pcapng