LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Blogs > 55020
User Name
Password

Notices



Rate this Entry

SlackBuild for gpsd

Posted 06-14-2011 at 03:25 PM by 55020
Updated 06-15-2011 at 03:39 PM by 55020 (URL fixed)

There's recently been a long running thread in which xj25vm has explored the possibilities of getting gpsd to start on demand in Slackware, both when USB GPS devices are hotplugged (plugged into an already booted system) and when coldplugged (discovered by the system at boot).

The core difficulty to be overcome was that the gpsd daemon wants to read from a control socket which is created on the fly by a helper when the hotplugged or coldplugged device triggers an action in udev. Unfortunately, during coldplug on Slackware, the root filesystem is mounted read-only, and therefore the socket can't be created, and therefore the action terminates without starting gpsd. Symlinks of the form /dev/gps<n> are successfully created, but gpsd isn't started.

The solution that has been adopted is to have a conventional boot script, /etc/rc.d/rc.gpsd, which runs at a later stage of booting (in the usual manner). The boot script will detect if any symlinks were created earlier, and therefore start gpsd. As usual with packages built from SBo SlackBuilds, the boot script is not enabled by default. To enable it, add a couple of lines to rc.local and set execute permission on rc.gpsd, as described in the README.

Complicating this whole picture is the sad reality that USB GPS devices are indistinguishable by udev from any other serial device. The best recommendation to prevent udev from starting gpsd when other devices are plugged in is to enable only the udev rules that belong to the USB id that your own GPS device actually has. (Plug your device in and use 'lsusb' to see what the USB id actually is.) The new SlackBuild will ship with all the udev rules commented out, and you will be expected to uncomment only the rule or rules that apply to your GPS hardware. If you don't want gpsd to be started on demand, just leave those rules commented out.

Another complicating factor is the necessity of having a few configurable settings. The hotplug scripts that come from upstream know about Debian-style configuration (in /etc/default) and Red Hat style configuration (in /etc/sysconfig). However, neither of these are really satisfactory for Slackware. Either location would contravene the principle of minimum surprise, and some of the variables in those files are unintuitive or duplicative. So the new SlackBuild will ship a minimal configuration file at /etc/rc.d/rc.gpsd.conf. The only reasons to make any changes to this file are

(1) To add options to the gpsd command line. The most likely option that you might want is -b ("broken-device-safety mode", to work round limitations of certain bluetooth and other GPSes). You can specify this in the variable GPSD_OPTIONS.

(2) There will be some people who use GPSes connected to proper serial ports. The recommended approach would be to add /dev/ttyS0 (or ttyS1, or ttyS2 or whatever) to the option GPSD_DEVICES. This is preferable to creating your own permanent /dev/gps<n> symlink, because potentially it would clash with a USB GPS that was allocated /dev/ttyUSB<n> by udev.

The new SlackBuild is being targetted for use with gpsd-3.0, which is currently in development and available through the gpsd git repository. This has been a source of much grief in itself, because the build system has moved to scons, and there are a number of build-related bugs for which I'll be having to send patches upstream. In the meanwhile, these patches are incorporated in the new SlackBuild.

The new SlackBuild and associated files are available in my Github repository. Please remember that both the SlackBuild and the upstream git code is experimental. Feedback is welcome; just leave a comment here.

Thanks to xj25vm for multiple suggestions, corrections and encouragement!
Posted in Uncategorized
Views 552 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 11:44 AM.

Main Menu
Advertisement

Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration