Skip to content

Commit

Permalink
I was still getting XOFF with no XON with one of my test cases (63 A …
Browse files Browse the repository at this point in the history
…followed by a newline, sent via tio hexadecimal mode).

I added the additional patch here, which fixed it. The extra calls to flush() are probably also a good idea.
  • Loading branch information
tlyu authored and obra committed Dec 13, 2023
1 parent 601a023 commit 81851f7
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ void FocusSerial::manageFlowControl() {
if (xon == true) {
if (avail > RECV_BUFFER_THRESHOLD) {
Runtime.serialPort().write(XOFF); // Send XOFF to stop data
Runtime.serialPort().flush();
xon = false;
}
} else {
if (avail < RECV_BUFFER_RESUME) {
Runtime.serialPort().write(XON); // Send XON to resume data
Runtime.serialPort().flush();
xon = true;
}
}
Expand All @@ -65,6 +67,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
break;
}
c = Runtime.serialPort().read();
manageFlowControl();
// Don't store the separator; just stash it
if (c == SEPARATOR) {
break;
Expand All @@ -82,6 +85,7 @@ EventHandlerResult FocusSerial::afterEachCycle() {
Runtime.onFocusEvent(input_);
while (Runtime.serialPort().available()) {
c = Runtime.serialPort().read();
manageFlowControl();
if (c == NEWLINE) {
// newline serves as an end-of-command marker
// don't drain the buffer past there
Expand Down

0 comments on commit 81851f7

Please sign in to comment.