From e0df1a8313daf7947795ce3a15c835ed61377ab2 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Thu, 5 Dec 2024 12:57:48 +0100 Subject: [PATCH 1/2] Expanded line numbers column to support 4 digits. Signed-off-by: ubi de feo --- ui/arduino/main.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/arduino/main.css b/ui/arduino/main.css index 2c94b7d..cc0e95c 100644 --- a/ui/arduino/main.css +++ b/ui/arduino/main.css @@ -131,7 +131,7 @@ button.small .icon { #tabs { display: flex; - padding: 10px 10px 0px 40px; + padding: 10px 10px 0px 60px; align-items: center; gap: 10px; align-self: stretch; @@ -231,7 +231,7 @@ button.small .icon { #code-editor .cm-gutters { background-color: #ECF1F1; border-right: none; - width: 40px; + width: 60px; font-size: 14px; } From fa37c89eac548a1b1c2e64d6d5b26ba50dff3c01 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Thu, 5 Dec 2024 15:40:56 +0100 Subject: [PATCH 2/2] Implemented timeout on connect/getPrompt to handle board in strange state (crash). Signed-off-by: ubi de feo --- ui/arduino/store.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 2c93a7e..c748905 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -122,14 +122,28 @@ async function store(state, emitter) { state.isConnecting = true emitter.emit('render') - let timeout_id = setTimeout(() => emitter.emit('connection-timeout'), 5000) - await serial.connect(path) - clearTimeout(timeout_id) - + // The following Timeout operation will be cleared after a succesful getPrompt() + // If a board has crashed and/or cannot return a REPL prompt, the connection will fail + // and the user will be prompted to reset the device and try again. + let timeout_id = setTimeout(() => { + let response = win.openDialog({ + type: 'question', + buttons: ['OK'], + cancelId: 0, + message: "Could not connect to the board. Reset it and try again." + }) + console.log('Reset request acknowledged', response) + emitter.emit('connection-timeout') + }, 3500) + try { + await serial.connect(path) + } catch(e) { + console.error(e) + } // Stop whatever is going on // Recover from getting stuck in raw repl await serial.getPrompt() - + clearTimeout(timeout_id) // Connected and ready state.isConnecting = false state.isConnected = true