From 79b754e44bfae8e8643f93aa25f3ef8f5094f83e Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Wed, 28 Jun 2023 16:24:16 +0200 Subject: [PATCH 1/2] Move functions close to each other --- preload.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/preload.js b/preload.js index ad01aa5..0893001 100644 --- a/preload.js +++ b/preload.js @@ -23,6 +23,9 @@ const Serial = { }, stop: async () => { await board.stop() + return Promise.resolve() + }, + exit_raw_repl: async () => { await board.exit_raw_repl() return Promise.resolve() }, @@ -70,9 +73,6 @@ const Serial = { createFolder: async (folder) => { return await board.fs_mkdir(folder) }, - exit_raw_repl: async () => { - return board.exit_raw_repl() - }, getNavigationPath: (navigation, target) => { return [navigation, target].filter(p => p).join('/') }, From b70a767b5f4c8a92db0413ee2bc4cacd6e1aefab Mon Sep 17 00:00:00 2001 From: Murilo Polese Date: Wed, 28 Jun 2023 16:25:14 +0200 Subject: [PATCH 2/2] Make sure to get a clean repl before performing actions --- ui/arduino/store.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/arduino/store.js b/ui/arduino/store.js index 8115e69..3b5bedb 100644 --- a/ui/arduino/store.js +++ b/ui/arduino/store.js @@ -135,12 +135,14 @@ function store(state, emitter) { if (!state.isTerminalOpen) emitter.emit('show-terminal') let editor = state.cache(AceEditor, 'editor').editor let code = editor.getValue() + await serial.stop() await serial.run(code) emitter.emit('render') }) emitter.on('stop', async () => { log('stop') await serial.stop() + await serial.exit_raw_repl() emitter.emit('render') }) emitter.on('reset', async () => { @@ -173,6 +175,7 @@ function store(state, emitter) { emitter.emit('message', `Saving ${filename} on ${deviceName}.`) if (state.selectedDevice === 'serial') { + await serial.stop() await serial.saveFileContent( serial.getFullPath( state.serialPath, @@ -213,6 +216,7 @@ function store(state, emitter) { if (confirm(`Do you want to remove ${state.selectedFile} from ${deviceName}?`)) { if (state.selectedDevice === 'serial') { + await serial.stop() await serial.removeFile(state.serialNavigation + '/' + state.selectedFile) emitter.emit('new-file', 'serial') } @@ -253,6 +257,7 @@ function store(state, emitter) { let content = '' if (state.selectedDevice === 'serial') { + await serial.stop() content = await serial.loadFile( serial.getFullPath( state.serialPath, @@ -417,6 +422,7 @@ function store(state, emitter) { let contents = cleanCharacters(editor.getValue()) editor.setValue(contents) if (state.unsavedChanges) { + await serial.stop() await serial.saveFileContent( serial.getFullPath( state.serialPath, @@ -527,6 +533,7 @@ function store(state, emitter) { editor.setValue(contents) if (state.isConnected && state.selectedDevice === 'serial') { + await serial.stop() // Ask for confirmation to overwrite existing file let confirmation = true if (state.serialFiles.find(f => f.path === filename)) { 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