From 24d5726ee258e91a344c477e7e4104990cab571a Mon Sep 17 00:00:00 2001 From: Masonmason Date: Thu, 24 Jul 2025 19:25:02 +0800 Subject: [PATCH] fix: Restore USB timeout setting and improve terminal display reliability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Re-enable kp.core.set_timeout() which is required for proper device communication - Fix GUI terminal truncation issue by using append() instead of setPlainText() - Remove aggressive line limiting that was causing log display to stop midway - Implement gentler memory management (trim only after 1000+ lines) - This should resolve pipeline timeout issues and complete log display The previous USB timeout disable was causing stage timeouts without inference results. The terminal display issue was due to frequent text replacement causing display corruption. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- cluster4npu_ui/core/functions/Multidongle.py | 2 +- cluster4npu_ui/ui/dialogs/deployment.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cluster4npu_ui/core/functions/Multidongle.py b/cluster4npu_ui/core/functions/Multidongle.py index 6e1c88b..8700f27 100644 --- a/cluster4npu_ui/core/functions/Multidongle.py +++ b/cluster4npu_ui/core/functions/Multidongle.py @@ -290,7 +290,7 @@ class MultiDongle: # setting timeout of the usb communication with the device print('[Set Device Timeout]') - # kp.core.set_timeout(device_group=self.device_group, milliseconds=5000) + kp.core.set_timeout(device_group=self.device_group, milliseconds=5000) print(' - Success') # if self.upload_fw: diff --git a/cluster4npu_ui/ui/dialogs/deployment.py b/cluster4npu_ui/ui/dialogs/deployment.py index abc20b3..e327bc7 100644 --- a/cluster4npu_ui/ui/dialogs/deployment.py +++ b/cluster4npu_ui/ui/dialogs/deployment.py @@ -877,19 +877,22 @@ Stage Configurations: def update_terminal_output(self, terminal_text: str): """Update the terminal output display with new text.""" try: - # Append to terminal display (keep last 200 lines) - current_text = self.terminal_output_display.toPlainText() - lines = current_text.split('\n') - if len(lines) > 200: - lines = lines[-100:] # Keep last 100 lines - current_text = '\n'.join(lines) - - self.terminal_output_display.setPlainText(current_text + terminal_text) + # Use append() instead of setPlainText() for better performance and no truncation + self.terminal_output_display.append(terminal_text.rstrip('\n')) # Auto-scroll to bottom scrollbar = self.terminal_output_display.verticalScrollBar() scrollbar.setValue(scrollbar.maximum()) + # Optional: Limit total lines to prevent excessive memory usage + # Only trim if we have way too many lines (e.g., > 1000) + document = self.terminal_output_display.document() + if document.lineCount() > 1000: + cursor = self.terminal_output_display.textCursor() + cursor.movePosition(cursor.Start) + cursor.movePosition(cursor.Down, cursor.KeepAnchor, 200) # Select first 200 lines + cursor.removeSelectedText() + except Exception as e: print(f"Error updating terminal output: {e}")