Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.13.2
-
None
Description
gpsd is a widespread daemon that provides a mechanism to interact with a GPS device from a program. Although gpsd suffers from a few issues, it can be convenient to use it from a QML program.
The PositionSource QML component has an nmeasource property that allows specifying a file or a socket as a source of NMEA position data to use as the position source. The nmeasource property takes a URL. If the URL scheme is socket, it will establish a socket to the hostname and port specified in the URL (e.g. nmeasource: "socket://hostname:port"). Setting the property to connect to a gpsd-provided socket, however, does not work because gpsd only starts sending data when asked to do so by writing a cryptic command on the socket.
A solution to this would be to support a new gpsd scheme for the nmeasource property that would open a read-write socket and would issue the gpsd initiation command to it right after opening it, and then listen for the incoming NMEA data. For example, a gpsd socket could be specified as follows: nmeasource: "gpsd://hostname:port"
This could be achieved very simply by modifying the QDeclarativePositionSource::setNmeaSource method to recognize the gpsd scheme, which would cause it to open the socket as read-write instead of the current read-only and issue the gpsd command to initiate the NMEA data stream.
The gpsd stream could also be stopped/started based on the active property of the PositionSource component.
I posted a workaround to this limitation that requires no code change and a crude but working implementation of this proposed change here: https://stackoverflow.com/questions/59482703/getting-positions-from-gpsd-in-a-qt-quick-program
I would be happy to contribute the code to do this more cleanly but would welcome comments and suggestions.