Skip to content

Commit

Permalink
Merge pull request #151 from arduino/development
Browse files Browse the repository at this point in the history
Development to main
  • Loading branch information
ubidefeo authored Dec 6, 2024
2 parents 7da32ee + 9f56d75 commit adfef3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ui/arduino/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ button.small .icon {

#tabs {
display: flex;
padding: 10px 10px 0px 40px;
padding: 10px 10px 0px 60px;
align-items: center;
gap: 10px;
align-self: stretch;
Expand Down Expand Up @@ -231,7 +231,7 @@ button.small .icon {
#code-editor .cm-gutters {
background-color: #ECF1F1;
border-right: none;
width: 40px;
width: 60px;
font-size: 14px;
}

Expand Down
24 changes: 19 additions & 5 deletions ui/arduino/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,28 @@ async function store(state, emitter) {
state.isConnecting = true
emitter.emit('render')

let timeout_id = setTimeout(() => emitter.emit('connection-timeout'), 5000)
await serial.connect(path)
clearTimeout(timeout_id)

// The following Timeout operation will be cleared after a succesful getPrompt()
// If a board has crashed and/or cannot return a REPL prompt, the connection will fail
// and the user will be prompted to reset the device and try again.
let timeout_id = setTimeout(() => {
let response = win.openDialog({
type: 'question',
buttons: ['OK'],
cancelId: 0,
message: "Could not connect to the board. Reset it and try again."
})
console.log('Reset request acknowledged', response)
emitter.emit('connection-timeout')
}, 3500)
try {
await serial.connect(path)
} catch(e) {
console.error(e)
}
// Stop whatever is going on
// Recover from getting stuck in raw repl
await serial.getPrompt()

clearTimeout(timeout_id)
// Connected and ready
state.isConnecting = false
state.isConnected = true
Expand Down

0 comments on commit adfef3a

Please sign in to comment.