From f9917b786c4a07e2368be01d7b6bf2b20423b559 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sun, 25 Feb 2024 18:02:13 -0500 Subject: [PATCH] #432 wait 20s on computer power on before assuming monitor configuration problem --- coordinator/startup.lua | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/coordinator/startup.lua b/coordinator/startup.lua index 844be1c..268bec3 100644 --- a/coordinator/startup.lua +++ b/coordinator/startup.lua @@ -22,7 +22,9 @@ local sounder = require("coordinator.sounder") local apisessions = require("coordinator.session.apisessions") -local COORDINATOR_VERSION = "v1.2.6" +local COORDINATOR_VERSION = "v1.2.7" + +local CHUNK_LOAD_DELAY_S = 20.0 local println = util.println local println_ts = util.println_ts @@ -41,6 +43,25 @@ local log_crypto = coordinator.log_crypto ppm.mount_all() local loaded, monitors = coordinator.load_config() + +-- if the computer just started, its chunk may have just loaded (...or the user rebooted) +-- if monitor config failed, maybe an adjacent chunk containing all or part of a monitor has not loaded yet, so keep trying +while loaded == 2 and os.clock() < CHUNK_LOAD_DELAY_S do + term.clear() + term.setCursorPos(1, 1) + println("There was a monitor configuration problem at boot.\n") + println("Startup will keep trying every 2s in case of chunk load delays.\n") + println(util.sprintf("The configurator will be started in %ds if all attempts fail.\n", math.max(0, CHUNK_LOAD_DELAY_S - os.clock()))) + println("(exit early with ctrl-t)") + +---@diagnostic disable-next-line: undefined-field + os.sleep(2) + + -- remount and re-attempt + ppm.mount_all() + loaded, monitors = coordinator.load_config() +end + if loaded ~= 0 then -- try to reconfigure (user action) local success, error = configure.configure(loaded, monitors)