Skip to content

Conversation

@lutgaru
Copy link
Collaborator

@lutgaru lutgaru commented Jul 26, 2025

This PR introduces several improvements and refactors to the log handling and serial communication subsystems:

Changes

  • Refactored Log Writing:

    • The log file is now written directly with the raw received data (&[u8]) instead of converting to a string, ensuring binary data is handled correctly.
    • The write_to_file method in FileLogPanel now accepts a byte slice.
  • RxPanel Buffer Optimization:

    • RxPanel now uses a VecDeque<char> for its content buffer, allowing efficient removal of old characters when the log exceeds the maximum length.
    • Improved the append_log method to maintain the buffer size and performance.
    • Updated serialization/deserialization logic for the new buffer type.
  • UI Improvements:

    • The log display uses the new buffer and always shows the latest content efficiently.
  • Serial Communication Robustness:

    • Improved error handling for serial port reads.
    • Now gracefully handles channel disconnects and serial read errors, preventing panics and unnecessary thread activity.

lutgaru added 2 commits July 24, 2025 15:19
- Replace String::from_utf8_lossy().to_string() with into_owned() for better performance
- Refactor RxPanel to use VecDeque<char> for efficient character-based log management
  - Eliminates UTF-8 character boundary issues when truncating logs
  - Implements circular buffer pattern for O(1) character insertion/removal
  - Updates serialization to work with VecDeque<char>
- Add graceful error handling in serial communication thread
  - Handle serial read errors without panicking
  - Detect GUI channel disconnection and stop thread cleanly
  - Prevent cascade failures when GUI thread crashes

Fixes crashes caused by assertion failed: self.is_char_boundary(end) when
processing serial data containing invalid UTF-8 sequences.
@lutgaru lutgaru merged commit 6b14f88 into master Jul 26, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant