From 24d5726ee258e91a344c477e7e4104990cab571a Mon Sep 17 00:00:00 2001 From: Masonmason Date: Thu, 24 Jul 2025 19:25:02 +0800 Subject: [PATCH 1/3] 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}") From 260668ceb8341bad3e9b9f8a6f9ab56797e17832 Mon Sep 17 00:00:00 2001 From: Masonmason Date: Thu, 24 Jul 2025 19:26:37 +0800 Subject: [PATCH 2/3] fix: Register QTextCursor meta type to eliminate Qt warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add qRegisterMetaType(QTextCursor) to prevent Qt threading warning - Import QTextCursor and qRegisterMetaType from PyQt5 - Resolves "Cannot queue arguments of type 'QTextCursor'" warning - Ensures thread-safe GUI updates for terminal display 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- cluster4npu_ui/ui/dialogs/deployment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cluster4npu_ui/ui/dialogs/deployment.py b/cluster4npu_ui/ui/dialogs/deployment.py index e327bc7..4249a9b 100644 --- a/cluster4npu_ui/ui/dialogs/deployment.py +++ b/cluster4npu_ui/ui/dialogs/deployment.py @@ -32,8 +32,8 @@ from PyQt5.QtWidgets import ( QCheckBox, QGroupBox, QScrollArea, QTableWidget, QTableWidgetItem, QHeaderView, QMessageBox, QSplitter, QFrame ) -from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer -from PyQt5.QtGui import QFont, QColor, QPalette, QImage, QPixmap +from PyQt5.QtCore import Qt, QThread, pyqtSignal, QTimer, qRegisterMetaType +from PyQt5.QtGui import QFont, QColor, QPalette, QImage, QPixmap, QTextCursor # Import our converter and pipeline system sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'core', 'functions')) @@ -317,6 +317,9 @@ class DeploymentDialog(QDialog): def __init__(self, pipeline_data: Dict[str, Any], parent=None): super().__init__(parent) + # Register QTextCursor for thread-safe signal passing + qRegisterMetaType(QTextCursor) + self.pipeline_data = pipeline_data self.deployment_worker = None self.pipeline_config = None From ab802e60cfce8596e34b3d9c37a09859d53d7b38 Mon Sep 17 00:00:00 2001 From: Masonmason Date: Thu, 24 Jul 2025 19:29:26 +0800 Subject: [PATCH 3/3] fix: Remove dongle USB timeout setting to prevent camera connection crashes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove kp.core.set_timeout() call that causes crashes when camera is connected - Add explanatory message indicating timeout is skipped for stability - This prevents the system crash that occurs during camera initialization - Trade-off: Removes USB timeout but ensures stable camera operation The timeout setting was conflicting with camera connection process, causing the entire system to crash during device initialization. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- cluster4npu_ui/core/functions/Multidongle.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster4npu_ui/core/functions/Multidongle.py b/cluster4npu_ui/core/functions/Multidongle.py index 8700f27..9a4a7a5 100644 --- a/cluster4npu_ui/core/functions/Multidongle.py +++ b/cluster4npu_ui/core/functions/Multidongle.py @@ -289,9 +289,9 @@ class MultiDongle: sys.exit(1) # setting timeout of the usb communication with the device + # Note: Timeout setting removed as it causes crashes when camera is connected print('[Set Device Timeout]') - kp.core.set_timeout(device_group=self.device_group, milliseconds=5000) - print(' - Success') + print(' - Skipped (prevents camera connection crashes)') # if self.upload_fw: try: