From c039ea59c2fe8d8922f6e50bd1e29e3c019cf6d4 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Sat, 12 Apr 2025 22:44:06 +0200 Subject: [PATCH 1/6] Implemented board root detection (/ or /flash). Signed-off-by: ubi de feo --- ui/arduino/helpers.py | 8 ++++++++ ui/arduino/store.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ui/arduino/helpers.py b/ui/arduino/helpers.py index cb7b757..2731091 100644 --- a/ui/arduino/helpers.py +++ b/ui/arduino/helpers.py @@ -1,6 +1,14 @@ import os import json +import sys os.chdir('/') + +def get_root(has_flash_mount = True): + if '/flash' in sys.path: + print('/flash', end = '') + else: + print('/', end = '') + def is_directory(path): return True if os.stat(path)[0] == 0x4000 else False diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 04889b4..c69e5e7 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -175,6 +175,7 @@ async function store(state, emitter) { // Connected and ready state.isConnecting = false state.isConnected = true + state.boardNavigationRoot = await getBoardRoot() updateMenu() if (state.view === 'editor' && state.panelHeight <= PANEL_CLOSED) { state.panelHeight = state.savedPanelHeight @@ -1691,6 +1692,23 @@ async function getAvailablePorts() { return await serialBridge.loadPorts() } +async function getBoardRoot() { + let output = await serialBridge.execFile(await getHelperFullPath()) + output = await serialBridge.run(`get_root()`) + let boardRoot = '' + try { + // Extracting the json output from serial response + output = output.substring( + output.indexOf('OK')+2, + output.indexOf('\x04') + ) + boardRoot = output + } catch (e) { + log('error', output) + } + return boardRoot +} + async function getBoardFiles(path) { await serialBridge.getPrompt() let files = await serialBridge.ilistFiles(path) From 80e37a3692234314f3ee400141e0961549f9eec6 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Sun, 13 Apr 2025 00:04:12 +0200 Subject: [PATCH 2/6] Refactored getRoot with interface for consumer. Signed-off-by: ubi de feo --- ui/arduino/helpers.py | 10 +++++++--- ui/arduino/store.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/arduino/helpers.py b/ui/arduino/helpers.py index 2731091..ac4ec34 100644 --- a/ui/arduino/helpers.py +++ b/ui/arduino/helpers.py @@ -1,13 +1,12 @@ import os import json import sys -os.chdir('/') def get_root(has_flash_mount = True): if '/flash' in sys.path: - print('/flash', end = '') + return '/flash' else: - print('/', end = '') + return '/' def is_directory(path): return True if os.stat(path)[0] == 0x4000 else False @@ -26,6 +25,9 @@ def get_all_files(path, array_of_files = []): return array_of_files +def iget_root(): + print(get_root(), end='') + def ilist_all(path): print(json.dumps(get_all_files(path))) @@ -38,3 +40,5 @@ def delete_folder(path): if file['type'] == 'folder': os.rmdir(file['path']) os.rmdir(path) + +os.chdir(get_root()) \ No newline at end of file diff --git a/ui/arduino/store.js b/ui/arduino/store.js index c69e5e7..bd03a2a 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -1694,7 +1694,7 @@ async function getAvailablePorts() { async function getBoardRoot() { let output = await serialBridge.execFile(await getHelperFullPath()) - output = await serialBridge.run(`get_root()`) + output = await serialBridge.run(`iget_root()`) let boardRoot = '' try { // Extracting the json output from serial response From 06de27a8908bf1a826d9fc60f98f2aa0f874b55e Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Sun, 13 Apr 2025 11:56:18 +0200 Subject: [PATCH 3/6] Working implementation of Board Root detection. Signed-off-by: ubi de feo --- ui/arduino/store.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index bd03a2a..373c816 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -285,7 +285,10 @@ async function store(state, emitter) { } emitter.emit('open-panel') emitter.emit('render') - await serialBridge.getPrompt() + if (state.isConnected) { + await serialBridge.getPrompt() + } + }) emitter.on('reset', async () => { log('reset') @@ -603,7 +606,7 @@ async function store(state, emitter) { } await serialBridge.saveFileContent( serialBridge.getFullPath( - '/', + state.boardNavigationRoot, state.boardNavigationPath, fileNameParameter ), @@ -782,7 +785,7 @@ async function store(state, emitter) { if (file.source === 'board') { await serialBridge.removeFile( serialBridge.getFullPath( - '/', + state.boardNavigationRoot, state.boardNavigationPath, file.fileName ) From 0ddffa7c33349cf158d6c6c2c5091d6c4ba7f2f6 Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Mon, 14 Apr 2025 09:10:22 +0200 Subject: [PATCH 4/6] Fixed query selector typo. Signed-off-by: ubi de feo --- ui/arduino/views/components/new-file-dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/arduino/views/components/new-file-dialog.js b/ui/arduino/views/components/new-file-dialog.js index 83ace3f..8e00d9e 100644 --- a/ui/arduino/views/components/new-file-dialog.js +++ b/ui/arduino/views/components/new-file-dialog.js @@ -65,7 +65,7 @@ function NewFileDialog(state, emit) { ` if (state.isNewFileDialogOpen) { - const el = newFileDialog.querySelector('#dialog-new-file .dialog-contents > input') + const el = newFileDialog.querySelector('#dialog-new-file .dialog-content > input') if (el) { el.focus() } From 46dcd656415caae44349d0268c4e882f8de849ee Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Mon, 14 Apr 2025 17:44:31 +0200 Subject: [PATCH 5/6] Amended ununsed signature parameter in get_root(). Signed-off-by: ubi de feo --- ui/arduino/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/arduino/helpers.py b/ui/arduino/helpers.py index ac4ec34..15ab644 100644 --- a/ui/arduino/helpers.py +++ b/ui/arduino/helpers.py @@ -2,7 +2,7 @@ import json import sys -def get_root(has_flash_mount = True): +def get_root(): if '/flash' in sys.path: return '/flash' else: From 3915443fbc5642b42109eca15d15cd9a44a3277c Mon Sep 17 00:00:00 2001 From: ubi de feo Date: Tue, 15 Apr 2025 12:53:51 +0200 Subject: [PATCH 6/6] Pointing BoardNavigationPath to /flash when it's the default writable mount-point. Signed-off-by: ubi de feo --- ui/arduino/store.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 6526f99..966e906 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -179,7 +179,7 @@ async function store(state, emitter) { // Connected and ready state.isConnecting = false state.isConnected = true - state.boardNavigationRoot = await getBoardRoot() + state.boardNavigationPath = await getBoardNavigationPath() updateMenu() if (state.view === 'editor' && state.panelHeight <= PANEL_CLOSED) { state.panelHeight = state.savedPanelHeight @@ -1699,7 +1699,7 @@ async function getAvailablePorts() { return await serialBridge.loadPorts() } -async function getBoardRoot() { +async function getBoardNavigationPath() { let output = await serialBridge.execFile(await getHelperFullPath()) output = await serialBridge.run(`iget_root()`) let boardRoot = ''