Fix for ports higher than com9 not being properly auto-detected for pinone#51
Merged
jsm174 merged 1 commit intovpinball:masterfrom May 5, 2026
Merged
Fix for ports higher than com9 not being properly auto-detected for pinone#51jsm174 merged 1 commit intovpinball:masterfrom
jsm174 merged 1 commit intovpinball:masterfrom
Conversation
…inone
I removed the entire section but it could also be #ifndef _WIN32
Claude's explanation:
On Linux/macOS, serial ports are real filesystem entries — /dev/ttyUSB0, /dev/cu.usbmodem1, etc. Opening one with std::ifstream is a cheap way to verify the device file actually exists before bothering to call sp_open.
On Windows, COM ports are not filesystem files. They live in the Windows device namespace. COM1–COM9 happen to work as legacy DOS device aliases, so std::ifstream("COM3") opens. COM10+ breaks because those aliases only cover single digits — std::ifstream("COM10") fails even when the port is perfectly real and connected. The correct way to open them is \\.\COM10, which is exactly what libserialport's sp_open does internally.
So the original code (without #ifndef) would hit that ifstream check on Windows, fail on COM10, and return "" — making the port invisible to the auto-configurator.
jsm174
approved these changes
May 5, 2026
Collaborator
|
Thanks for this! |
Contributor
Author
|
No problem. Bit of an edge case which I unfortunately hit as a total newb to the DOF stack. 🤦🏻♂️ |
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.
I removed the entire section but it could also be #ifndef _WIN32
Claude's explanation:
On Linux/macOS, serial ports are real filesystem entries — /dev/ttyUSB0, /dev/cu.usbmodem1, etc. Opening one with std::ifstream is a cheap way to verify the device file actually exists before bothering to call sp_open.
On Windows, COM ports are not filesystem files. They live in the Windows device namespace. COM1–COM9 happen to work as legacy DOS device aliases, so std::ifstream("COM3") opens. COM10+ breaks because those aliases only cover single digits — std::ifstream("COM10") fails even when the port is perfectly real and connected. The correct way to open them is \.\COM10, which is exactly what libserialport's sp_open does internally.
So the original code (without #ifndef) would hit that ifstream check on Windows, fail on COM10, and return "" — making the port invisible to the auto-configurator.