-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modbus): Added some initial tests for Modbus-RTU and Modbus-ASCII
- Loading branch information
Showing
11 changed files
with
268 additions
and
19 deletions.
There are no files selected for viewing
26 changes: 21 additions & 5 deletions
26
plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...bus/src/test/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiParserSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.modbus.ascii; | ||
|
||
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; | ||
|
||
public class ModbusAsciiParserSerializerTest extends ParserSerializerTestsuiteRunner { | ||
|
||
public ModbusAsciiParserSerializerTest() { | ||
super("/protocols/modbus/ascii/ParserSerializerTestsuite.xml"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../modbus/src/test/java/org/apache/plc4x/java/modbus/tcp/ModbusTcpParserSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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.modbus.tcp; | ||
|
||
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; | ||
|
||
public class ModbusTcpParserSerializerTest extends ParserSerializerTestsuiteRunner { | ||
|
||
public ModbusTcpParserSerializerTest() { | ||
super("/protocols/modbus/tcp/ParserSerializerTestsuite.xml"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
protocols/modbus/src/test/resources/protocols/modbus/ascii/ParserSerializerTestsuite.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
84 changes: 84 additions & 0 deletions
84
protocols/modbus/src/test/resources/protocols/modbus/rtu/ParserSerializerTestsuite.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
File renamed without changes.
File renamed without changes.
File renamed without changes.