Skip to content

Commit

Permalink
fix com port detection on windows
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14339 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 5, 2010
1 parent 1db228c commit 5b4d73e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -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 );
}
Expand Down
20 changes: 20 additions & 0 deletions src/core/gps/qextserialport/qextserialenumerator.cpp
Expand Up @@ -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 )
Expand Down

0 comments on commit 5b4d73e

Please sign in to comment.