Skip to content

Commit 1d14bb6

Browse files
authored
Merge pull request #22 from makermelissa/main
Handle reset command better
2 parents 58199f7 + 4a09ef6 commit 1d14bb6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

repl.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const PROMPT_TIMEOUT = 20000;
2222
const CODE_EXECUTION_TIMEOUT = 15000;
2323
const CODE_INTERRUPT_TIMEOUT = 5000;
2424
const PROMPT_CHECK_INTERVAL = 50;
25+
const PARTIAL_TOKEN_TIMEOUT = 250;
2526

2627
const REGEX_PROMPT_RAW_MODE = /raw REPL; CTRL-B to exit/;
2728
const REGEX_PROMPT_NORMAL_MODE = />>> /;
@@ -408,10 +409,11 @@ export class REPL {
408409
this._promptCheckPointer = 0; // Used for looking at prompt output/control characters
409410
this._checkpointCount = 0;
410411
this._rawByteCount = 0;
412+
this._partialToken = null;
411413
this.terminalOutput = true;
412414
}
413415

414-
//// Placeholder Functions ////
416+
//// Abstract Functions ////
415417
setTitle(title, append=false) {
416418
return;
417419
}
@@ -561,6 +563,11 @@ export class REPL {
561563
console.log("Unexpected bytes encountered. " + bytes);
562564
}
563565
return;
566+
} else if (bytes.slice(0, 4) == CHAR_TITLE_START) {
567+
// Device was reset, wait for prompt
568+
await this.serialTransmit(CHAR_CTRL_C);
569+
await this.getToPrompt();
570+
return;
564571
} else {
565572
console.error("Unexpected output in raw mode: " + bytes);
566573
return;
@@ -790,6 +797,8 @@ export class REPL {
790797
for (let token of tokens) {
791798
this._tokenQueue.push(token);
792799
}
800+
801+
// Process the queued tokens
793802
await this._processQueuedTokens();
794803
}
795804

0 commit comments

Comments
 (0)