25 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 29 #include <QStringList> 32 #include <QSerialPortInfo> 36 QList< QPair<QString, QString> > devs;
39 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 40 devs << QPair<QString, QString>( QStringLiteral(
"internalGPS" ), tr(
"internal GPS" ) );
44 devs << QPair<QString, QString>( QStringLiteral(
"localhost:2947:" ), tr(
"local gpsd" ) );
46 for (
auto p : QSerialPortInfo::availablePorts() )
48 devs << QPair<QString, QString>( p.portName(), tr(
"%1: %2" ).arg( p.portName(), p.description() ) );
57 mBaudList << QSerialPort::Baud4800 << QSerialPort::Baud9600 << QSerialPort::Baud38400 << QSerialPort::Baud57600 << QSerialPort::Baud115200;
59 if ( portName.isEmpty() )
65 mPortList << QPair<QString, QString>( portName, portName );
86 if ( mBaudIndex == mBaudList.size() )
92 if ( mPortIndex == mPortList.size() )
99 if ( mPortList.at( mPortIndex ).first.contains(
':' ) )
101 mBaudIndex = mBaudList.size() - 1;
103 QStringList gpsParams = mPortList.at( mPortIndex ).first.split(
':' );
105 Q_ASSERT( gpsParams.size() >= 3 );
107 mConn =
new QgsGpsdConnection( gpsParams[0], gpsParams[1].toShort(), gpsParams[2] );
109 else if ( mPortList.at( mPortIndex ).first.contains( QLatin1String(
"internalGPS" ) ) )
111 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 114 qWarning(
"QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
119 QSerialPort *serial =
new QSerialPort( mPortList.at( mPortIndex ).first );
121 serial->setBaudRate( mBaudList[ mBaudIndex ] );
122 serial->setFlowControl( QSerialPort::NoFlowControl );
123 serial->setParity( QSerialPort::NoParity );
124 serial->setDataBits( QSerialPort::Data8 );
125 serial->setStopBits( QSerialPort::OneStop );
127 if ( serial->open( QIODevice::ReadOnly ) )
Evaluates NMEA sentences coming from gpsd.
Class to detect the GPS port.
void detected(const QgsGpsInformation &)
~QgsGpsDetector() override
void connDestroyed(QObject *)
void stateChanged(const QgsGpsInformation &info)
Evaluates NMEA sentences coming from a GPS device.
static QList< QPair< QString, QString > > availablePorts()
QgsGpsDetector(const QString &portName)
Abstract base class for connection to a GPS device.
Status status() const
Returns the status. Possible state are not connected, connected, data received.