Skip to content

Commit 6ec0217

Browse files
author
jef
committed
qextserialport update (improved device detection on Windows & OSX)
git-svn-id: http://svn.osgeo.org/qgis/trunk@12732 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 2d2ffda commit 6ec0217

File tree

105 files changed

+23954
-2972
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+23954
-2972
lines changed

scripts/prepare-commit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ASTYLEDIFF=astyle.r$REV.diff
3434
# reformat
3535
for f in $MODIFIED; do
3636
case "$f" in
37-
src/core/spatialite/*)
37+
src/core/spatialite/*|src/core/gps/qextserialport/*)
3838
echo $f skipped
3939
continue
4040
;;

src/app/gps/qgsgpsinformationwidget.cpp

+3-88
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
/* $Id: qgisapp.h 12390 2009-12-09 21:35:43Z jef $ */
1818
#include "qgsgpsinformationwidget.h"
1919
#include "qgsvectorlayer.h"
20-
#include "qextserialport.h"
2120
#include "qgsnmeaconnection.h"
2221
#include "qgsgpstrackerthread.h"
2322
#include "qgscoordinatetransform.h"
@@ -308,13 +307,7 @@ void QgsGPSInformationWidget::connectGps()
308307
{
309308
if ( !mCboDevices->currentText().isEmpty() )
310309
{
311-
mSerialPort = new QextSerialPort( mCboDevices->currentText() );
312-
mSerialPort->setBaudRate( BAUD4800 );
313-
mSerialPort->setFlowControl( FLOW_OFF );
314-
mSerialPort->setParity( PAR_NONE );
315-
mSerialPort->setDataBits( DATA_8 );
316-
mSerialPort->setStopBits( STOP_2 );
317-
mNmea = new QgsNMEAConnection( mSerialPort, 500 );
310+
mNmea = new QgsNMEAConnection( mCboDevices->currentText(), 500 );
318311
QObject::connect( mNmea, SIGNAL( stateChanged( const QgsGPSInformation& ) ),
319312
this, SLOT( displayGPSInformation( const QgsGPSInformation& ) ) );
320313
mThread = new QgsGPSTrackerThread( mNmea );
@@ -329,7 +322,7 @@ void QgsGPSInformationWidget::connectGps()
329322
mConnectButton->setChecked( false );
330323
}
331324
}
332-
else //autdetect
325+
else //autodetect
333326
{
334327
mNmea = QgsGPSConnection::detectGPSConnection();
335328
if ( !mNmea )
@@ -861,86 +854,8 @@ void QgsGPSInformationWidget::on_mBtnRefreshDevices_clicked( )
861854
/* Copied from gps plugin */
862855
void QgsGPSInformationWidget::populateDevices()
863856
{
864-
865857
mCboDevices->clear();
866-
#ifdef linux
867-
// look for linux serial devices
868-
QString linuxDev( "/dev/ttyS%1" );
869-
for ( int i = 0; i < 10; ++i )
870-
{
871-
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
872-
{
873-
mCboDevices->addItem( linuxDev.arg( i ) );
874-
}
875-
else
876-
break;
877-
}
878-
879-
// and the ttyUSB* devices (serial USB adaptor)
880-
linuxDev = "/dev/ttyUSB%1";
881-
for ( int i = 0; i < 10; ++i )
882-
{
883-
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
884-
{
885-
mCboDevices->addItem( linuxDev.arg( i ) );
886-
}
887-
else
888-
break;
889-
}
890-
891-
mCboDevices->addItem( "usb:" );
892-
#endif
893-
894-
#ifdef __FreeBSD__ // freebsd
895-
// and freebsd devices (untested)
896-
QString freebsdDev( "/dev/cuaa%1" );
897-
for ( int i = 0; i < 10; ++i )
898-
{
899-
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
900-
{
901-
mCboDevices->addItem( freebsdDev.arg( i ) );
902-
}
903-
else
904-
break;
905-
}
906-
907-
// and the ucom devices (serial USB adaptors)
908-
freebsdDev = "/dev/ucom%1";
909-
for ( int i = 0; i < 10; ++i )
910-
{
911-
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
912-
{
913-
mCboDevices->addItem( freebsdDev.arg( i ) );
914-
}
915-
else
916-
break;
917-
}
918-
919-
#endif
920-
921-
#ifdef sparc
922-
// and solaris devices (also untested)
923-
QString solarisDev( "/dev/cua/%1" );
924-
for ( int i = 'a'; i < 'k'; ++i )
925-
{
926-
if ( QFileInfo( solarisDev.arg( char( i ) ) ).exists() )
927-
{
928-
mCboDevices->addItem( solarisDev.arg( char( i ) ) );
929-
}
930-
else
931-
break;
932-
}
933-
#endif
934-
935-
#ifdef WIN32
936-
mCboDevices->addItem( "com1" );
937-
mCboDevices->addItem( "com2" );
938-
mCboDevices->addItem( "com3" );
939-
mCboDevices->addItem( "com4" );
940-
mCboDevices->addItem( "usb:" );
941-
#endif
942-
943-
// OSX, OpenBSD, NetBSD etc? Anyone?
858+
mCboDevices->addItems( QgsGPSConnection::availablePorts() );
944859

945860
// remember the last ports used
946861
QSettings settings;

src/core/CMakeLists.txt

+22-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
SET(QGIS_CORE_SRCS
77

8-
gps/qextserialport.cpp
9-
gps/qextserialbase.cpp
8+
gps/qextserialport/qextserialport.cpp
9+
gps/qextserialport/qextserialenumerator.cpp
10+
1011
gps/qgsgpsconnection.cpp
1112
gps/qgsgpsconnectionregistry.cpp
1213
gps/qgsgpstrackerthread.cpp
@@ -144,15 +145,25 @@ SET(QGIS_CORE_SRCS
144145
spatialindex/qgsspatialindex.cpp
145146

146147
)
147-
148+
148149
IF(WIN32)
149-
SET(QGIS_CORE_SRCS
150-
${QGIS_CORE_SRCS}
151-
gps/win_qextserialport.cpp)
150+
SET(QGIS_CORE_SRCS
151+
${QGIS_CORE_SRCS}
152+
gps/qextserialport/win_qextserialport.cpp
153+
)
154+
ADD_DEFINITIONS(-D_TTY_WIN_)
155+
TARGET_LINK_LIBRARIES(qgis_core setupapi)
152156
ELSE(WIN32)
153157
SET(QGIS_CORE_SRCS
154-
${QGIS_CORE_SRCS}
155-
gps/posix_qextserialport.cpp)
158+
${QGIS_CORE_SRCS}
159+
gps/qextserialport/posix_qextserialport.cpp
160+
)
161+
ADD_DEFINITIONS(-D_TTY_POSIX_)
162+
163+
IF(APPLE)
164+
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
165+
TARGET_LINK_LIBRARIES(qgis_core ${IOKIT_LIBRARY))
166+
ENDIF(APPLE)
156167
ENDIF(WIN32)
157168

158169
IF (WITH_INTERNAL_SPATIALITE)
@@ -233,6 +244,8 @@ composer/qgscomposition.h
233244
composer/qgslegendmodel.h
234245
gps/qgsgpsconnection.h
235246
gps/qgsnmeaconnection.h
247+
gps/qextserialport/qextserialenumerator.h
248+
gps/qextserialport/qextserialport.h
236249
symbology/qgsmarkercatalogue.h
237250
raster/qgsrasterlayer.h
238251
)
@@ -248,6 +261,7 @@ INCLUDE_DIRECTORIES(
248261
symbology
249262
spatialindex/include
250263
symbology-ng
264+
gps/qextserialport
251265
${PROJ_INCLUDE_DIR}
252266
${GEOS_INCLUDE_DIR}
253267
${GDAL_INCLUDE_DIR}

0 commit comments

Comments
 (0)