25 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 29 #include <QStringList> 33 #if defined( HAVE_QT5SERIALPORT ) 34 #include <QSerialPortInfo> 35 #include <QSerialPort> 40 QList< QPair<QString, QString> > devs;
43 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 44 devs << QPair<QString, QString>( QStringLiteral(
"internalGPS" ), tr(
"internal GPS" ) );
48 devs << QPair<QString, QString>( QStringLiteral(
"localhost:2947:" ), tr(
"local gpsd" ) );
51 #if defined( HAVE_QT5SERIALPORT ) 52 for (
auto p : QSerialPortInfo::availablePorts() )
54 devs << QPair<QString, QString>( p.portName(), tr(
"%1: %2" ).arg( p.portName(), p.description() ) );
65 #if defined( HAVE_QT5SERIALPORT ) 66 mBaudList << QSerialPort::Baud4800 << QSerialPort::Baud9600 << QSerialPort::Baud38400 << QSerialPort::Baud57600 << QSerialPort::Baud115200;
69 if ( portName.isEmpty() )
75 mPortList << QPair<QString, QString>( portName, portName );
96 if ( mBaudIndex == mBaudList.size() )
102 if ( mPortIndex == mPortList.size() )
109 if ( mPortList.at( mPortIndex ).first.contains(
':' ) )
111 mBaudIndex = mBaudList.size() - 1;
113 QStringList gpsParams = mPortList.at( mPortIndex ).first.split(
':' );
115 Q_ASSERT( gpsParams.size() >= 3 );
117 mConn =
new QgsGpsdConnection( gpsParams[0], gpsParams[1].toShort(), gpsParams[2] );
119 else if ( mPortList.at( mPortIndex ).first.contains( QLatin1String(
"internalGPS" ) ) )
121 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 124 qWarning(
"QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
129 #if defined( HAVE_QT5SERIALPORT ) 130 QSerialPort *serial =
new QSerialPort( mPortList.at( mPortIndex ).first );
132 serial->setBaudRate( mBaudList[ mBaudIndex ] );
133 serial->setFlowControl( QSerialPort::NoFlowControl );
134 serial->setParity( QSerialPort::NoParity );
135 serial->setDataBits( QSerialPort::Data8 );
136 serial->setStopBits( QSerialPort::OneStop );
138 if ( serial->open( QIODevice::ReadOnly ) )
147 qWarning(
"QT5SERIALPORT not found and mPortList matches serial port, this should never happen" );
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.
Status status() const
Returns the status. Possible state are not connected, connected, data received.
static QList< QPair< QString, QString > > availablePorts()
QgsGpsDetector(const QString &portName)
Abstract base class for connection to a GPS device.