diff --git a/app/app.iml b/app/app.iml index 039cbc1a..852a1345 100644 --- a/app/app.iml +++ b/app/app.iml @@ -65,26 +65,19 @@ - - - - - - - - - + + diff --git a/app/src/main/java/lu/fisch/canze/devices/ELM327.java b/app/src/main/java/lu/fisch/canze/devices/ELM327.java index 06d9d576..077a1d5f 100644 --- a/app/src/main/java/lu/fisch/canze/devices/ELM327.java +++ b/app/src/main/java/lu/fisch/canze/devices/ELM327.java @@ -389,6 +389,10 @@ private String sendAndWaitForAnswer(String command, int waitMillis, boolean unti // send a command and wait for an answer private String sendAndWaitForAnswer(String command, int waitMillis, boolean untilEmpty, int answerLinesCount, boolean addReturn) { + + int maxUntilEmptyCounter = 10; + int maxLengthCounter = 500; // char = nibble, so 2000 bits + if(!BluetoothManager.getInstance().isConnected()) return ""; if(command!=null) { @@ -457,9 +461,14 @@ private String sendAndWaitForAnswer(String command, int waitMillis, boolean unti // do nothing } stop=(BluetoothManager.getInstance().available()==0); + } else { + if (--maxUntilEmptyCounter <= 0) timedOut = true; // well, this is a timed"In", as in, too many lines } } + } else { + if (--maxLengthCounter <= 0) timedOut = true; // well, this is a timed"In", as in, too many lines } + } } else