Default all USB Companions to ASCII across host sessions

This commit is contained in:
mikecarper committed 2026-09-13 17:13:51 -07:00
1 parent 794cf15395
commit 0938da5ea6
13 files changed
+398 -145

No files matched your search

+29 -1
View File
@@ -215,7 +215,7 @@ public:
}
};
// Coordinates the Full Companion USB startup handoff without consuming the
// Coordinates the Companion USB startup handoff without consuming the
// '<' byte. ArduinoSerialInterface remains the only binary protocol parser.
class UsbBinaryStartupProbe {
public:
@@ -271,6 +271,34 @@ public:
}
};
// A new physical/data session starts in ASCII after the old transport has
// been cleaned. A network terminal may temporarily own the CLI; a complete
// USB frame received while it does is an explicit choice of Binary mode.
class UsbAsciiSessionDefault {
bool _pending = false;
uint32_t _frame_count_at_reset = 0;
public:
void request(uint32_t completed_frame_count) {
_pending = true;
_frame_count_at_reset = completed_frame_count;
}
void cancel() { _pending = false; }
bool shouldRestore(bool transport_ready, bool network_terminal_active,
uint32_t completed_frame_count) {
if (!_pending) return false;
if (completed_frame_count != _frame_count_at_reset) {
_pending = false;
return false;
}
if (!transport_ready || network_terminal_active) return false;
_pending = false;
return true;
}
};
// Tracks the narrow case where TCP temporarily borrows an idle startup ASCII
// terminal. A complete USB Binary frame during the TCP session wins ownership,
// so closing TCP must not force that USB client back to ASCII.