Skip to content

Commit c039ea5

Browse files
committed
Implemented board root detection (/ or /flash).
Signed-off-by: ubi de feo <me@ubidefeo.com>
1 parent c58289d commit c039ea5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

ui/arduino/helpers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import os
22
import json
3+
import sys
34
os.chdir('/')
5+
6+
def get_root(has_flash_mount = True):
7+
if '/flash' in sys.path:
8+
print('/flash', end = '')
9+
else:
10+
print('/', end = '')
11+
412
def is_directory(path):
513
return True if os.stat(path)[0] == 0x4000 else False
614

ui/arduino/store.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ async function store(state, emitter) {
175175
// Connected and ready
176176
state.isConnecting = false
177177
state.isConnected = true
178+
state.boardNavigationRoot = await getBoardRoot()
178179
updateMenu()
179180
if (state.view === 'editor' && state.panelHeight <= PANEL_CLOSED) {
180181
state.panelHeight = state.savedPanelHeight
@@ -1691,6 +1692,23 @@ async function getAvailablePorts() {
16911692
return await serialBridge.loadPorts()
16921693
}
16931694

1695+
async function getBoardRoot() {
1696+
let output = await serialBridge.execFile(await getHelperFullPath())
1697+
output = await serialBridge.run(`get_root()`)
1698+
let boardRoot = ''
1699+
try {
1700+
// Extracting the json output from serial response
1701+
output = output.substring(
1702+
output.indexOf('OK')+2,
1703+
output.indexOf('\x04')
1704+
)
1705+
boardRoot = output
1706+
} catch (e) {
1707+
log('error', output)
1708+
}
1709+
return boardRoot
1710+
}
1711+
16941712
async function getBoardFiles(path) {
16951713
await serialBridge.getPrompt()
16961714
let files = await serialBridge.ilistFiles(path)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy