Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update j2mod dependency to 3.2.0 #2364

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cnf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.5.1</version>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>com.ghgande</groupId>
<artifactId>j2mod</artifactId>
<version>2.5.5</version>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.github.rzymek</groupId>
Expand Down
6 changes: 3 additions & 3 deletions io.openems.edge.application/EdgeApp.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -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)',\
Expand Down Expand Up @@ -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)'
rrd4j;version='[3.9.0,3.9.1)'
Original file line number Diff line number Diff line change
Expand Up @@ -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(//
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) //
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down