feat: enhance Windows UART compatibility with platform-specific handling#13
Merged
wizzomafizzo merged 26 commits intomainfrom Sep 17, 2025
Merged
feat: enhance Windows UART compatibility with platform-specific handling#13wizzomafizzo merged 26 commits intomainfrom
wizzomafizzo merged 26 commits intomainfrom
Conversation
- Add Windows-specific timeout adjustments (100ms vs 50ms for other platforms) - Implement Windows post-write delay for proper buffer flushing - Add Windows port recovery mechanism for stuck COM port situations - Include comprehensive Windows-specific test coverage - Platform detection utilities for Windows vs other OS handling Addresses Windows USB-to-serial driver timing differences and provides recovery mechanisms for common Windows COM port issues.
…empty data Critical fixes for Windows USB-serial driver compatibility: - Add missing windowsPostWriteDelay() calls to all write operations (wakeUp, sendAck, sendNack, sendFrame) - Reduce readRemainingData timeout from 2s to 500ms/750ms to prevent accumulation causing 30s delays - Add windowsPortRecovery() calls on read errors with helper functions - Implement platform-specific read timing (Windows: 2ms initial, 25ms retry vs Linux/Mac: 5ms, 50ms) - Extract helper functions to reduce complexity and pass linting Addresses root causes: timeout accumulation, missing USB-serial buffer flush delays, and absent error recovery that were causing intermittent failures on Windows.
…iles Enhance retry behavior with intelligent, command-specific retry profiles: - ProfileDetection: Higher retry count for tag detection commands (5 attempts) - ProfileDataExchange: Standard retry for data operations (3 attempts) - ProfileStatus: Quick retry for status commands (2 attempts) - ProfileDefault: General commands (3 attempts) UART transport improvements: - Command-specific timeouts for optimal performance - Robust empty response recovery with escalating procedures - Enhanced health monitoring system with periodic checks - Comprehensive input buffer clearing to prevent stale data - Windows-specific timing optimizations and port recovery - Improved wake-up sequence with verification and double-wake pattern - Better ACK waiting with configurable timeouts and retry logic Fixes Windows UART timing issues and improves overall reliability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem Addressed
Windows USB-to-serial drivers have different timing characteristics compared to native UART or other platforms, which can cause:
Solution
This PR implements platform-specific handling that:
Test Coverage
Research & Best Practices
Implementation follows industry best practices for Windows COM port handling:
The go.bug.st/serial library (v1.6.4) provides additional capabilities like
SetDTR(),SetRTS(), and buffer management methods that could be leveraged for future enhancements if specific issues arise.Test plan