/*! Get list of ports. return list of ports currently available in the system. */ QList<QextPortInfo> QextSerialEnumeratorPrivate::getPorts_sys() { QList<QextPortInfo> ports; enumerateDevicesWin(GUID_DEVCLASS_PORTS, &ports); enumerateDevicesWin(GUID_DEVCLASS_VIRTUAL_PORTS, &ports); qSort(ports.begin(), ports.end(), lessThan); return ports; }
QList<QUsbHidInfo> QUsbHidEnumerator::getPorts(unsigned short vid, unsigned short pid) { QList<QUsbHidInfo> ports; GUID guid; HidD_GetHidGuid(&guid); enumerateDevicesWin(guid, &ports,vid, pid); return ports; }
//static void QextSerialEnumerator::setupAPIScan(QList<QextPortInfo> & infoList) { HDEVINFO devInfo = SetupDiGetClassDevs(&GUID_DEVCLASS_PORTS, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if(devInfo == INVALID_HANDLE_VALUE) { qCritical() << "SetupDiGetClassDevs failed:" << GetLastError(); return; } enumerateDevicesWin( devInfo, &GUID_DEVCLASS_PORTS, &infoList ); }
//static void QextSerialEnumerator::setupAPIScan(QList<QextPortInfo> & infoList) { #if 0 enumerateDevicesWin(GUID_DEVCLASS_PORTS, &infoList); #else // just iterate the com ports. // looks like GUID_DEVCLASS_PORTS doesn't find them all. for( unsigned int i = 0 ; i < 256; i++ ) { QString port = "\\\\.\\COM" + QString::number(i); HANDLE hPort = ::CreateFile(port.toAscii(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); if( hPort == INVALID_HANDLE_VALUE ) continue; QextPortInfo info; info.friendName = QString("COM%1:").arg( i ); info.portName = port; infoList.append(info); CloseHandle( hPort ); } #endif }
QList<QextPortInfo> QextSerialEnumerator::getPorts() { QList<QextPortInfo> ports; enumerateDevicesWin(GUID_DEVCLASS_PORTS, &ports); return ports; }