me.martiii.modbustcpjava.protocol.ModbusResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of modbus-tcp-java Show documentation
Show all versions of modbus-tcp-java Show documentation
Modbus-TCP protocol for java.
The newest version!
package me.martiii.modbustcpjava.protocol;
import java.util.Arrays;
public class ModbusResponse {
private byte functionCode;
protected byte[] data;
private boolean error;
public ModbusResponse(byte functionCode, byte[] data, boolean error) {
this.functionCode = functionCode;
this.data = data;
this.error = error;
//TODO: Add write response helper class (like ReadResponse)
}
public byte getFunctionCode() {
return functionCode;
}
public byte[] getData() {
return data;
}
public boolean isError() {
return error;
}
public int getErrorCode() {
if (isError()) {
return data[0];
}
return -1;
}
@Override
public String toString() {
return "ModbusResponse{" +
"functionCode=" + functionCode +
", data=" + Arrays.toString(data) +
", error=" + error +
'}';
}
}