Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#18934 - [gpsd] udev autostart & device notification

Attached to Project: Community Packages
Opened by orbisvicis (orbisvicis) - Friday, 02 April 2010, 18:25 GMT
Last edited by Sergej Pupykin (sergej) - Tuesday, 13 April 2010, 19:02 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sergej Pupykin (sergej)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
When a gps dongle is hotplugged gpsd is not autostarted. If gpsd is already running and accepting commands on the correct socket, gpsd is notified devices that have been added. However gpsd does not receive "device removed" notifications.

Problem #1
In "/etc/udev/rules.d/99-gpsd-usb.rules" the two udev rules for the first device are commented out and disabled. I don't see any reason for this. "Bus 004 Device 010: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port" is a common usb<->serial interface used by many - mainly SiRF - gps products. Since all gps usb dongles use usb<->serial interfaces that could possibly be found in non-gps products, rules should not be commented out on the off chance of triggering false-negatives.

Problem #2
Once the udev rules are fixed, the "/etc/hotplug/usb/gpsd" script is triggered. However, this fails to autostart gpsd if it is not already running, and furthermore fails to notify gpsd of removed devices.
- Calling "/etc/hotplug/usb/gpsd" from bash works as expected. Running "sudo /etc/hotplug/usb/gpsd add /dev/ttyUSB0" will start gpsd if not running and notify gpsd of a new device. Running "sudo /etc/hotplug/usb/gpsd remove /dev/ttyUSB0" will tell gpsd to remove the device from the list. Therefore if the "/etc/hotplug/usb/gpsd" script is in error (I doubt it) the problem must lie with the hotplug(action, devpath) function.

I assume udev succesfully calls "/etc/hotplug/usb/gpsd" because gpsd logs
- gpsd: <= control(6): adding /dev/ttyUSB0
- gpsd: stashing device /dev/ttyUSB0 at slot 0
When the dongle has been hotplugged.

However, I can't ascertain that the script is also called on "remove" events. "udevadm monitor --property" records four kernel and four udev events for each connect/disconnect of the gps device. On either remove/add one event is in the tty subsystem, so the script *should* be triggered, but neither dmesg or udevadm list futher details.

So, summary: I don't know why notification doesn't always work, or how to find out, but I would be happy to help.


Additional info:
* package version(s)
community/gpsd 2.92-1
This task depends upon

Closed by  Sergej Pupykin (sergej)
Tuesday, 13 April 2010, 19:02 GMT
Reason for closing:  Fixed
Additional comments about closing:  thanks, I used attached files.
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 02:11 GMT
The attached files do not fix this problem, but should help out in general
   PKGBUILD (2.1 KiB)
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 02:14 GMT
... and the rest
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 02:32 GMT
oops
   gpsd (0.7 KiB)
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 02:35 GMT
So now the add/remove events are consistently being received by gpsd.

One problem remains: udev is unable to autostart gpsd

One new problem: clients are unable to connect to gpsd. Seems to be since it drops privileges to nobody. If run in the exact same manner, except as root, clients are able to connect
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 03:03 GMT
I can't figure out why gpsd can not be autostarted.
root root 25822 /usr/bin/python /lib/udev/gpsd.hotplug remove /dev/ttyUSB0 0.0
The hotplug script runs as root. So I try duplicating the script in the python interpreter (as root)
>>> import os
>>> os.system("gpsd -P /var/run/gpsd.pid -F /var/run/gpsd/gpsd.sock")
0
After which gpsd starts and runs perfectly

in /var/log/messages
Apr 2 22:54:00 cinnabar gpsd.hotplug: socket /var/run/gpsd/gpsd.sock doesn't exist
Apr 2 22:54:00 cinnabar gpsd.hotplug: launching gpsd -P /var/run/gpsd.pid -F /var/run/gpsd/gpsd.sock
Apr 2 22:54:00 cinnabar gpsd.hotplug: socket /var/run/gpsd/gpsd.sock doesn't exist
Apr 2 22:54:00 cinnabar gpsd.hotplug: can't reach gpsd


Nevermind about the connection problem with gpsd: seems xgps doesn't always work
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 03:13 GMT
btw, I most likely messed up makedepends() and depends() in the PKGBUILD
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 16:38 GMT
os.system() in /lib/udev/gpsd.hotplug could not start gpsd because "gpsd" is not in the path of the udev caller. This is fixed by giving the absolute path to gpsd.
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 16:48 GMT
Done
   PKGBUILD (2.2 KiB)
Comment by orbisvicis (orbisvicis) - Saturday, 03 April 2010, 17:03 GMT
Forgot to update the md5sums
   PKGBUILD (2.2 KiB)

Loading...