Keep hardware CDC packet log lines whole under congestion
This commit is contained in:
1 parent
1ec9234d3c
commit
8a7fe7ff42
5 files changed
+150
-9
No files matched your search
@@ -32,6 +32,17 @@ inline bool& serialLogPortSeen() {
|
||||
|
||||
template <class T>
|
||||
bool serialLogEmit(T& out, const char* data, size_t len) {
|
||||
#if defined(ESP32_PLATFORM) && defined(ARDUINO_USB_CDC_ON_BOOT) && \
|
||||
(ARDUINO_USB_CDC_ON_BOOT == 1) && defined(ARDUINO_USB_MODE) && \
|
||||
(ARDUINO_USB_MODE == 1)
|
||||
// The HWCDC logging view checks this complete record again under the shared
|
||||
// producer guard. Never leave a line prefix behind when its host stalls.
|
||||
const int space = out.availableForWrite();
|
||||
if (space <= 0 || static_cast<size_t>(space) < len) return false;
|
||||
if (out.write(reinterpret_cast<const uint8_t*>(data), len) != len) return false;
|
||||
serialLogPortSeen() = true;
|
||||
return true;
|
||||
#else
|
||||
if (out.availableForWrite() <= 0) return false;
|
||||
|
||||
const uint32_t start = millis();
|
||||
@@ -55,6 +66,7 @@ bool serialLogEmit(T& out, const char* data, size_t len) {
|
||||
}
|
||||
serialLogPortSeen() = true;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <size_t CAP = SERIAL_LOG_LINE_MAX>
|
||||
|
||||
@@ -513,6 +513,11 @@ static SingleAttemptNonBlockingStream guarded_esp32_hwcdc_port(
|
||||
static AtomicWholeRecordNonBlockingStream<11>
|
||||
guarded_esp32_hwcdc_mota_port(guarded_esp32_hwcdc_port);
|
||||
|
||||
// Admit each complete packet log line under the same guard as CLI replies.
|
||||
// Short records can still use a smaller ring if the preferred allocation fails.
|
||||
static AtomicWholeRecordNonBlockingStream<640> guarded_esp32_hwcdc_logging_port(
|
||||
guarded_esp32_hwcdc_port);
|
||||
|
||||
static void serviceEsp32HwcdcTxKickExclusive(void*) {
|
||||
if (!esp32_hwcdc_tx_kick_pending.load(std::memory_order_acquire)
|
||||
|| !canAccessEsp32Hwcdc(nullptr)) {
|
||||
@@ -1393,7 +1398,7 @@ Stream& usbLoggingPort() {
|
||||
#if MESH_ESP32_TINYUSB_NONBLOCKING
|
||||
return buffered_esp32_tinyusb_logging_port;
|
||||
#elif MESH_ESP32_HWCDC_SESSION_GUARD
|
||||
return guarded_esp32_hwcdc_port;
|
||||
return guarded_esp32_hwcdc_logging_port;
|
||||
#elif defined(NRF52_PLATFORM)
|
||||
return nonblocking_primary_usb_logging_port;
|
||||
#else
|
||||
|
||||
Reference in new issue
Block a user