-
Notifications
You must be signed in to change notification settings - Fork 2
Add Virtual COM port support on Windows #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 updates the Windows COM port enumeration approach by switching from device class enumeration to device interface enumeration. This change aims to provide more accurate and reliable COM port detection on Windows systems.
- Switches from
GUID_DEVCLASS_PORTStoGUID_DEVINTERFACE_COMPORTfor more specific COM port targeting - Adds
DIGCF_DEVICEINTERFACEflag to enable device interface enumeration mode
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| HDEVINFO device_info_set = SetupDiGetClassDevs( | ||
| (const GUID *) &GUID_DEVCLASS_PORTS, | ||
| (const GUID *) &GUID_DEVINTERFACE_COMPORT, | ||
| NULL, | ||
| NULL, | ||
| DIGCF_PRESENT); | ||
| DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using DIGCF_DEVICEINTERFACE flag with SetupDiGetClassDevs, the subsequent enumeration should use SetupDiEnumDeviceInterfaces instead of SetupDiEnumDeviceInfo (line 51). The current code at line 51 calls SetupDiEnumDeviceInfo which is designed for device class enumeration, not device interface enumeration. This mismatch may cause the function to miss COM ports or behave incorrectly. Consider either: (1) keeping the original GUID_DEVCLASS_PORTS without DIGCF_DEVICEINTERFACE, or (2) refactoring the enumeration logic to use SetupDiEnumDeviceInterfaces followed by SetupDiGetDeviceInterfaceDetail.
|
@davidegorbani @Gianlucamilani @marcoforleo do you think you can test this somehow in one of our Windows use of the serial_cpp library to ensure that there are no regressions? Thanks! |
Friendly ping @davidegorbani @Gianlucamilani @LudovicaDanovaro @camillagallina2000 fyi @ttsesm @gbionics/team-1 |
Fixes wjwwood/serial#202
I changed the
ClassGuidtoGUID_DEVINTERFACE_COMPORTas suggested in the issue which resolved the problem, I'm now able to see my virtual COM ports. I wasn't able to test this with physical COM ports, since my machine doesn't have any.