{"id":74,"date":"2009-02-20T12:09:32","date_gmt":"2009-02-20T11:09:32","guid":{"rendered":"http:\/\/cris.netsons.org\/?p=74"},"modified":"2009-03-24T07:50:54","modified_gmt":"2009-03-24T06:50:54","slug":"starting-gpsd-automatically-with-a-bluetooth-gps","status":"publish","type":"post","link":"https:\/\/cris.bytesnblades.net\/it\/2009\/02\/20\/starting-gpsd-automatically-with-a-bluetooth-gps\/","title":{"rendered":"(English) Starting gpsd automatically with a bluetooth GPS"},"content":{"rendered":"<p class=\"qtranxs-available-languages-message qtranxs-available-languages-message-it\">Purtroppo questo articolo \u00e8 disponibile soltanto in <a href=\"https:\/\/cris.bytesnblades.net\/en\/wp-json\/wp\/v2\/posts\/74\" class=\"qtranxs-available-language-link qtranxs-available-language-link-en\" title=\"English\">English<\/a>.<\/p><p>I&#8217;ve lost a bit time trying to have gpsd starting automatically upon connection of my bluetooth GPS receiver (Holux M-1000) and finally I&#8217;ve found a solution that is probably not the best but is enough good for me.<br \/>\n<!--more--><\/p>\n<p>At first I had to struggle against the quite completely broken bluetooth support of ubuntu intrepid.<br \/>\n<em>Providentially<\/em> the <a href=\"http:\/\/blueman-project.org\">Blueman project<\/a> is keeping a <a href=\"https:\/\/edge.launchpad.net\/~blueman\/+archive\/ppa\">PPA repository<\/a> with the last version of their fantastic <em>Bluetooth Manager<\/em> and up to date bluez packages.<\/p>\n<p>Installing the <em>Blueman manager<\/em> and their bluez packages solved the most of my problems: thank you guys!<\/p>\n<p>The gpsd distribution comes already with a set of udev rules (see <em>\/etc\/udev\/rules.d\/50-gpsd.rules<\/em>) that match some devices by vendor and product id and a set of hotplug scripts that are invoked upon detection of devices to start and stop the gpsd daemon. Sadly this seems to work only with serial or usb devices as the sysfs subsystem does not seem to keep any of such information for my blootooth device.<\/p>\n<p>But let&#8217;s see what happens when the device is attached to a serial port &#8230;<br \/>\nRunning <em>udevadm monitor &#8211;udev<\/em> reveals the following events:<\/p>\n<pre><code>add  \/devices\/pci0000:00\/0000:00:02.1\/usb2\/2-1\/2-1.4\/2-1.4:1.0\/bluetooth\/hci0\/hci0:43 (bluetooth)\r\nadd  \/devices\/virtual\/tty\/rfcomm0 (tty)\r\nmove \/devices\/pci0000:00\/0000:00:02.1\/usb2\/2-1\/2-1.4\/2-1.4:1.0\/bluetooth\/hci0\/hci0:43\/rfcomm0 (tty)<\/code><\/pre>\n<p>so the device is recognized and a virtual serial port is created and relocated under the bluetooth device sub-tree.<\/p>\n<p>Checking the information of the relocated rfcomm device with <em>udevadm info -a -p \/devices\/&#8230;<\/em> reveals that it inherits the address of the gps device as attribute:<\/p>\n<pre><code>looking at device '\/devices\/pci0000:00\/0000:00:02.1\/...\/bluetooth\/hci0\/hci0:43\/rfcomm0':\r\n   KERNEL==\"rfcomm0\"\r\n   SUBSYSTEM==\"tty\"\r\n   DRIVER==\"\"\r\n   ATTR{address}==\"00:A6:01:39:D0:A0\"\r\n   ATTR{channel}==\"1\"<\/code><\/pre>\n<p>Good! The device address can be used to write a rule for udev!<\/p>\n<p>At this point I&#8217;ve got fresh versions of the <a href=\"http:\/\/gpsd.berlios.de\">GPSd&#8217;s<\/a> hotplug scripts as the ones that come with ubuntu are a bit outdated and broken.<br \/>\nThese scripts are available on the<a href=\"http:\/\/developer.berlios.de\/svn\/?group_id=2116\"> GPSd&#8217;s project subversion<\/a>: I&#8217;ve got <em>gpsd.hotplug<\/em> and <em>gpsd.hotplug.wrapper<\/em> from the trunk and copied them to <em>\/lib\/udev<\/em>.<\/p>\n<p>So I&#8217;ve added the following two rules to <em>\/etc\/udev\/rules.d\/50-gpsd.rules<\/em><\/p>\n<pre><code>ACTION==\"add\", SUBSYSTEM==\"tty\", ATTR{address}==\"00:A6:01:39:D0:A0\", SYMLINK=\"gps%n\", \\\r\n                    ENV{HOLUX_M1000}=\"present\", RUN+=\"\/lib\/udev\/gpsd.hotplug.wrapper\"\r\nACTION==\"remove\", SUBSYSTEM==\"tty\", ENV{HOLUX_M1000}==\"present\", RUN+=\"\/lib\/udev\/gpsd.hotplug.wrapper\"<\/code><\/pre>\n<p>Note how the <em>ADD<\/em> rule sets an environment variable <em>ENV{HOLUX_M1000}<\/em> that is used for matching the <em>REMOVE<\/em> event.<\/p>\n<p>I&#8217;ve reloaded the udev rules with <em>udevadm control reload_rules<\/em> &#8230; et voil\u00e0 &#8230; gpsd starts automatically when connecting my gps device.<\/p>","protected":false},"excerpt":{"rendered":"<p>Purtroppo questo articolo \u00e8 disponibile soltanto in English.I&#8217;ve lost a bit time trying to have gpsd starting automatically upon connection of my bluetooth GPS receiver (Holux M-1000) and finally I&#8217;ve found a solution that is probably not the best but &hellip; <a class=\"more-link\" href=\"https:\/\/cris.bytesnblades.net\/it\/2009\/02\/20\/starting-gpsd-automatically-with-a-bluetooth-gps\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49,4],"tags":[35,4,34,36],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-experiments","category-tips","tag-bluetooth","tag-tips","tag-ubuntu","tag-udev"],"_links":{"self":[{"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":55,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":668,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/posts\/74\/revisions\/668"}],"wp:attachment":[{"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cris.bytesnblades.net\/it\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}