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 53d0aef feat(protocol/c-bus): Initial commit.
53d0aef is described below
commit 53d0aef9aa9a8b8de823b2ef2c9c817ac81f2291
Author: cdutz <[email protected]>
AuthorDate: Mon Feb 28 11:25:48 2022 +0100
feat(protocol/c-bus): Initial commit.
---
protocols/c-bus/pom.xml | 43 ++++++++++++
.../apache/plc4x/protocol/cbus/CBusProtocol.java | 44 ++++++++++++
...e.plc4x.plugins.codegenerator.protocol.Protocol | 19 +++++
.../src/main/resources/protocols/cbus/c-bus.mspec | 80 ++++++++++++++++++++++
protocols/pom.xml | 1 +
5 files changed, 187 insertions(+)
diff --git a/protocols/c-bus/pom.xml b/protocols/c-bus/pom.xml
new file mode 100644
index 0000000..36804e4
--- /dev/null
+++ b/protocols/c-bus/pom.xml
@@ -0,0 +1,43 @@
+<?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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-protocols</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-protocols-c-bus</artifactId>
+
+ <name>Protocols: C-Bus</name>
+ <description>Base protocol specifications for the C-Bus
protocol</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
+ <version>0.10.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/protocols/c-bus/src/main/java/org/apache/plc4x/protocol/cbus/CBusProtocol.java
b/protocols/c-bus/src/main/java/org/apache/plc4x/protocol/cbus/CBusProtocol.java
new file mode 100644
index 0000000..f616a12
--- /dev/null
+++
b/protocols/c-bus/src/main/java/org/apache/plc4x/protocol/cbus/CBusProtocol.java
@@ -0,0 +1,44 @@
+/*
+ * 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.protocol.cbus;
+
+import
org.apache.plc4x.plugins.codegenerator.language.mspec.parser.MessageFormatParser;
+import org.apache.plc4x.plugins.codegenerator.protocol.Protocol;
+import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext;
+import
org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException;
+
+import java.io.InputStream;
+
+public class CBusProtocol implements Protocol {
+
+ @Override
+ public String getName() {
+ return "c-bus";
+ }
+
+ @Override
+ public TypeContext getTypeContext() throws GenerationException {
+ InputStream schemaInputStream =
CBusProtocol.class.getResourceAsStream("/protocols/cbus/c-bus.mspec");
+ if(schemaInputStream == null) {
+ throw new GenerationException("Error loading message-format schema
for protocol '" + getName() + "'");
+ }
+ return new MessageFormatParser().parse(schemaInputStream);
+ }
+
+}
diff --git
a/protocols/c-bus/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
b/protocols/c-bus/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
new file mode 100644
index 0000000..9e8c5cf
--- /dev/null
+++
b/protocols/c-bus/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+org.apache.plc4x.protocol.cbus.CBusProtocol
diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
new file mode 100644
index 0000000..2170288
--- /dev/null
+++ b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+[discriminatedType CBusCommand
+ [const uint 8 initiator '0x5C'] // 0x5C = "/"
+ [simple CBusHeader header ]
+ [typeSwitch 'header.destinationAddressType'
+ ['PointToPointToMultiPoint' CBusCommandPointToPointToMultiPoint
+ [simple CBusPointToPointToMultipointCommand command]
+ ]
+ ['PointToMultiPoint' CBusCommandPointToMultiPoint
+ [simple CBusPointToMultiPointCommand command]
+ ]
+ ['PointToPoint' CBusCommandPointToPoint
+ [simple CBusPointToPointCommand command]
+ ]
+ ]
+]
+
+[type CBusHeader
+ [simple PriorityClass priorityClass ]
+ [reserved bit 'false' ] // Reserved for
internal C-Bus management purposes
+ [reserved uint 2 '0' ] // Reserved for
internal C-Bus management purposes
+ [simple DestinationAddressType destinationAddressType]
+]
+
+[discriminatedType CBusPointToPointCommand
+ [peek uint 16 bridgeAddressCountPeek]
+ [virtual UnitAddress unitAddress ]
+ [typeSwitch 'bridgeAddressCountPeek && 0x00FF'
+ ['0x0000' CBusPointToPointCommandDirect
+ [simple UnitAddress unitAddress
]
+ ]
+ [ CBusPointToPointCommandIndirect
+ [simple BridgeAddress firstBridgeAddress
]
+ [simple RouteType routeType
]
+ [array BridgeAddress additionalBridgeAddresses count
'routeType.additionalBridges']
+ [simple UnitAddress unitAddress
]
+ ]
+ ]
+
+]
+
+[enum uint 2 PriorityClass
+ ['0x00' Class4] // lowest
+ ['0x01' Class3] // medium low
+ ['0x02' Class2] // medium high
+ ['0x03' Class1] // highest
+]
+
+[enum uint 3 DestinationAddressType
+ ['0x03' PointToPointToMultiPoint] // P-P-M
+ ['0x05' PointToMultiPoint ] // P-M
+ ['0x06' PointToPoint ] // P-P
+]
+
+[enum uint 8 RouteType(uint 3 additionalBridges)
+ ['0x00' NoBridgeAtAll ['0']]
+ ['0x09' NoAdditionalBridge ['1']]
+ ['0x12' OneAdditionalBridge ['2']]
+ ['0x1B' TwoAdditionalBridge ['3']]
+ ['0x24' ThreeAdditionalBridge ['4']]
+ ['0x2D' FourAdditionalBridge ['4']]
+ ['0x36' FiveAdditionalBridge ['4']]
diff --git a/protocols/pom.xml b/protocols/pom.xml
index f2d94f6..f785374 100644
--- a/protocols/pom.xml
+++ b/protocols/pom.xml
@@ -36,6 +36,7 @@
<modules>
<module>ab-eth</module>
<module>ads</module>
+ <module>c-bus</module>
<module>bacnetip</module>
<module>canopen</module>
<module>df1</module>