diff --git a/cnf/pom.xml b/cnf/pom.xml
index 8a7aca84198..415c0d42777 100644
--- a/cnf/pom.xml
+++ b/cnf/pom.xml
@@ -17,12 +17,12 @@
com.fazecast
jSerialComm
- 2.5.1
+ 2.9.3
com.ghgande
j2mod
- 2.5.5
+ 3.2.0
com.github.rzymek
diff --git a/io.openems.edge.application/EdgeApp.bndrun b/io.openems.edge.application/EdgeApp.bndrun
index 84c1c2d1221..0398f8d7922 100644
--- a/io.openems.edge.application/EdgeApp.bndrun
+++ b/io.openems.edge.application/EdgeApp.bndrun
@@ -188,8 +188,8 @@
bcpkix;version='[1.70.0,1.70.1)',\
bcprov;version='[1.70.0,1.70.1)',\
bcutil;version='[1.70.0,1.70.1)',\
- com.fazecast.jSerialComm;version='[2.5.1,2.5.2)',\
- com.ghgande.j2mod;version='[2.5.5,2.5.6)',\
+ com.fazecast.jSerialComm;version='[2.9.3,2.9.4)',\
+ com.ghgande.j2mod;version='[3.2.0,3.2.1)',\
com.google.gson;version='[2.10.1,2.10.2)',\
com.google.guava;version='[33.0.0,33.0.1)',\
com.google.guava.failureaccess;version='[1.0.2,1.0.3)',\
@@ -407,4 +407,4 @@
org.osgi.util.promise;version='[1.3.0,1.3.1)',\
org.owasp.encoder;version='[1.2.3,1.2.4)',\
reactive-streams;version='[1.0.4,1.0.5)',\
- rrd4j;version='[3.9.0,3.9.1)'
\ No newline at end of file
+ rrd4j;version='[3.9.0,3.9.1)'
diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/BridgeModbusSerialImpl.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/BridgeModbusSerialImpl.java
index dd13dd2c81f..4488593accc 100644
--- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/BridgeModbusSerialImpl.java
+++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/BridgeModbusSerialImpl.java
@@ -60,6 +60,15 @@ public class BridgeModbusSerialImpl extends AbstractModbusBridge
/** The configured parity. */
private Parity parity;
+
+ /** Enable internal bus termination. */
+ private boolean enableTermination;
+
+ /** The configured delay between activating the transmitter and actually sending data in microseconds. */
+ private int delayBeforeTx;
+
+ /** The configured delay between the end of transmitting data and deactivating transmitter in microseconds. */
+ private int delayAfterTx;
public BridgeModbusSerialImpl() {
super(//
@@ -90,6 +99,9 @@ private void applyConfig(ConfigSerial config) {
this.databits = config.databits();
this.stopbits = config.stopbits();
this.parity = config.parity();
+ this.enableTermination = config.enableTermination();
+ this.delayBeforeTx = config.delayBeforeTx();
+ this.delayAfterTx = config.delayAfterTx();
}
@Override
@@ -129,6 +141,13 @@ private synchronized SerialConnection getModbusConnection() throws OpenemsExcept
params.setParity(this.parity.getValue());
params.setEncoding(Modbus.SERIAL_ENCODING_RTU);
params.setEcho(false);
+ /* RS485 Settings */
+ params.setRs485Mode(true);
+ params.setRs485RxDuringTx(false);
+ params.setRs485TxEnableActiveHigh(true);
+ params.setRs485EnableTermination(this.enableTermination);
+ params.setRs485DelayBeforeTxMicroseconds(this.delayBeforeTx);
+ params.setRs485DelayAfterTxMicroseconds(this.delayAfterTx);
var connection = new SerialConnection(params);
this._connection = connection;
}
diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/ConfigSerial.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/ConfigSerial.java
index 3024294f204..5032b4f574c 100644
--- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/ConfigSerial.java
+++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/ConfigSerial.java
@@ -35,6 +35,15 @@
@AttributeDefinition(name = "Parity", description = "The parity - 'none', 'even', 'odd', 'mark' or 'space'")
Parity parity() default Parity.NONE;
+
+ @AttributeDefinition(name = "Enable termination", description = "Sets whether the interface shall enable internal bus termination")
+ boolean enableTermination() default true;
+
+ @AttributeDefinition(name = "Delay before TX [μs]", description = "Sets the delay between activating the transmitter and actually sending data. There are devices in the field requiring such a delay for start bit detection.", min = "0")
+ int delayBeforeTx() default 1000;
+
+ @AttributeDefinition(name = "Delay after TX [μs]", description = "Sets the delay between the end of transmitting data and deactivating the transmitter.", min = "0")
+ int delayAfterTx() default 0;
@AttributeDefinition(name = "Log-Verbosity", description = "The log verbosity.")
LogVerbosity logVerbosity() default LogVerbosity.NONE;
diff --git a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/BridgeModbusSerialImplTest.java b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/BridgeModbusSerialImplTest.java
index da821996473..3645d2d6fdf 100644
--- a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/BridgeModbusSerialImplTest.java
+++ b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/BridgeModbusSerialImplTest.java
@@ -22,6 +22,9 @@ public void test() throws Exception {
.setParity(Parity.NONE) //
.setStopbits(Stopbit.ONE) //
.setInvalidateElementsAfterReadErrors(1) //
+ .setEnableTermination(true) //
+ .setDelayBeforeTx(1000) //
+ .setDelayAfterTx(0) //
.setLogVerbosity(LogVerbosity.NONE) //
.build()) //
;
diff --git a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/MyConfigSerial.java b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/MyConfigSerial.java
index 621dedce05f..5df6db2a1d2 100644
--- a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/MyConfigSerial.java
+++ b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/MyConfigSerial.java
@@ -15,6 +15,9 @@ protected static class Builder {
private int databits;
private Stopbit stopbits;
private Parity parity;
+ private boolean enableTermination;
+ private int delayBeforeTx;
+ private int delayAfterTx;
private LogVerbosity logVerbosity;
private int invalidateElementsAfterReadErrors;
@@ -50,6 +53,21 @@ public Builder setParity(Parity parity) {
this.parity = parity;
return this;
}
+
+ public Builder setEnableTermination(boolean enableTermination) {
+ this.enableTermination = enableTermination;
+ return this;
+ }
+
+ public Builder setDelayBeforeTx(int delay) {
+ this.delayBeforeTx = delay;
+ return this;
+ }
+
+ public Builder setDelayAfterTx(int delay) {
+ this.delayAfterTx = delay;
+ return this;
+ }
public Builder setLogVerbosity(LogVerbosity logVerbosity) {
this.logVerbosity = logVerbosity;
@@ -106,6 +124,21 @@ public Stopbit stopbits() {
public Parity parity() {
return this.builder.parity;
}
+
+ @Override
+ public boolean enableTermination() {
+ return this.builder.enableTermination;
+ }
+
+ @Override
+ public int delayBeforeTx() {
+ return this.builder.delayBeforeTx;
+ }
+
+ @Override
+ public int delayAfterTx() {
+ return this.builder.delayAfterTx;
+ }
@Override
public LogVerbosity logVerbosity() {