User Tools

Site Tools


doc:appunti:hardware:eeepc_navit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:hardware:eeepc_navit [2011/04/22 11:32] – [Installing the GPS daemon] niccolodoc:appunti:hardware:eeepc_navit [2011/04/22 13:00] (current) – [Installing the GPS daemon] niccolo
Line 35: Line 35:
 </code> </code>
  
-===== Installing the GPS daemon =====+===== Installing gpsd, the GPS daemon =====
  
 This was tested on Debian Squeeze 6.0. This was tested on Debian Squeeze 6.0.
Line 75: Line 75:
 $GPGGA,112814.000,4353.5310,N,01106.0969,E,0,3,,102.4,M,47.6,M,,*4B $GPGGA,112814.000,4353.5310,N,01106.0969,E,0,3,,102.4,M,47.6,M,,*4B
 </code> </code>
-==== Problems to be solved with gpsd ====+==== Problem #1: plug/unplug ====
  
-We want to be able to plug/unplug the GPS device in the USB port and gpsd should work seamlessbut there are two problems:+When a gps client opens a connection with gpsd, it starts receiving data. If GPS device is unplugged and plugged againthe connection does not restart automatically. A workaround is to execute **''gpspipe -r n1''** into another terminal to force device re-opening.
  
-  - **Permissions**: if gpsd starts with no GPS is connected, it switches to group **nobody**. When a GPS is connected, udev add the /dev/ttyUSB device as **root:dialout** and /lib/udev/gpsd.hotplug assigns mode **0660**. In this scenario gpsd cannot read the device. +I hacked **''/lib/udev/gpsd.hotplug''**, adding the execution of that command when the device is re-addedThis is the patch:
-  - **GPS unplug/plug**: when a gps client opens a connection with gpsd, it starts receiving data. If GPS device is unplugged and plugged again, the connection does not restart automatically. A workaround is to execute **''gpspipe -r n1''** to force device re-opening. +
- +
-A workaround at the first problem is to let /etc/init.d/udev create a node for /dev/ttyS0 at boot time, even if no devices are present. Per default gpsd will read the group of this device and switches to that group.+
  
 <code> <code>
-mknod -m 0660 /lib/udev/devices c 4 64 +--- gpsd.hotplug.orig   2010-06-02 23:03:02.000000000 +0200 
-chown root:dialout /lib/udev/devices++++ gpsd.hotplug        2011-04-22 12:44:32.000000000 +0200 
 +@@ -114,6 +114,9 @@ 
 +                 hotplug(os.getenv("ACTION"), os.getenv("DEVPATH")) 
 +             else:                      # Called by hand for testing 
 +                 gpsd_control(sys.argv[1], sys.argv[2]) 
 ++                if sys.argv[1] == 'add': 
 ++                    # Wake-up all the listening clients. 
 ++                    os.system("/usr/bin/gpspipe -r -n1 &"
 +         except: 
 +             (exc_type, exc_value, exc_traceback) = sys.exc_info() 
 +             syslog.syslog("gpsd.hotplug: exception %s yields %s" % (exc_type, exc_value))
 </code> </code>
  
-For the second problem I hacked **''/lib/udev/gpsd.hotplug''**, adding the execution of a script when the device is re-added:+==== Problem #2permissions ====
  
-<code python> +With Debian Lenny there is a **permission problem**if gpsd starts with no GPS connected, it switches to group **nobody**When a GPS is connectedudev add the ''/dev/ttyUSB'' device as **root:dialout** and ''/lib/udev/gpsd.hotplug'' assigns mode **0660**. In this scenario gpsd cannot read the device.
-    if action == 'add': +
-        # Force the group-read & group-write bits on, so gpsd will still be +
-        # able to use this device after dropping root privileges. +
-        os.chmod(argumentstat.S_IMODE(os.stat(argument)[stat.ST_MODE])|0660) +
-        connect.sendall("+%s\r\n" % argument) +
-        connect.recv(12) +
-        os.system('/usr/local/bin/gps-reopen'+
-</code>+
  
-The script is simple this:+A workaround is to create a node for ''/dev/ttyS0'' owned by group dialout at boot time, even if no such device is present. Per default ''gpsd'' will read the group of this device and switches to that group.
  
-<code bash+It should be possibile to create such a static device into **''/lib/udev/devices/''**, udev will copy it under ''/dev/'' at boot time: 
-#!/bin/sh + 
-/bin/echo /usr/bin/gpspipe -r -n1 | /usr/bin/at now+<code> 
 +mknod -m 0660 /lib/udev/devices/ttyS0 c 4 64 
 +chown root:dialout /lib/udev/devices/ttyS0
 </code> </code>
- 
-Don't ask me why I need running gpspipe it via **at**, I suspect there is the need of a controlling terminal, etc... 
  
 ===== Navigation ===== ===== Navigation =====
doc/appunti/hardware/eeepc_navit.1303464747.txt.gz · Last modified: 2011/04/22 11:32 by niccolo