Skip to content

Fix/root detection #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ui/arduino/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import os
import json
os.chdir('/')
import sys

def get_root():
if '/flash' in sys.path:
return '/flash'
else:
return '/'

def is_directory(path):
return True if os.stat(path)[0] == 0x4000 else False

@@ -18,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)))

@@ -30,3 +40,5 @@ def delete_folder(path):
if file['type'] == 'folder':
os.rmdir(file['path'])
os.rmdir(path)

os.chdir(get_root())
27 changes: 24 additions & 3 deletions ui/arduino/store.js
Original file line number Diff line number Diff line change
@@ -179,6 +179,7 @@ async function store(state, emitter) {
// Connected and ready
state.isConnecting = false
state.isConnected = true
state.boardNavigationPath = await getBoardNavigationPath()
updateMenu()
if (state.view === 'editor' && state.panelHeight <= PANEL_CLOSED) {
state.panelHeight = state.savedPanelHeight
@@ -288,7 +289,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')
@@ -606,7 +610,7 @@ async function store(state, emitter) {
}
await serialBridge.saveFileContent(
serialBridge.getFullPath(
'/',
state.boardNavigationRoot,
state.boardNavigationPath,
fileNameParameter
),
@@ -785,7 +789,7 @@ async function store(state, emitter) {
if (file.source === 'board') {
await serialBridge.removeFile(
serialBridge.getFullPath(
'/',
state.boardNavigationRoot,
state.boardNavigationPath,
file.fileName
)
@@ -1695,6 +1699,23 @@ async function getAvailablePorts() {
return await serialBridge.loadPorts()
}

async function getBoardNavigationPath() {
let output = await serialBridge.execFile(await getHelperFullPath())
output = await serialBridge.run(`iget_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)
2 changes: 1 addition & 1 deletion ui/arduino/views/components/new-file-dialog.js
Original file line number Diff line number Diff line change
@@ -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()
}