specific exception
This commit is contained in:
parent
59bf7d65a0
commit
ffe3ff249f
@ -1,5 +1,7 @@
|
||||
package de.hottis.mbusMaster;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@ -26,13 +28,17 @@ public class MbusMaster {
|
||||
mbusgw.start();
|
||||
|
||||
|
||||
mbusgw.sendRequest((byte)0x5b, (byte)80);
|
||||
try {
|
||||
mbusgw.sendRequest((byte)0x5b, (byte)80);
|
||||
|
||||
byte[] frame = mbusgw.collectResponse();
|
||||
for (byte x : frame) {
|
||||
System.out.print(Integer.toHexString(Byte.toUnsignedInt(x)) + " ");
|
||||
byte[] frame = mbusgw.collectResponse();
|
||||
for (byte x : frame) {
|
||||
System.out.print(Integer.toHexString(Byte.toUnsignedInt(x)) + " ");
|
||||
}
|
||||
System.out.println();
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in Meterbus dialog: " + e.toString() + ", " + e.getMessage());
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
System.out.println("Stopping mbusgw process");
|
||||
mbusgw.stop();
|
||||
|
@ -99,6 +99,10 @@ public class MbusgwChild {
|
||||
int responseCode = Byte.toUnsignedInt(header[0]);
|
||||
int responseLen = Byte.toUnsignedInt(header[1]);
|
||||
logger.debug("n: " + n + ", h: " + responseCode + ", l: " + responseLen);
|
||||
if (responseCode != 0) {
|
||||
logger.debug("Received error from child: " + responseCode);
|
||||
throw new MbusgwChildException("Error " + responseCode + " from child");
|
||||
}
|
||||
byte[] frame = new byte[responseLen];
|
||||
n = this.processInput.read(frame, 0, responseLen);
|
||||
logger.debug("frame completely read");
|
||||
|
21
src/main/java/de/hottis/mbusMaster/MbusgwChildException.java
Normal file
21
src/main/java/de/hottis/mbusMaster/MbusgwChildException.java
Normal file
@ -0,0 +1,21 @@
|
||||
package de.hottis.mbusMaster;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MbusgwChildException extends IOException {
|
||||
public MbusgwChildException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MbusgwChildException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public MbusgwChildException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MbusgwChildException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user