@@ -424,7 +424,7 @@ class G2coreAPI extends EventEmitter {
424
424
this . emit ( 'setupDone' ) ;
425
425
426
426
// Allow data to be sent. We'll start with 5 lines to fill the buffer.
427
- this . linesRequested = 5 ;
427
+ this . _resetLinesRequested ( ) ;
428
428
this . _sendLines ( ) ;
429
429
} ) ;
430
430
} ; // _completeConnection
@@ -467,7 +467,15 @@ class G2coreAPI extends EventEmitter {
467
467
this . emit ( 'sentLine' , lastLineSent ) ;
468
468
} ; // _sendLines
469
469
470
+
471
+ /**
472
+ * _resetLinesRequested - internal only
473
+ */
474
+ _resetLinesRequested ( ) {
475
+ this . linesRequested = 5 ;
476
+ } ; // _resetLinesRequested
470
477
478
+
471
479
/**
472
480
* flush - empty the send buffer, without sending what's left
473
481
*/
@@ -479,7 +487,7 @@ class G2coreAPI extends EventEmitter {
479
487
this . lineBuffer . length = 0 ;
480
488
481
489
// Reset line requested
482
- this . linesRequested = 5 ;
490
+ this . _resetLinesRequested ( ) ;
483
491
484
492
// Send a queue flush followed by an alarm clear
485
493
this . _write ( '\x04' ) ; // send the ^D
@@ -603,6 +611,15 @@ class G2coreAPI extends EventEmitter {
603
611
this . ignoredResponses ++ ;
604
612
}
605
613
this . _write ( value ) ;
614
+
615
+ // handle flush command
616
+ if ( typeof value === 'string' && value . match ( / ^ [ % ] + $ / ) ) {
617
+ this . _resetLinesRequested ( ) ;
618
+ this . linesSent = 0 ;
619
+ this . ignoredResponses = 0 ;
620
+ this . lineBuffer . length = 0 ;
621
+ }
622
+
606
623
return ;
607
624
}
608
625
0 commit comments