From 81851f7878c9d3ca58bedbecaa16c3802fddf114 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Tue, 12 Dec 2023 21:23:18 -0800 Subject: [PATCH] I was still getting XOFF with no XON with one of my test cases (63 A 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. --- .../src/kaleidoscope/plugin/FocusSerial.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp index e1091382bc..30d7bb6741 100644 --- a/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp +++ b/plugins/Kaleidoscope-FocusSerial/src/kaleidoscope/plugin/FocusSerial.cpp @@ -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; } } @@ -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; @@ -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