Skip to content

Commit

Permalink
qextserialport update (improved device detection on Windows & OSX)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12732 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jan 11, 2010
1 parent 2d2ffda commit 6ec0217
Show file tree
Hide file tree
Showing 105 changed files with 23,954 additions and 2,972 deletions.
2 changes: 1 addition & 1 deletion scripts/prepare-commit.sh
Expand Up @@ -34,7 +34,7 @@ ASTYLEDIFF=astyle.r$REV.diff
# reformat
for f in $MODIFIED; do
case "$f" in
src/core/spatialite/*)
src/core/spatialite/*|src/core/gps/qextserialport/*)
echo $f skipped
continue
;;
Expand Down
91 changes: 3 additions & 88 deletions src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -17,7 +17,6 @@
/* $Id: qgisapp.h 12390 2009-12-09 21:35:43Z jef $ */
#include "qgsgpsinformationwidget.h"
#include "qgsvectorlayer.h"
#include "qextserialport.h"
#include "qgsnmeaconnection.h"
#include "qgsgpstrackerthread.h"
#include "qgscoordinatetransform.h"
Expand Down Expand Up @@ -308,13 +307,7 @@ void QgsGPSInformationWidget::connectGps()
{
if ( !mCboDevices->currentText().isEmpty() )
{
mSerialPort = new QextSerialPort( mCboDevices->currentText() );
mSerialPort->setBaudRate( BAUD4800 );
mSerialPort->setFlowControl( FLOW_OFF );
mSerialPort->setParity( PAR_NONE );
mSerialPort->setDataBits( DATA_8 );
mSerialPort->setStopBits( STOP_2 );
mNmea = new QgsNMEAConnection( mSerialPort, 500 );
mNmea = new QgsNMEAConnection( mCboDevices->currentText(), 500 );
QObject::connect( mNmea, SIGNAL( stateChanged( const QgsGPSInformation& ) ),
this, SLOT( displayGPSInformation( const QgsGPSInformation& ) ) );
mThread = new QgsGPSTrackerThread( mNmea );
Expand All @@ -329,7 +322,7 @@ void QgsGPSInformationWidget::connectGps()
mConnectButton->setChecked( false );
}
}
else //autdetect
else //autodetect
{
mNmea = QgsGPSConnection::detectGPSConnection();
if ( !mNmea )
Expand Down Expand Up @@ -861,86 +854,8 @@ void QgsGPSInformationWidget::on_mBtnRefreshDevices_clicked( )
/* Copied from gps plugin */
void QgsGPSInformationWidget::populateDevices()
{

mCboDevices->clear();
#ifdef linux
// look for linux serial devices
QString linuxDev( "/dev/ttyS%1" );
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
{
mCboDevices->addItem( linuxDev.arg( i ) );
}
else
break;
}

// and the ttyUSB* devices (serial USB adaptor)
linuxDev = "/dev/ttyUSB%1";
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
{
mCboDevices->addItem( linuxDev.arg( i ) );
}
else
break;
}

mCboDevices->addItem( "usb:" );
#endif

#ifdef __FreeBSD__ // freebsd
// and freebsd devices (untested)
QString freebsdDev( "/dev/cuaa%1" );
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
{
mCboDevices->addItem( freebsdDev.arg( i ) );
}
else
break;
}

// and the ucom devices (serial USB adaptors)
freebsdDev = "/dev/ucom%1";
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
{
mCboDevices->addItem( freebsdDev.arg( i ) );
}
else
break;
}

#endif

#ifdef sparc
// and solaris devices (also untested)
QString solarisDev( "/dev/cua/%1" );
for ( int i = 'a'; i < 'k'; ++i )
{
if ( QFileInfo( solarisDev.arg( char( i ) ) ).exists() )
{
mCboDevices->addItem( solarisDev.arg( char( i ) ) );
}
else
break;
}
#endif

#ifdef WIN32
mCboDevices->addItem( "com1" );
mCboDevices->addItem( "com2" );
mCboDevices->addItem( "com3" );
mCboDevices->addItem( "com4" );
mCboDevices->addItem( "usb:" );
#endif

// OSX, OpenBSD, NetBSD etc? Anyone?
mCboDevices->addItems( QgsGPSConnection::availablePorts() );

// remember the last ports used
QSettings settings;
Expand Down
30 changes: 22 additions & 8 deletions src/core/CMakeLists.txt
Expand Up @@ -5,8 +5,9 @@

SET(QGIS_CORE_SRCS

gps/qextserialport.cpp
gps/qextserialbase.cpp
gps/qextserialport/qextserialport.cpp
gps/qextserialport/qextserialenumerator.cpp

gps/qgsgpsconnection.cpp
gps/qgsgpsconnectionregistry.cpp
gps/qgsgpstrackerthread.cpp
Expand Down Expand Up @@ -144,15 +145,25 @@ SET(QGIS_CORE_SRCS
spatialindex/qgsspatialindex.cpp

)

IF(WIN32)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/win_qextserialport.cpp)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qextserialport/win_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_WIN_)
TARGET_LINK_LIBRARIES(qgis_core setupapi)
ELSE(WIN32)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/posix_qextserialport.cpp)
${QGIS_CORE_SRCS}
gps/qextserialport/posix_qextserialport.cpp
)
ADD_DEFINITIONS(-D_TTY_POSIX_)

IF(APPLE)
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
TARGET_LINK_LIBRARIES(qgis_core ${IOKIT_LIBRARY))
ENDIF(APPLE)
ENDIF(WIN32)
IF (WITH_INTERNAL_SPATIALITE)
Expand Down Expand Up @@ -233,6 +244,8 @@ composer/qgscomposition.h
composer/qgslegendmodel.h
gps/qgsgpsconnection.h
gps/qgsnmeaconnection.h
gps/qextserialport/qextserialenumerator.h
gps/qextserialport/qextserialport.h
symbology/qgsmarkercatalogue.h
raster/qgsrasterlayer.h
)
Expand All @@ -248,6 +261,7 @@ INCLUDE_DIRECTORIES(
symbology
spatialindex/include
symbology-ng
gps/qextserialport
${PROJ_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}
${GDAL_INCLUDE_DIR}
Expand Down

0 comments on commit 6ec0217

Please sign in to comment.