Refactor d1l_logger.py with VID-based serial port detection #52
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/logger-gemini-updates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace glob-based find_serial_port() with serial.tools.list_ports for robust USB device detection.
Changes:
Testing:
Addresses Gemini code review feedback on PR #51.
🤖 Generated with Claude Code
Description
Type of Change
Related Issues
Testing Performed
Hardware Tested
Code Quality Checklist
Breaking Changes
Screenshots/Logs
Additional Notes
Summary of Changes
Hello @okapteinis, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly improves the reliability of serial port auto-detection for the D1L device within the
d1l_logger.pyscript. By transitioning from a less stableglob-based approach to leveraging theserial.tools.list_portsmodule, the system now prioritizes identification via USB Vendor ID, with a robust fallback to device name patterns. This change ensures more consistent and accurate device discovery across various operating systems, directly addressing previous feedback and enhancing the overall user experience.Highlights
glob-based serial port detection ind1l_logger.pywith the more robustserial.tools.list_portsmodule.Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either
/gemini <command>or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page./gemini review/gemini summary/gemini helpCustomization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a
.gemini/folder in the base of the repository. Detailed instructions can be found here.Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩︎
Code Review
This pull request refactors the serial port detection logic in
d1l_logger.pyto useserial.tools.list_portsinstead ofglob. This is a great improvement, making the detection more robust and portable by prioritizing USB Vendor ID (VID) matching, with a fallback to device name patterns. The code is clear and the change is well-documented in the PR description. I have one suggestion to improve maintainability by defining the name patterns as a module-level constant.For improved code clarity and maintainability, it would be better to define
name_patternsas a module-level constant, similar toD1L_VID. This avoids redefining the list on every function call and makes it clear that it's a fixed configuration value.You could add
NAME_PATTERNS = ['usbserial', 'ttyUSB', 'ttyACM', 'SLAB_USBtoUART', 'usbmodem']at the top of the file and then use that constant in the loop.