Skip to content

Commit 4ba5831

Browse files
authoredJul 5, 2023
Merge pull request #57 from arduino/bugfix/run-twice
Bugfix/run twice
2 parents 4e890a6 + b44aa56 commit 4ba5831

File tree

6 files changed

+994
-586
lines changed

6 files changed

+994
-586
lines changed
 

‎package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"post-set-shell": "npm config set script-shell bash",
99
"rebuild": "electron-rebuild",
10-
"dev": "electron ./",
10+
"dev": "electron --inspect ./",
1111
"build": "npm run post-set-shell && electron-builder $(if [ $(uname -m) = arm64 ]; then echo --mac --x64; fi)",
1212
"postinstall": "npm run post-set-shell && npm run rebuild"
1313
},
@@ -38,7 +38,7 @@
3838
"license": "MIT",
3939
"dependencies": {
4040
"about-window": "^1.15.2",
41-
"micropython.js": "github:arduino/micropython.js#v1.4.0"
41+
"micropython.js": "github:arduino/micropython.js#v1.4.1"
4242
},
4343
"engines": {
4444
"node": "18"

‎preload.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ const Serial = {
2121
run: async (code) => {
2222
return board.run(code)
2323
},
24-
stop: async () => {
25-
await board.stop()
26-
return Promise.resolve()
24+
get_prompt: async () => {
25+
return board.get_prompt()
2726
},
28-
exit_raw_repl: async () => {
29-
await board.exit_raw_repl()
27+
keyboard_interrupt: async () => {
28+
await board.stop()
3029
return Promise.resolve()
3130
},
3231
reset: async () => {

‎ui/arduino/package-lock.json

Lines changed: 960 additions & 549 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ui/arduino/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "micropython-lab-arduino-ui",
3-
"version": "1.0.0",
3+
"version": "0.8.0",
44
"description": "Interface for Arduino's MicroPython Lab IDE",
55
"main": "index.js",
66
"scripts": {

‎ui/arduino/store.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ function store(state, emitter) {
9292
await serial.connect(path)
9393

9494
// Stop whatever is going on
95-
await serial.stop()
9695
// Recover from getting stuck in raw repl
97-
await serial.exit_raw_repl()
96+
await serial.get_prompt()
9897

9998
state.isConnected = true
10099
emitter.emit('close-port-dialog')
@@ -135,14 +134,13 @@ function store(state, emitter) {
135134
if (!state.isTerminalOpen) emitter.emit('show-terminal')
136135
let editor = state.cache(AceEditor, 'editor').editor
137136
let code = editor.getValue()
138-
await serial.stop()
139-
await serial.run(code)
137+
await serial.get_prompt()
138+
serial.run(code)
140139
emitter.emit('render')
141140
})
142141
emitter.on('stop', async () => {
143142
log('stop')
144-
await serial.stop()
145-
await serial.exit_raw_repl()
143+
await serial.get_prompt()
146144
emitter.emit('render')
147145
})
148146
emitter.on('reset', async () => {
@@ -175,7 +173,7 @@ function store(state, emitter) {
175173
emitter.emit('message', `Saving ${filename} on ${deviceName}.`)
176174

177175
if (state.selectedDevice === 'serial') {
178-
await serial.stop()
176+
await serial.get_prompt()
179177
await serial.saveFileContent(
180178
serial.getFullPath(
181179
state.serialPath,
@@ -216,7 +214,7 @@ function store(state, emitter) {
216214

217215
if (confirm(`Do you want to remove ${state.selectedFile} from ${deviceName}?`)) {
218216
if (state.selectedDevice === 'serial') {
219-
await serial.stop()
217+
await serial.get_prompt()
220218
await serial.removeFile(state.serialNavigation + '/' + state.selectedFile)
221219
emitter.emit('new-file', 'serial')
222220
}
@@ -257,7 +255,7 @@ function store(state, emitter) {
257255

258256
let content = ''
259257
if (state.selectedDevice === 'serial') {
260-
await serial.stop()
258+
await serial.get_prompt()
261259
content = await serial.loadFile(
262260
serial.getFullPath(
263261
state.serialPath,
@@ -308,7 +306,7 @@ function store(state, emitter) {
308306
return folders.concat(files)
309307
}
310308
if (state.isConnected) {
311-
await serial.stop()
309+
await serial.get_prompt()
312310
try {
313311
const files = await serial.ilistFiles(
314312
serial.getFullPath(
@@ -422,7 +420,7 @@ function store(state, emitter) {
422420
let contents = cleanCharacters(editor.getValue())
423421
editor.setValue(contents)
424422
if (state.unsavedChanges) {
425-
await serial.stop()
423+
await serial.get_prompt()
426424
await serial.saveFileContent(
427425
serial.getFullPath(
428426
state.serialPath,
@@ -533,7 +531,7 @@ function store(state, emitter) {
533531
editor.setValue(contents)
534532

535533
if (state.isConnected && state.selectedDevice === 'serial') {
536-
await serial.stop()
534+
await serial.get_prompt()
537535
// Ask for confirmation to overwrite existing file
538536
let confirmation = true
539537
if (state.serialFiles.find(f => f.path === filename)) {

0 commit comments

Comments
 (0)
Please sign in to comment.