summaryrefslogtreecommitdiff
path: root/gpsd.hotplug
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-04-02 09:15:58 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-04-02 09:15:58 +0000
commit71a3907ac9d9876259bc8e04620f4c6494913d78 (patch)
tree523291ac9fe00c419350b25c14fe4bd8ac34f438 /gpsd.hotplug
parentd4daf7c74adb8e87c5f54f627527f2fd9473dc6d (diff)
downloadgpsd-71a3907ac9d9876259bc8e04620f4c6494913d78.tar.gz
Hotplug script must talk to the control socket.
Diffstat (limited to 'gpsd.hotplug')
-rwxr-xr-xgpsd.hotplug33
1 files changed, 13 insertions, 20 deletions
diff --git a/gpsd.hotplug b/gpsd.hotplug
index 5cc0f864..b4454a25 100755
--- a/gpsd.hotplug
+++ b/gpsd.hotplug
@@ -3,26 +3,19 @@
# This script is part of the gpsd distribution: see http://gpsd.berlios.de
import os, syslog, glob, socket
-def gpsd_connect():
- "Acquire a connection to the GPSD port."
- msg = "getaddrinfo returns an empty list"
- sock = None
- sockfile = None
- for res in socket.getaddrinfo("localhost", 2947, 0, socket.SOCK_STREAM):
- (af, socktype, proto, canonname, sa) = res
- try:
- sock = socket.socket(af, socktype, proto)
- sock.connect(sa)
- sockfile = sock.makefile()
- except socket.error, msg:
- if sock:
- sock.close()
- sock = None
- sockfile = None
- continue
- break
+def gpsd_control_connect():
+ "Acquire a connection to the GPSD control socket."
+ try:
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
+ sock.connect("/var/run/gpsd.sock")
+ sockfile = sock.makefile()
+ except socket.error, msg:
+ if sock:
+ sock.close()
+ sock = None
+ sockfile = None
if not sock:
- syslog.syslog("gpsd is not running or is unreachable")
+ syslog.syslog("gpsd is not running or control socket is unreachable")
return None
else:
return sockfile
@@ -48,7 +41,7 @@ def wake_up_gpsd(devpath):
else:
syslog.syslog("attempting to launch gpsd")
os.system("gpsd")
- connect = gpsd_connect()
+ connect = gpsd_control_connect()
if not connect:
return