Keep dedicated USB logging quiet hooks out of nRF52 Full images

This commit is contained in:
mikecarper committed 2026-10-27 18:23:01 -07:00
1 parent b3df8bfd3f
commit 1f2fcfc449
4 files changed
+39 -3

No files matched your search

+2 -2
View File
@@ -94,7 +94,7 @@ static std::atomic<bool> usb_logging_enabled{true};
#endif
static std::atomic<bool> usb_logging_preference_known{false};
static std::atomic<bool> usb_debug_enabled{false};
#if MESH_USB_LOGGING_AVAILABLE
#if MESH_USB_LOGGING_AVAILABLE && !defined(MESH_DUAL_CDC_LOGGING)
static std::atomic<uint32_t> usb_packet_logging_quiet_until{0};
#endif
#if MESH_ENABLE_HOST_KISS
@@ -1297,7 +1297,7 @@ bool isUsbLoggingEnabled() {
return usb_logging_enabled.load(std::memory_order_relaxed);
}
#if MESH_USB_LOGGING_AVAILABLE
#if MESH_USB_LOGGING_AVAILABLE && !defined(MESH_DUAL_CDC_LOGGING)
void noteUsbConsoleCommand(const char* command) {
if (command == nullptr || hasDedicatedUsbLoggingPort() || isUsbLoggingPacketStream()) return;
while (*command == ' ' || *command == '\t' || *command == '\r' || *command == '\n') ++command;
+7 -1
View File
@@ -92,7 +92,13 @@ inline size_t nextUsbLoggingIdentityOffset(size_t current_offset,
// protect framed traffic and restores its saved choice after preferences load.
bool isUsbLoggingEnabled();
void setUsbLoggingEnabled(bool enabled);
#if MESH_USB_LOGGING_AVAILABLE
#if MESH_USB_LOGGING_AVAILABLE && defined(MESH_DUAL_CDC_LOGGING)
// Either the dedicated CDC or explicit packet stream owns capture in these
// builds. Both bypass quieting, so no timer or command parser is needed.
inline void noteUsbConsoleCommand(const char*) {}
inline void resumeUsbPacketLogging() {}
inline bool isUsbPacketLoggingAllowed() { return isUsbLoggingEnabled(); }
#elif MESH_USB_LOGGING_AVAILABLE
// Human console commands pause packet records for five minutes without
// changing the saved logging setting, functional replies, or debug output.
// Dedicated logging endpoints, explicit packet streams, and stats polls keep
+1
View File
@@ -46,6 +46,7 @@ static RescueStream rescue_input, rescue_output;
namespace mesh {
static bool usb_binary_owned = false;
bool isUsbBinaryStreamOwned() { return usb_binary_owned; }
void noteUsbConsoleCommand(const char*) {}
Stream& usbTerminalPort() { return rescue_output; }
Stream& usbCompanionPort() { return rescue_input; }
namespace hostkiss {
+29
View File
@@ -181,6 +181,35 @@ class UsbPacketLoggingQuietTests(unittest.TestCase):
ran = subprocess.run([str(binary)], capture_output=True, text=True, timeout=20)
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
def test_dual_cdc_inline_apis_preserve_both_continuous_capture_modes(self):
source = (ROOT / "src/helpers/UsbLogging.cpp").read_text()
harness = '''
#include <helpers/UsbLogging.h>
#include <cassert>
#include <initializer_list>
namespace mesh {
bool enabled=false,packet_stream=false;
bool isUsbLoggingEnabled(){return enabled;}
bool isUsbLoggingPacketStream(){return packet_stream;}
@DEDICATED@
}
int main(){
for(bool stream:{false,true})for(bool enabled:{false,true}){
mesh::packet_stream=stream;mesh::enabled=enabled;
assert(mesh::hasDedicatedUsbLoggingPort()==!stream);
mesh::noteUsbConsoleCommand(nullptr);mesh::noteUsbConsoleCommand("get name");
assert(mesh::isUsbPacketLoggingAllowed()==enabled);
mesh::resumeUsbPacketLogging();
assert(mesh::isUsbPacketLoggingAllowed()==enabled);
}
}
'''.replace("@DEDICATED@", method(source, "bool hasDedicatedUsbLoggingPort("))
with tempfile.TemporaryDirectory(prefix="meshcore-packet-dual-") as directory:
binary = self.compile(Path(directory), "dual", harness,
["-DMESH_DEBUG=1", "-DMESH_DUAL_CDC_LOGGING=1"])
ran = subprocess.run([str(binary)], capture_output=True, text=True, timeout=20)
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
def test_disabled_logging_build_has_noop_pause_apis(self):
with tempfile.TemporaryDirectory(prefix="meshcore-packet-disabled-") as directory:
for flags in ([], ["-DMESH_DEBUG=1", "-DMESH_USB_LOGGING_DISABLED=1"]):