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

+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"]):