This is an automated email from the ASF dual-hosted git repository. ldywicki pushed a commit to branch features/generated-ads-driver in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 3010fdd15524410dfd55746562ed44bcee0fe80f Author: Ćukasz Dywicki <l...@code-house.org> AuthorDate: Wed May 6 01:05:03 2020 +0200 PLC4X-191 Rearrange fields in ams status type. This change makes parser match received bit order in received byte sequence and not an sequence written using little endian notation. --- .../main/resources/protocols/amsads/amsads.mspec | 6 +- .../java/amsads/StateSerializerParserTest.java | 30 ++++++ .../testsuite/StateParserSerializerTest.xml | 119 +++++++++++++++++++++ 3 files changed, 153 insertions(+), 2 deletions(-) diff --git a/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec b/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec index 0319554..09497fb 100644 --- a/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec +++ b/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec @@ -157,9 +157,9 @@ ['0x0009' ADS_READ_WRITE] ] +// State is composed of two bytes which can be read as uint with little endian coding +// that's why order of fields here reflects endianness [type 'State' - [simple bit 'broadcast' ] - [reserved int 7 '0x0' ] [simple bit 'initCommand' ] [simple bit 'updCommand' ] [simple bit 'timestampAdded' ] @@ -168,6 +168,8 @@ [simple bit 'adsCommand' ] [simple bit 'noReturn' ] [simple bit 'response' ] + [simple bit 'broadcast' ] + [reserved int 7 '0x0' ] ] // It is not only possible to exchange data between TwinCAT modules on one PC, it is even possible to do so by ADS diff --git a/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java b/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java new file mode 100644 index 0000000..648fc7f --- /dev/null +++ b/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java @@ -0,0 +1,30 @@ +/* + 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.amsads; + +import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner; + +public class StateSerializerParserTest extends ParserSerializerTestsuiteRunner { + + public StateSerializerParserTest() { + super("/testsuite/StateParserSerializerTest.xml"); + } + +} diff --git a/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml b/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml new file mode 100644 index 0000000..3f72908 --- /dev/null +++ b/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml @@ -0,0 +1,119 @@ +<?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" bigEndian="true"> + + <name>State</name> + + <testcase> + <name>State ADS_COMMAND</name> + <raw>0400</raw> + <root-type>State</root-type> + <xml> + <State className="org.apache.plc4x.java.amsads.readwrite.State"> + <initCommand>false</initCommand> + <updCommand>false</updCommand> + <timestampAdded>false</timestampAdded> + <highPriorityCommand>false</highPriorityCommand> + <systemCommand>false</systemCommand> + <adsCommand>true</adsCommand> + <noReturn>false</noReturn> + <response>false</response> + <broadcast>false</broadcast> + </State> + </xml> + </testcase> + + <testcase> + <name>State ADS_COMMAND RESPONSE</name> + <raw>0500</raw> + <root-type>State</root-type> + <xml> + <State className="org.apache.plc4x.java.amsads.readwrite.State"> + <initCommand>false</initCommand> + <updCommand>false</updCommand> + <timestampAdded>false</timestampAdded> + <highPriorityCommand>false</highPriorityCommand> + <systemCommand>false</systemCommand> + <adsCommand>true</adsCommand> + <noReturn>false</noReturn> + <response>true</response> + <broadcast>false</broadcast> + </State> + </xml> + </testcase> + + <testcase> + <name>State ADS_COMMAND RESPONSE BROADCAST</name> + <raw>0580</raw> + <root-type>State</root-type> + <xml> + <State className="org.apache.plc4x.java.amsads.readwrite.State"> + <initCommand>false</initCommand> + <updCommand>false</updCommand> + <timestampAdded>false</timestampAdded> + <highPriorityCommand>false</highPriorityCommand> + <systemCommand>false</systemCommand> + <adsCommand>true</adsCommand> + <noReturn>false</noReturn> + <response>true</response> + <broadcast>true</broadcast> + </State> + </xml> + </testcase> + + <testcase> + <name>State ALL FLAGS 1</name> + <raw>FF80</raw> + <root-type>State</root-type> + <xml> + <State className="org.apache.plc4x.java.amsads.readwrite.State"> + <initCommand>true</initCommand> + <updCommand>true</updCommand> + <timestampAdded>true</timestampAdded> + <highPriorityCommand>true</highPriorityCommand> + <systemCommand>true</systemCommand> + <adsCommand>true</adsCommand> + <noReturn>true</noReturn> + <response>true</response> + <broadcast>true</broadcast> + </State> + </xml> + </testcase> + + <testcase> + <name>State ALL BUT UDP 1</name> + <raw>BF80</raw> + <root-type>State</root-type> + <xml> + <State className="org.apache.plc4x.java.amsads.readwrite.State"> + <initCommand>true</initCommand> + <updCommand>false</updCommand> + <timestampAdded>true</timestampAdded> + <highPriorityCommand>true</highPriorityCommand> + <systemCommand>true</systemCommand> + <adsCommand>true</adsCommand> + <noReturn>true</noReturn> + <response>true</response> + <broadcast>true</broadcast> + </State> + </xml> + </testcase> + +</test:testsuite> \ No newline at end of file