fixed a tcp connection problem
This commit is contained in:
parent
852cddc2cb
commit
3a599f3bdb
@ -22,9 +22,9 @@ public class GlobalState extends Application {
|
||||
INPUT_REGISTER (1, 1),
|
||||
DISCRETE_INPUT(1, 12);
|
||||
*/
|
||||
COIL (1, 8),
|
||||
INPUT_REGISTER (1, 8),
|
||||
DISCRETE_INPUT(1, 12);
|
||||
COIL (8192, 8),
|
||||
INPUT_REGISTER (0, 2),
|
||||
DISCRETE_INPUT(0, 12);
|
||||
|
||||
private int startReference;
|
||||
private int count;
|
||||
|
@ -19,8 +19,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void sendMessage(View view) {
|
||||
EditText editText1 = (EditText) findViewById(R.id.ipAddress);
|
||||
// String ipAddress = editText1.getText().toString();
|
||||
String ipAddress = "192.168.157.16";
|
||||
int port = 503;
|
||||
String ipAddress = "10.0.0.60";
|
||||
int port = 502;
|
||||
|
||||
EditText editText2 = (EditText) findViewById(R.id.port);
|
||||
// int port = Integer.parseInt(editText2.getText().toString());
|
||||
|
@ -33,6 +33,9 @@ public class MyIntentService extends IntentService {
|
||||
private static final String EXTRA_REF = "extra.ref";
|
||||
private static final String EXTRA_COUNT = "extra.count";
|
||||
private static final String EXTRA_INTENT_NAME = "extra.intent.name";
|
||||
//turns out modbus on siemens logo is crap and isnt responding for at least 50ms
|
||||
private static final Integer CAPWAITTIME = 100;
|
||||
//this is not a type, idiot.
|
||||
|
||||
public MyIntentService() {
|
||||
super("MyIntentService");
|
||||
@ -71,6 +74,7 @@ public class MyIntentService extends IntentService {
|
||||
listBooleanBit.add(bv.getBit(i));
|
||||
}
|
||||
sendBooleanListToActivity(listBooleanBit, intentReceiveName, "discreteInputValues");
|
||||
Thread.sleep(CAPWAITTIME);
|
||||
master.disconnect();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception in reading discrete input " + e);
|
||||
@ -89,6 +93,7 @@ public class MyIntentService extends IntentService {
|
||||
listBooleanBit.add(bv.getBit(i));
|
||||
}
|
||||
sendBooleanListToActivity(listBooleanBit, intentReceiveName, "coilValues");
|
||||
Thread.sleep(CAPWAITTIME);
|
||||
master.disconnect();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception in reading coil " + e);
|
||||
@ -107,6 +112,7 @@ public class MyIntentService extends IntentService {
|
||||
System.out.println(ir.getValue()+" input register "+Math.random());
|
||||
}
|
||||
sendIntegerListToActivity (listIntegerInputRegister, intentReceiveName);
|
||||
Thread.sleep(CAPWAITTIME);
|
||||
master.disconnect();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception in reading input register " + e);
|
||||
|
Loading…
Reference in New Issue
Block a user