Skip to content

48 improve flush robustness#109

Merged
pierre-rouanet merged 5 commits into
developfrom
48-improve-flush-robustness
Jan 6, 2026
Merged

48 improve flush robustness#109
pierre-rouanet merged 5 commits into
developfrom
48-improve-flush-robustness

Conversation

@pierre-rouanet

Copy link
Copy Markdown
Member
  • Remove assert and uses Err instead.
  • Add retry and post delay to improve robustness

- Add retries and delay
- Raise proper error instead of assert.
@pierre-rouanet
pierre-rouanet requested a review from Copilot January 5, 2026 15:27
@pierre-rouanet pierre-rouanet self-assigned this Jan 5, 2026
@pierre-rouanet pierre-rouanet added the enhancement New feature or request label Jan 5, 2026
@pierre-rouanet pierre-rouanet linked an issue Jan 5, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the robustness of the serial port flush operation by replacing an assert with proper error handling and implementing a retry mechanism with configurable delays.

Key Changes:

  • Replaced assert! with error return to handle flush failures gracefully
  • Added retry logic with configurable attempts and delays between retries
  • Improved logging for flush operations with warnings and errors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dynamixel_protocol/mod.rs Outdated
Ok(())
} else {
log::error!("Could not flush input buffer before sending instruction");
Err(Box::new(CommunicationErrorKind::ParsingError))

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error kind ParsingError is misleading for a flush failure. Consider using a more appropriate error variant that indicates a communication or buffer flush failure, or create a new error variant if one doesn't exist.

Suggested change
Err(Box::new(CommunicationErrorKind::ParsingError))
Err(Box::new(CommunicationErrorKind::TimeoutError))

Copilot uses AI. Check for mistakes.
max_retries
);
self.flush(port)?;
std::thread::sleep(flush_after_delay);

Copilot AI Jan 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking the thread with std::thread::sleep inside a retry loop may not be ideal for async contexts or performance-sensitive code. Consider whether this blocking behavior is acceptable for all use cases of this trait, or if a configurable sleep strategy would be better.

Copilot uses AI. Check for mistakes.
@pierre-rouanet
pierre-rouanet merged commit 67dfc6c into develop Jan 6, 2026
15 checks passed
@pierre-rouanet
pierre-rouanet deleted the 48-improve-flush-robustness branch January 6, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve flush robustness.

2 participants