@@ -22,6 +22,7 @@ const PROMPT_TIMEOUT = 20000;
2222const CODE_EXECUTION_TIMEOUT = 15000 ;
2323const CODE_INTERRUPT_TIMEOUT = 5000 ;
2424const PROMPT_CHECK_INTERVAL = 50 ;
25+ const PARTIAL_TOKEN_TIMEOUT = 250 ;
2526
2627const REGEX_PROMPT_RAW_MODE = / r a w R E P L ; C T R L - B t o e x i t / ;
2728const 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