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
Last revisionBoth sides next revision
doc:appunti:hardware:eeepc_navit [2009/11/06 12:27] niccolodoc:appunti:hardware:eeepc_navit [2011/04/22 12:59] – [Problems to be solved with gpsd] niccolo
Line 36: Line 36:
  
 ===== Installing the GPS daemon ===== ===== Installing the GPS daemon =====
 +
 +This was tested on Debian Squeeze 6.0.
  
 Before starting Navit the **gpsd** should be up and running. Install the gpsd package and configure it, this is the relevant part of **''/etc/default/gpsd''** file: Before starting Navit the **gpsd** should be up and running. Install the gpsd package and configure it, this is the relevant part of **''/etc/default/gpsd''** file:
Line 46: Line 48:
 </file> </file>
  
-It is convenient to let **udev** handle some operations: when I connect my **[[gps_logger_i_blue_747|i-Blue 747 USB GPS logger]]** I want gpsd to be started (if it was not)Just add the following line to the file **''/etc/udev/rules.d/z60_gpsd.rules''** and restart udev:+This will start **''gpsd''** at bootstrap, it will wait for the GPS to be connected to the USB port. **Note:** when the USB is connected, ''udev'' will not start ''gpsd'' if it is not already running (i.e. when ''START_DAEMON="false"''). 
 + 
 +**''udev''** will handle the automatic connection of the GPS via USB, there is a script **''/lib/udev/rules.d/60-gpsd.rules''** in Debian Squeeze which includes the **[[gps_logger_i_blue_747|i-Blue 747 USB GPS logger]]**. 
 + 
 +For previous Debian releases just add the following line to the file **''/etc/udev/rules.d/z60_gpsd.rules''** and restart ''udev'':
  
 <file> <file>
Line 53: Line 59:
 </file> </file>
  
-When the GPS is plugged into the USB port, udev creates the **''/dev/gps0''** device and starts **gpsd**. When the GPS is unplugged the Unix device is removed, but the daemon remains running.+When the GPS is plugged into the USB port, ''udev'' creates the **''/dev/gps0''** device, when the GPS is unplugged the Unix device is removed and the daemon remains running.
  
 A simple test to check that gpsd is working, is to run **''gpspipe -r''** (provided by the ''gpsd-clients'' package), it should print out the NMEA messages recevied from the GPS: A simple test to check that gpsd is working, is to run **''gpspipe -r''** (provided by the ''gpsd-clients'' package), it should print out the NMEA messages recevied from the GPS:
Line 69: 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>
 +==== Problem #1: plug/unplug ====
  
 +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''** into another terminal to force device re-opening.
  
 +I hacked **''/lib/udev/gpsd.hotplug''**, adding the execution of that command when the device is re-added. This is the patch:
  
 +<code>
 +--- gpsd.hotplug.orig   2010-06-02 23:03:02.000000000 +0200
 ++++ 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>
  
 +==== Problem #2: permissions ====
  
 +With Debian Lenny there is a **permission problem**: if gpsd starts with no GPS 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.
  
 +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.
  
-==== Problems to be solved with gpsd ==== +It should be possibile to create such static device into **''/lib/udev/devices/''**, udev will copy it under ''/dev/'' at boot time:
- +
-We want to be able to plug/unplug the GPS device in the USB port and gpsd should work seamless, but there are two problems: +
- +
-  - **Permissions**: if gpsd starts with no GPS is connected, it switches to group **nobody**. When 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. +
-  - **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 +mknod -m 0660 /lib/udev/devices/ttyS0 c 4 64 
-chown root:dialout /lib/udev/devices+chown root:dialout /lib/udev/devices/ttyS0
 </code> </code>
- 
-For the second problem I hacked **''/lib/udev/gpsd.hotplug''**, adding the execution of a script when the device is re-added: 
- 
-<code python> 
-    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(argument, stat.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: 
- 
-<code bash> 
-#!/bin/sh 
-/bin/echo /usr/bin/gpspipe -r -n1 | /usr/bin/at now 
-</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.txt · Last modified: 2011/04/22 13:00 by niccolo