Skip to content

Fix for ports higher than com9 not being properly auto-detected for pinone#51

Merged
jsm174 merged 1 commit intovpinball:masterfrom
dejaloomer:com10_fix
May 5, 2026
Merged

Fix for ports higher than com9 not being properly auto-detected for pinone#51
jsm174 merged 1 commit intovpinball:masterfrom
dejaloomer:com10_fix

Conversation

@dejaloomer
Copy link
Copy Markdown
Contributor

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.

…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
Copy link
Copy Markdown
Collaborator

jsm174 commented May 5, 2026

Thanks for this!

@jsm174 jsm174 merged commit c02135e into vpinball:master May 5, 2026
12 checks passed
@dejaloomer
Copy link
Copy Markdown
Contributor Author

No problem. Bit of an edge case which I unfortunately hit as a total newb to the DOF stack. 🤦🏻‍♂️

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.

2 participants