From 15bac4d386dac73d2b58b24f873ccf809ef26446 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 6 Sep 2017 11:02:35 +0200 Subject: [PATCH] Wait for currentMenu to be != null (cherry picked from commit 13b96ec) --- .../plugins/PumpCombo/scripter/RuffyScripter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/scripter/RuffyScripter.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/scripter/RuffyScripter.java index d0d126235e..c13242b5c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/scripter/RuffyScripter.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/scripter/RuffyScripter.java @@ -474,10 +474,12 @@ public class RuffyScripter { // === pump ops === public Menu getCurrentMenu() { - // TODO workaround, supposedly fixed in latest ruffy? + long timeout = System.currentTimeMillis() + 5 * 1000; while (currentMenu == null) { + if (System.currentTimeMillis() > timeout) { + throw new CommandException().message("Unable to read current menu"); + } log.error("currentMenu == null, waiting"); - SystemClock.sleep(500); waitForMenuUpdate(); } return currentMenu;