19 #include "qextserialenumerator.h" 25 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 29 #include <QStringList> 38 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 39 devs << QPair<QString, QString>(
"internalGPS",
tr(
"internal GPS" ) );
43 devs << QPair<QString, QString>(
"localhost:2947:",
tr(
"local gpsd" ) );
47 Q_FOREACH (
const QString& linuxDev,
QStringList() <<
"/dev/ttyS%1" <<
"/dev/ttyUSB%1" <<
"/dev/rfcomm%1" <<
"/dev/ttyACM%1" )
49 for (
int i = 0; i < 10; ++i )
53 devs << QPair<QString, QString>( linuxDev.
arg( i ), linuxDev.
arg( i ) );
61 Q_FOREACH (
const QString& freebsdDev,
QStringList() <<
"/dev/cuaa%1" <<
"/dev/ucom%1" )
63 for (
int i = 0; i < 10; ++i )
67 devs << QPair<QString, QString>( freebsdDev.
arg( i ), freebsdDev.
arg( i ) );
75 QString solarisDev(
"/dev/cua/%1" );
76 for (
char i =
'a'; i <
'k'; ++i )
78 if (
QFileInfo( solarisDev.arg( i ) ).exists() )
80 devs << QPair<QString, QString>( solarisDev.arg( i ), solarisDev.arg( i ) );
85 #if defined(Q_OS_WIN) || defined(Q_OS_MAC) 87 Q_FOREACH ( QextPortInfo port, ports )
89 devs << QPair<QString, QString>( port.portName, port.friendName );
101 mBaudList << BAUD4800 << BAUD9600 << BAUD38400 << BAUD57600 << BAUD115200;
109 mPortList << QPair<QString, QString>( portName, portName );
134 if ( mBaudIndex == mBaudList.
size() )
140 if ( mPortIndex == mPortList.
size() )
147 if ( mPortList.
at( mPortIndex ).first.contains(
':' ) )
149 mBaudIndex = mBaudList.
size() - 1;
151 QStringList gpsParams = mPortList.
at( mPortIndex ).first.split(
':' );
153 Q_ASSERT( gpsParams.
size() >= 3 );
155 mConn =
new QgsGpsdConnection( gpsParams[0], gpsParams[1].toShort(), gpsParams[2] );
157 else if ( mPortList.
at( mPortIndex ).first.contains(
"internalGPS" ) )
159 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB) 162 qWarning(
"QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
167 QextSerialPort *serial =
new QextSerialPort( mPortList.
at( mPortIndex ).first, QextSerialPort::EventDriven );
169 serial->setBaudRate( mBaudList[ mBaudIndex ] );
170 serial->setFlowControl( FLOW_OFF );
171 serial->setParity( PAR_NONE );
172 serial->setDataBits( DATA_8 );
173 serial->setStopBits( STOP_1 );
175 if ( serial->open( QIODevice::ReadOnly | QIODevice::Unbuffered ) )
Evaluates NMEA sentences coming from gpsd.
const T & at(int i) const
QString tr(const char *sourceText, const char *disambiguation, int n)
Abstract base class for connection to a GPS device.
QgsGPSDetector(const QString &portName)
Evaluates NMEA sentences coming from a GPS device.
void connDestroyed(QObject *)
void detected(const QgsGPSInformation &)
static QList< QPair< QString, QString > > availablePorts()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Status status() const
Returns the status.
void destroyed(QObject *obj)