Skip to content

Conversation

@M4rFri
Copy link

@M4rFri M4rFri commented Nov 10, 2025

Fixes wjwwood/serial#202
I changed the ClassGuid to GUID_DEVINTERFACE_COMPORT as 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.

@traversaro traversaro requested a review from Copilot November 10, 2025 16:01
Copy link

Copilot AI left a 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_PORTS to GUID_DEVINTERFACE_COMPORT for more specific COM port targeting
  • Adds DIGCF_DEVICEINTERFACE flag to enable device interface enumeration mode

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 40 to +44
HDEVINFO device_info_set = SetupDiGetClassDevs(
(const GUID *) &GUID_DEVCLASS_PORTS,
(const GUID *) &GUID_DEVINTERFACE_COMPORT,
NULL,
NULL,
DIGCF_PRESENT);
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
Copy link

Copilot AI Nov 10, 2025

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.

Copilot uses AI. Check for mistakes.
@traversaro
Copy link
Contributor

@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!

@traversaro traversaro changed the title Virtual COM port support Add Virtual COM port support on Windows Nov 14, 2025
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.

Not detecting all serial ports on Windows

2 participants