0

我需要确定调制解调器 com 端口的数量。调制解调器是 USB 设备。

为了做到这一点,我需要

  1. 检测连接的调制解调器

    GUID usbGuid = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } };
    HDEVINFO hDevInfo = SetupDiGetClassDevs(&usbGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
    
    SP_DEVINFO_DATA DeviceInfoData;
    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    DWORD i;
    
    for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData); i++)
    {
        //detect by vendorId
    }
    

2.对于附加的调制解调器,列出它模拟的所有 com 端口。但是如何访问有关子设备和相关通信端口号的信息。下面来自 USB 树视图的日志,其中包含有关我需要的 com 端口的信息。

    +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : Composite USB device
Device Path              : \\?\usb#vid_1199&pid_68c0#6&24e4eadd&0&4#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
...
Power State              : D0 (supported: D0, D1, D2, D3, wake from D0, wake from D1, wake from D2)
 Child Device 1          : Sierra Wireless NMEA Port
  Device ID              : USB\VID_1199&PID_68C0&MI_02\7&2BC75400&0&0002
  Class                  : Ports
  COM-Port               : COM19 (\Device\QCUSB_COM19_2)
 Child Device 2          : Sierra Wireless Mobile Broadband Network Adapter
  Device ID              : USB\VID_1199&PID_68C0&MI_0A\7&2BC75400&0&000A
  Class                  : Net
 Child Device 3          : Sierra Wireless WWAN Modem
  Device ID              : USB\VID_1199&PID_68C0&MI_03\7&2BC75400&0&0003
  Class                  : Modem
  COM-Port               : COM18 (\Device\QCUSB_COM18_3)
 Child Device 4          : Sierra Wireless Mobile Broadband Network Adapter
  Device ID              : USB\VID_1199&PID_68C0&MI_08\7&2BC75400&0&0008
  Class                  : Net
 Child Device 5          : Sierra Wireless Mobile Broadband Network Adapter
  Device ID              : USB\VID_1199&PID_68C0&MI_0B\7&2BC75400&0&000B
  Class                  : Net
 Child Device 6          : Sierra Wireless DM Port
  Device ID              : USB\VID_1199&PID_68C0&MI_00\7&2BC75400&0&0000
  Class                  : Ports
  COM-Port               : COM17 (\Device\QCUSB_COM17_1)
4

0 回答 0