Skip to content
Permalink
Browse files

fix com port detection on windows

git-svn-id: http://svn.osgeo.org/qgis/trunk@14339 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Oct 5, 2010
1 parent 50bdfb3 commit 9f79f6f1cc579321e06b23d41e50a16cad1cd178
Showing with 23 additions and 1 deletion.
  1. +3 −1 src/app/gps/qgsgpsinformationwidget.cpp
  2. +20 −0 src/core/gps/qextserialport/qextserialenumerator.cpp
@@ -889,7 +889,9 @@ void QgsGPSInformationWidget::populateDevices()
QList< QPair<QString, QString> > ports = QgsGPSDetector::availablePorts();

mCboDevices->clear();
for ( int i = 0; i < ports.size(); i++ )

// add devices to combobox, but skip gpsd which is first.
for ( int i = 1; i < ports.size(); i++ )
{
mCboDevices->addItem( ports[i].second, ports[i].first );
}
@@ -85,7 +85,27 @@ QextSerialEnumerator::~QextSerialEnumerator( )
//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
}

void QextSerialEnumerator::enumerateDevicesWin( const GUID & guid, QList<QextPortInfo>* infoList )

0 comments on commit 9f79f6f

Please sign in to comment.
You can’t perform that action at this time.