fix: Restore USB timeout setting and improve terminal display reliability

- 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 <noreply@anthropic.com>
This commit is contained in:
Masonmason 2025-07-24 19:25:02 +08:00
parent f41d9ae5c8
commit 24d5726ee2
2 changed files with 12 additions and 9 deletions

View File

@ -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:

View File

@ -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}")