[PATCH] NeoGpsPlugin - use "gpspipe -r" instead of "cat /dev/ttyO1".

Neil Jerram neil at ossau.homelinux.net
Mon Oct 1 00:35:15 CEST 2012


This allows us to have multiple GPS clients at the same time.
Specifically, to have NeronGPS running on the GTA04, and also using
gpspipe to export the GPS NMEA stream over Bluetooth.

(An alternative approach is to use QGpsdWhereabouts instead of
NeoGpsPlugin, but this doesn't work because the QGpsdWhereabouts code
assumes the old GPSD protocol which has now been replaced by JSON.  To
use QGpsdWhereabouts successfully, that code would need updating for
the new protocol, probably by using libgps.

Using "gpspipe -r" at the bottom of NeoGpsPlugin should be equally
effective, and doesn't require such a complex code change.)
---
 .../src/plugins/whereabouts/neo/neogpsplugin.cpp   |   21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/devices/gta04/src/plugins/whereabouts/neo/neogpsplugin.cpp b/devices/gta04/src/plugins/whereabouts/neo/neogpsplugin.cpp
index 7737c17..f6e55fc 100644
--- a/devices/gta04/src/plugins/whereabouts/neo/neogpsplugin.cpp
+++ b/devices/gta04/src/plugins/whereabouts/neo/neogpsplugin.cpp
@@ -31,7 +31,20 @@
 #include <qtopialog.h>
 
 /*
- This plugin only works for Goldelico's GTA04
+  This plugin uses "gpspipe -r" to get NMEA sentences out of GPSD,
+  then feeds those to QNmeaWhereabouts.  It should work on any
+  distribution where GPSD is running and successfully accessing the
+  GPS device. 
+
+  The benefit of using GPSD, instead of reading the GPS device
+  directly, is that multiple clients can access GPS information at the
+  same time.  For example, GPS can be simultaneously used by a local
+  application such as NeronGPS, and exported over Bluetooth to another
+  device.
+
+  An alternative GPSD-based solution would be to use QGpsdWhereabouts
+  instead of QNmeaWhereabouts, but that would require updating
+  QGpsdWhereabouts for GPSD's new JSON-based protocol.
 */
 NeoGpsPlugin::NeoGpsPlugin(QObject * parent)
 :  QWhereaboutsPlugin(parent)
@@ -56,12 +69,12 @@ QWhereabouts *NeoGpsPlugin::create(const QString &)
     qLog(Hardware) << __PRETTY_FUNCTION__;
 
     reader = new QProcess(this);
-    reader->start("cat", QStringList() << "/dev/ttyO1", QIODevice::ReadWrite);
+    reader->start("gpspipe", QStringList() << "-r", QIODevice::ReadWrite);
 
     if (!reader->waitForStarted()) {
-        qWarning() << "couldnt start cat /dev/ttyO1: " + reader->errorString();
+        qWarning() << "Couldn't start gpspipe -r: " + reader->errorString();
         QMessageBox::warning(0, tr("GPS"),
-                             tr("Cannot open GPS device at /dev/ttyO1"),
+                             tr("Couldn't start gpspipe -r"),
                              QMessageBox::Ok, QMessageBox::Ok);
         delete reader;
         reader = 0;
-- 
1.7.10.4


--=-=-=


I don't think this patch is ready for inclusion yet, because it would be
better if it handled both gpsd usage and direct access gracefully -
i.e. try using gpspipe, and fall back to opening /dev/ttyO1 if that
fails.  But it would be interesting to hear if people think this is the
right longterm approach.

Regards,
        Neil

--=-=-=--



More information about the community mailing list