Conversation
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.