|
@@ -60,7 +60,7 @@ public class MODBUS implements Protocol {
|
|
//public static final int WRITE_MULTIPLE_COILS = 15; Not sure of these commands
|
|
//public static final int WRITE_MULTIPLE_COILS = 15; Not sure of these commands
|
|
//public static final int WRITE_MULTIPLE_REGISTERS = 16; Not sure of these commands
|
|
//public static final int WRITE_MULTIPLE_REGISTERS = 16; Not sure of these commands
|
|
|
|
|
|
- //Packet Constants
|
|
|
|
|
|
+ //Packet Constants, declaring it for now, depends on usage. Static assignment is not a good idea
|
|
|
|
|
|
int FUNCTION_CODE;
|
|
int FUNCTION_CODE;
|
|
int UNIT_NUMBER;
|
|
int UNIT_NUMBER;
|
|
@@ -69,6 +69,9 @@ public class MODBUS implements Protocol {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
public int sid=1; // Denotes the Unit Number or Slave_ID of the device
|
|
public int sid=1; // Denotes the Unit Number or Slave_ID of the device
|
|
|
|
|
|
public static final int COIL_MAX_DATA_ADDRESS = 128; // Max coil data address
|
|
public static final int COIL_MAX_DATA_ADDRESS = 128; // Max coil data address
|
|
@@ -325,7 +328,7 @@ public class MODBUS implements Protocol {
|
|
|
|
|
|
private String getDeviceInfo() {
|
|
private String getDeviceInfo() {
|
|
|
|
|
|
- DeviceInfo = "5369656d656e732053494d415449432053372d323030";
|
|
|
|
|
|
+ DeviceInfo = "5369656d656e732053494d415449432053372d323030"; // Hex value for Simatic S7 200
|
|
return DeviceInfo;
|
|
return DeviceInfo;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -334,7 +337,7 @@ public class MODBUS implements Protocol {
|
|
|
|
|
|
private int readRegister(int registerAddress) {
|
|
private int readRegister(int registerAddress) {
|
|
|
|
|
|
- registerAddress+=30001; //Offset of 30001
|
|
|
|
|
|
+ // registerAddress+=30001; //Offset of 30001 Check the packet in wireshark and decide to put offset
|
|
|
|
|
|
if (register.containsKey(registerAddress)) {
|
|
if (register.containsKey(registerAddress)) {
|
|
int val = (Integer) register.get(registerAddress);
|
|
int val = (Integer) register.get(registerAddress);
|
|
@@ -361,7 +364,7 @@ public class MODBUS implements Protocol {
|
|
|
|
|
|
private int writeSingleRegister(int regAddress, int regData){
|
|
private int writeSingleRegister(int regAddress, int regData){
|
|
|
|
|
|
- regData+=30001;
|
|
|
|
|
|
+ //regData+=30001;
|
|
register.put(regAddress, regData);
|
|
register.put(regAddress, regData);
|
|
int val = (Integer)register.get(regAddress);
|
|
int val = (Integer)register.get(regAddress);
|
|
return val;
|
|
return val;
|