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/03/17 16:35:45 UTC
[plc4x] 02/04: - Worked on the firmata tests
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
commit b8387e14d8283251a9d8da68d96af6831982ebf6
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Mar 17 17:34:56 2020 +0100
- Worked on the firmata tests
---
.../java/firmata/readwrite/FirmataDriver.java | 2 +
.../readwrite/protocol/FirmataProtocolLogic.java | 2 +-
...suite.java => FirmataParserSerializerTest.java} | 6 +-
...stsuite.xml => FirmataParserSerializerTest.xml} | 91 ++++++++++++++++------
4 files changed, 75 insertions(+), 26 deletions(-)
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
index 07b8105..54bd704 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
@@ -81,6 +81,8 @@ public class FirmataDriver extends GeneratedDriverBase<FirmataMessage> {
.withDriverContext(FirmataDriverContext.class)
.withPacketSizeEstimator(ByteLengthEstimator.class)
.withCorruptPacketRemover(CorruptPackageCleaner.class)
+ // Every incoming message is to be treated as a response.
+ .withParserArgs(true)
.build();
}
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
index c08b994..645d448 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
@@ -76,7 +76,7 @@ public class FirmataProtocolLogic extends Plc4xProtocolBase<FirmataMessage> impl
.unwrap(FirmataMessageCommand::getCommand)
.only(FirmataCommandSysex.class)
.unwrap(FirmataCommandSysex::getCommand)
- .only(SysexCommandReportFirmware.class)
+ .only(SysexCommandReportFirmwareResponse.class)
.handle(sysexCommandReportFirmware -> {
String name = new String(sysexCommandReportFirmware.getFileName(), StandardCharsets.UTF_8);
LOGGER.info(String.format("Connected to Firmata host running version %s.%s with name %s",
diff --git a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTestsuite.java b/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTest.java
similarity index 81%
rename from plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTestsuite.java
rename to plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTest.java
index 7e0f5dc..4d159fe 100644
--- a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTestsuite.java
+++ b/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataParserSerializerTest.java
@@ -20,10 +20,10 @@ package org.apache.plc4x.java.firmata.readwrite;
import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
-public class FirmataParserSerializerTestsuite extends ParserSerializerTestsuiteRunner {
+public class FirmataParserSerializerTest extends ParserSerializerTestsuiteRunner {
- public FirmataParserSerializerTestsuite() {
- super("/testsuite/FirmataParserSerializerTestsuite.xml");
+ public FirmataParserSerializerTest() {
+ super("/testsuite/FirmataParserSerializerTest.xml");
}
}
diff --git a/plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTestsuite.xml b/plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTest.xml
similarity index 81%
rename from plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTestsuite.xml
rename to plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTest.xml
index 6f392fc..bb15b63 100644
--- a/plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTestsuite.xml
+++ b/plc4j/drivers/firmata/src/test/resources/testsuite/FirmataParserSerializerTest.xml
@@ -25,6 +25,9 @@
<name>Firmata Reset</name>
<raw>FF</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSystemReset"/>
@@ -36,6 +39,9 @@
<name>Firmata Report Version</name>
<raw>F90205</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandProtocolVersion">
@@ -50,10 +56,13 @@
<name>Firmata Report Version And Name</name>
<raw>F07902055300740061006E0064006100720064004600690072006D006100740061002E0069006E006F00F7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
- <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandReportFirmware">
+ <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandReportFirmwareResponse">
<majorVersion>2</majorVersion>
<minorVersion>5</minorVersion>
<fileName>U3RhbmRhcmRGaXJtYXRhLmlubw==</fileName>
@@ -63,25 +72,33 @@
</xml>
</testcase>
- <!-- TODO: Fix this -->
- <!--testcase>
+ <testcase>
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandReportFirmware (Request)</name>
<raw>f079f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
+ <command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
+ <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandReportFirmwareRequest"/>
+ </command>
</FirmataMessageCommand>
</xml>
- </testcase-->
+ </testcase>
<testcase>
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandReportFirmware (Response)</name>
<raw>f07902055300740061006e0064006100720064004600690072006d006100740061002e0069006e006f00f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
- <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandReportFirmware">
+ <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandReportFirmwareResponse">
<majorVersion>2</majorVersion>
<minorVersion>5</minorVersion>
<fileName>U3RhbmRhcmRGaXJtYXRhLmlubw==</fileName>
@@ -95,10 +112,13 @@
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandAnalogMappingQuery (Request)</name>
<raw>f069f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
- <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandAnalogMappingQuery"/>
+ <command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandAnalogMappingQueryRequest"/>
</command>
</FirmataMessageCommand>
</xml>
@@ -108,6 +128,9 @@
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandCapabilityQuery (Request)</name>
<raw>f06bf7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
@@ -121,6 +144,9 @@
<name>FirmataMessageSubscribeAnalogPinValue (Pin 0)</name>
<raw>c001</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageSubscribeAnalogPinValue className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageSubscribeAnalogPinValue">
<pin>0</pin>
@@ -133,6 +159,9 @@
<name>FirmataMessageSubscribeDigitalPinValue (Pin 0)</name>
<raw>d001</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageSubscribeDigitalPinValue className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageSubscribeDigitalPinValue">
<pin>0</pin>
@@ -142,38 +171,44 @@
</testcase>
<!-- TODO: Fix this -->
- <testcase>
+ <!--testcase>
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandAnalogMappingResponse</name>
- <raw></raw>
+ <raw>F069</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
</FirmataMessageCommand>
</xml>
- </testcase>
+ </testcase-->
<!-- TODO: Fix this -->
- <testcase>
+ <!--testcase>
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandCapabilityResponse</name>
<raw></raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
</FirmataMessageCommand>
</xml>
- </testcase>
+ </testcase-->
<testcase>
<name>FirmataMessageAnalogIO (Pin 0)</name>
<raw>e05403</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageAnalogIO className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageAnalogIO">
<pin>0</pin>
- <data>
- <data>84</data>
- <data>3</data>
- </data>
+ <data>VAM=</data>
</FirmataMessageAnalogIO>
</xml>
</testcase>
@@ -182,10 +217,13 @@
<name>FirmataMessageDigitalIO (Pin 0)</name>
<raw>900000</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageDigitalIO className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageDigitalIO">
- <pin>0</pin>
- <data>0</data>
+ <pinBlock>0</pinBlock>
+ <data>AAA=</data>
</FirmataMessageDigitalIO>
</xml>
</testcase>
@@ -194,6 +232,9 @@
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandPinStateQuery (Pin 2)</name>
<raw>f06d02f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>false</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
@@ -209,22 +250,28 @@
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandPinStateResponse</name>
<raw>f06e020100f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
<command className="org.apache.plc4x.java.firmata.readwrite.SysexCommandPinStateResponse">
<pin>2</pin>
- <state>256</state>
+ <pinMode>1</pinMode>
+ <pinState>0</pinState>
</command>
</command>
- </FirmataMessageCommand>
- </xml>
+ </FirmataMessageCommand> </xml>
</testcase>
- <testcase>
+ <!--testcase>
<name>FirmataMessageCommand->FirmataCommandSysex->SysexCommandPinStateResponse (short)</name>
<raw>f06e14f7</raw>
<root-type>FirmataMessage</root-type>
+ <parser-arguments>
+ <response>true</response>
+ </parser-arguments>
<xml>
<FirmataMessageCommand className="org.apache.plc4x.java.firmata.readwrite.FirmataMessageCommand">
<command className="org.apache.plc4x.java.firmata.readwrite.FirmataCommandSysex">
@@ -234,6 +281,6 @@
</command>
</FirmataMessageCommand>
</xml>
- </testcase>
+ </testcase-->
</test:testsuite>
\ No newline at end of file