-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
S-Bus transport protocol. Derived from Modbus protocol
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
- Loading branch information
Ciprian Pascu
committed
Jan 7, 2024
1 parent
7d1dcd7
commit bda0984
Showing
80 changed files
with
10,411 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
<attribute name="optional" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openhab.core.io.transport.sbus</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,20 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab-core | ||
|
||
== Third-party Content | ||
|
||
jsoup | ||
* License: MIT License | ||
* Project: https://jsoup.org/ | ||
* Source: https://github.com/jhy/jsoup |
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,10 @@ | ||
Bundle-SymbolicName: ${project.artifactId} | ||
Automatic-Module-Name: ${def;bsn} | ||
Import-Package: \ | ||
org.eclipse.jdt.annotation.*;resolution:=optional,\ | ||
org.openhab.*;version=!,\ | ||
!net.sf.cglib.proxy,\ | ||
gnu.io;version="[3.12,6)",\ | ||
* | ||
-sources: false | ||
-contract: * |
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,71 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.core.bundles</groupId> | ||
<artifactId>org.openhab.core.reactor.bundles</artifactId> | ||
<version>4.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.core.io.transport.sbus</artifactId> | ||
|
||
<name>openHAB Core :: Bundles :: S-Bus Transport</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.openhab.core.bundles</groupId> | ||
<artifactId>org.openhab.core.config.core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openhab.core.bundles</groupId> | ||
<artifactId>org.openhab.core.test</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-pool2</artifactId> | ||
<version>2.8.1</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ro.ciprianpascu</groupId> | ||
<artifactId>j2sbus</artifactId> | ||
<version>1.3.5.OH</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.1.1</version> | ||
<executions> | ||
<execution> | ||
<id>embed-dependencies</id> | ||
<goals> | ||
<goal>unpack-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<includeScope>runtime</includeScope> | ||
<includeTypes>jar</includeTypes> | ||
<excludeGroupIds>commons-pool2,org.openhab.core.bundles</excludeGroupIds> | ||
<outputDirectory>${project.build.directory}/classes</outputDirectory> | ||
<overWriteReleases>true</overWriteReleases> | ||
<overWriteSnapshots>true</overWriteSnapshots> | ||
<excludeTransitive>true</excludeTransitive> | ||
<type>jar</type> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
65 changes: 65 additions & 0 deletions
65
...o.transport.sbus/src/main/java/org/openhab/core/io/transport/sbus/AsyncModbusFailure.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,65 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.io.transport.sbus; | ||
|
||
import java.util.Objects; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* Encapsulates result of modbus read operations | ||
* | ||
* @author Nagy Attila Gabor - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class AsyncModbusFailure<R> { | ||
private final R request; | ||
|
||
private final Exception cause; | ||
|
||
public AsyncModbusFailure(R request, Exception cause) { | ||
Objects.requireNonNull(request, "Request must not be null!"); | ||
Objects.requireNonNull(cause, "Cause must not be null!"); | ||
this.request = request; | ||
this.cause = cause; | ||
} | ||
|
||
/** | ||
* Get request matching this response | ||
* | ||
* @return request object | ||
*/ | ||
public R getRequest() { | ||
return request; | ||
} | ||
|
||
/** | ||
* Get cause of error | ||
* | ||
* @return exception representing error | ||
*/ | ||
public Exception getCause() { | ||
return cause; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder("AsyncModbusReadResult("); | ||
builder.append("request = "); | ||
builder.append(request); | ||
builder.append(", error = "); | ||
builder.append(cause); | ||
builder.append(")"); | ||
return builder.toString(); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...ransport.sbus/src/main/java/org/openhab/core/io/transport/sbus/AsyncModbusReadResult.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,93 @@ | ||
/** | ||
* Copyright (c) 2010-2023 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.io.transport.sbus; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
|
||
/** | ||
* Encapsulates result of modbus read operations | ||
* | ||
* @author Sami Salonen - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class AsyncModbusReadResult { | ||
|
||
private final ModbusReadRequestBlueprint request; | ||
|
||
private final Optional<BitArray> bits; | ||
|
||
private final Optional<ModbusRegisterArray> registers; | ||
|
||
public AsyncModbusReadResult(ModbusReadRequestBlueprint request, ModbusRegisterArray registers) { | ||
Objects.requireNonNull(request, "Request must not be null!"); | ||
Objects.requireNonNull(registers, "Registers must not be null!"); | ||
this.request = request; | ||
this.registers = Optional.of(registers); | ||
this.bits = Optional.empty(); | ||
} | ||
|
||
public AsyncModbusReadResult(ModbusReadRequestBlueprint request, BitArray bits) { | ||
Objects.requireNonNull(request, "Request must not be null!"); | ||
Objects.requireNonNull(bits, "Bits must not be null!"); | ||
this.request = request; | ||
this.registers = Optional.empty(); | ||
this.bits = Optional.of(bits); | ||
} | ||
|
||
/** | ||
* Get request matching this response | ||
* | ||
* @return request object | ||
*/ | ||
public ModbusReadRequestBlueprint getRequest() { | ||
return request; | ||
} | ||
|
||
/** | ||
* Get "coil" or "discrete input" bit data in the case of no errors | ||
* | ||
* @return bit data | ||
*/ | ||
public Optional<BitArray> getBits() { | ||
return bits; | ||
} | ||
|
||
/** | ||
* Get "input register" or "holding register" data in the case of no errors | ||
* | ||
* @return register data | ||
*/ | ||
public Optional<ModbusRegisterArray> getRegisters() { | ||
return registers; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder("AsyncModbusReadResult("); | ||
builder.append("request = "); | ||
builder.append(request); | ||
bits.ifPresent(bits -> { | ||
builder.append(", bits = "); | ||
builder.append(bits); | ||
}); | ||
registers.ifPresent(registers -> { | ||
builder.append(", registers = "); | ||
builder.append(registers); | ||
}); | ||
builder.append(")"); | ||
return builder.toString(); | ||
} | ||
} |
Oops, something went wrong.