[Merkaartor] Refactoring GPS/ directory

bvh bvh-osm at irule.be
Sun Sep 7 17:01:21 BST 2008


On Sun, Sep 07, 2008 at 04:51:26PM +0200, Chris Browet wrote:
> > Great. Do you think it is possible to remove the polling for stopLoop
> > inside QGPSComDevice? Since this part is mostly going to be used for
> > mobile devices, waking up every 100ms is really penalizing if it is not
> > needed (GPS changes normally only come every 1s). I used the thread
> > event loop in QGPSSDDevice it works quite well.
> Mmm.. I don't follow you... What polling on stopLoop? You mean the check of
> the variable? Where does the 100ms you speak about come from?

The run method of QGPSComDevice is a huge do-while loop that basically
never goes to sleep. It is constantly polling for either a change of
stopLoop or data available on the serial io-device.

As a consequence the thread is constantly 'active' using resources like
CPU time and consequently battery power. It is better to set up signals
that will wake up your event loop on serial data available (readyRead
signal on a QIODevice). Then you can have the run method enter the
thread eventloop with exec(). Qt will be smart and put the thread to
sleep and will get a kernel signal when there is something to read on
the serial port filedescriptor.

The 100ms is my mistake, that one is in the file-replay gpsdevice.

> > The only tricky part is
> > to make sure that the slots are really executed in the GPS-thread and
> > not inside the main program. If you want I can take a shot at it, but I
> > would probably break the serial port parsing since I don' t have a
> > device to test that.
> I thought that all GPSes exposed a serial interface, even the internal
> ones... How do you communicate with yours?

Not all GPS'es use RS-232 as the datatransport layer. For example
bluetooth gps-es obviously use bluetooth.

gpsd is basically a server that abstracts devices away and presents a
simple standard protocol as a tcp-server. See the code at the end of
qgpsdevice.h on how to interface with it (very simple just telnet to the
right address/port and after sending w+1 you get continuous updates)
See for more information http://gpsd.berlios.de/

> Anway, AFAIK, serial is the only way to access the GPS on WinCE and Win32 in
> general. So you definitely should try to avoid breaking it ;-)

gpsd is certainly something unix-y. And yes, we most definitly want to
keep serial port access working :) Please verify that I didn't already
break something inadvertently! I could easily have! BTW. Can you send me a
gps-replay file so that at least I can keep checking that part?

cu bart




More information about the Merkaartor mailing list