|
@@ -1,12 +1,14 @@
|
|
|
package de.tudarmstadt.informatik.hostage.protocol;
|
|
|
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.wrapper.Packet;
|
|
|
|
|
|
/**
|
|
|
- * Created by root on 25.05.15.
|
|
|
+ * Created by Shreyas Srinivasa on 25.05.15.
|
|
|
*/
|
|
|
public class MODBUS implements Protocol {
|
|
|
|
|
@@ -23,11 +25,6 @@ public class MODBUS implements Protocol {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public List<Packet> processMessage(Packet requestPacket) {
|
|
|
- List<Packet> responsePackets = new ArrayList<Packet>();
|
|
|
- responsePackets.add(requestPacket);
|
|
|
- return responsePackets;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
@@ -35,10 +32,53 @@ public class MODBUS implements Protocol {
|
|
|
}
|
|
|
|
|
|
public TALK_FIRST whoTalksFirst() {
|
|
|
- return null;
|
|
|
+ return TALK_FIRST.CLIENT;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Request Codes (keeping the most essential ones)
|
|
|
+
|
|
|
+ public static final int READ_COILS = 1;
|
|
|
+ public static final int READ_INPUT_DISCRETES = 2;
|
|
|
+ public static final int READ_INPUT_REGISTERS = 4;
|
|
|
+ public static final int WRITE_COIL = 5;
|
|
|
+ public static final int WRITE_SINGLE_REGISTER = 6;
|
|
|
+ public static final int WRITE_MULTIPLE_COILS = 15;
|
|
|
+ public static final int WRITE_MULTIPLE_REGISTERS = 16;
|
|
|
+ public static final int MODBUS_SERVICE = 17;
|
|
|
+
|
|
|
+
|
|
|
+ //Reply codes
|
|
|
+
|
|
|
+
|
|
|
+ //Device Information
|
|
|
+
|
|
|
+ private String DeviceInfo = getDeviceInfo();
|
|
|
+
|
|
|
+ private String getDeviceInfo() {
|
|
|
+
|
|
|
+ DeviceInfo = "Siemens SIMATIC S7-200";
|
|
|
+ return DeviceInfo;
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Packet> processMessage(Packet requestPacket) {
|
|
|
+ List<Packet> responsePackets = new ArrayList<Packet>();
|
|
|
+ byte[] request = null;
|
|
|
+ if (requestPacket != null) {
|
|
|
+ request = requestPacket.getBytes();
|
|
|
+ for (byte b : request) {
|
|
|
+ System.out.println(b);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return responsePackets;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|