troubleshooting.html.in 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head lang="en">
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="Author" content="Eric S. Raymond">
  6. <meta name="Description" content="How to bring up a GPS under GPSD">
  7. <meta name="Keywords" content="GPS, gpsd, troubleshooting">
  8. <meta name="Revised" content="3 November 2019">
  9. <meta name="robots" content="index,follow">
  10. <title>Troubleshooting GPSD</title>
  11. <link rel="stylesheet" href="main.css" type="text/css">
  12. </head>
  13. <body>
  14. <div id="Header">Troubleshooting GPSD</div>
  15. <div id="Menu">
  16. <img src="gpsd-logo-small.png" alt="Small gpsd Logo" height="126"
  17. width="105"><br>
  18. <a href="index.html">Home</a><br>
  19. <a href="index.html#news">News</a><br>
  20. <a href="index.html#downloads">Downloads</a><br>
  21. <a href="index.html#mailing-lists">Mailing lists</a><br>
  22. <a href="index.html#documentation">Documentation</a><br>
  23. <a href="faq.html">FAQ</a><br>
  24. <a href="xgps-sample.html">Screenshots</a><br>
  25. <a href="index.html#recipes">Recipes</a><br>
  26. <a href="index.html#others">Other GPSDs</a><br>
  27. <a href="hardware.html">Hardware</a><br>
  28. <a href="for-vendors.html">For GPS Vendors</a><br>
  29. <a href="wishlist.html">Wish List</a><br>
  30. <a href="hall-of-shame.html">Hall of Shame</a><br>
  31. Troubleshooting<br>
  32. <a href="hacking.html">Hacker's Guide</a><br>
  33. <a href="protocol-transition.html">Application Compatibility</a>
  34. <a href="references.html">References</a><br>
  35. <a href="history.html">History</a><br>
  36. <a href="future.html">Future</a><br>
  37. <div>&nbsp;</div>
  38. <a href='http://www.catb.org/hacker-emblem/'><img
  39. src='glider.png' alt='hacker emblem' height="55" width="55"></a><br>
  40. <script src="https://www.openhub.net/p/3944/widgets/project_thin_badge.js"></script>
  41. <hr>
  42. <script><!--
  43. google_ad_client = "pub-1458586455084261";
  44. google_ad_width = 160;
  45. google_ad_height = 600;
  46. google_ad_format = "160x600_as";
  47. google_ad_type = "text";
  48. google_ad_channel = "";
  49. //--></script>
  50. <script src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
  51. </script>
  52. <hr>
  53. <a href="https://validator.w3.org/check/referer"><img
  54. src="https://www.w3.org/Icons/valid-html401"
  55. alt="Valid HTML 4.01!" height="31" width="88"></a>
  56. </div>
  57. <div id="Content">
  58. <h1>Contents</h1>
  59. <p>References like <b>foobar(n)</b> are a Unix convention meaning you
  60. should look up the program <b>foobar</b> using the <b>man</b> utility
  61. for browsing manual pages. Numeric section 1 refers to general
  62. commands and section 8 to administrative commands.</p>
  63. <ol class="ToC">
  64. <li><a href="#firsttry">First Try</a></li>
  65. <li><a href="#gpstroubleshooting">GPS Troubleshooting</a></li>
  66. <li><a href="#usbtroubleshooting">USB Troubleshooting</a></li>
  67. <li><a href="#generaltroubleshooting">General Troubleshooting</a></li>
  68. <li><a href="#startuptroubleshooting">Start at Boot Troubleshooting</a></li>
  69. <li><a href="#telnet" >Telnet</a></li>
  70. <li><a href="#hotplugtroubleshooting">Udev Hotplug Troubleshooting</a></li>
  71. <li><a href="#systemdtroubleshooting" >Systemd Troubleshooting</a></li>
  72. </ol>
  73. <h1 id='firsttry'>First Try</h1>
  74. <p>If you have a USB GPS and have installed from a binary package,
  75. plug your GPS into a USB port and run <code>xgps</code> or
  76. <code>cgps</code>. Very likely you will see fix data appear in the
  77. client. If so, you're done.</p>
  78. <p>If you have a Bluetooth GPS, follow our <a href="bt.html">Bluetooth
  79. instructions</a> and run <code>xgps</code> or <code>cgps</code>. Very
  80. likely you will see fix data appear in the client. If so, you're
  81. done.</p>
  82. <p>If you have a serial (RS232) GPS, plug it into a serial port
  83. connector and jump to <a href="#generaltroubleshooting">General
  84. Troubleshooting</a></p>
  85. <p>We do not yet have troubleshooting instructions for GPSes using
  86. CF (Compact Flash) interfaces. Please contribute some if you can.</p>
  87. <p>If your test client does not show data, keep reading.</p>
  88. <h1 id='gpstroubleshooting'>GPS troubleshooting</h1>
  89. <p>Check that the GPS has power. If it is a USB device, it
  90. needs to be cabled to a USB port to have power. All Bluetooth GPSes
  91. and some serial GPSes are powered by an on-board battery; check that
  92. the battery is present and charged. The GPS may have an on-off switch
  93. which needs to be in the 'on' position.</p>
  94. <p>Most GPSes have a power-on LED; it should be continuously on
  95. or blinking once a second. If it is continuously off, your GPS is dead
  96. or disconnected. Check that it has power.</p>
  97. <h1 id='usbtroubleshooting'>USB troubleshooting</h1>
  98. <p>USB GPSes actually emulate RS232 serial using converter chips.
  99. Under Linux, the <code>usbserial</code> kernel module must be loaded
  100. for correct operation of this class of device. Normally this module
  101. load should happen automatically when the device activates, but if you
  102. don't receive data check for it with <b>lsmod(8)</b>.</p>
  103. <p>On Linux systems with module autoloading disabled or misconfigured,
  104. it is possible you may need to load the module manually with a command,
  105. while running as root, such as <code>modprobe usbserial vendor=0x1a86
  106. product=0x7523</code>. Do not copy those hex numbers slavishly, they
  107. are examples. To get the right numbers, you will need to dig up the
  108. vendor and product ID of your USB-serial converter device.</p>
  109. <p>Run <b>lsusb(8)</b> before and after connecting your GPS; after,
  110. you should see an additional line indicating a new device. Expect the
  111. new line to describe a serial-to-USB adapter chip, often (but not
  112. always) the Prolific Technology PL2303. Then run <b>dmesg(8)</b>,
  113. looking near the end for a message indicating a new USB device of
  114. that kind and giving you the device path - <code>/dev/ttyUSBn</code>
  115. for some number n.</p>
  116. <p>If you have installed a GPSD binary package on a Linux system and
  117. are using a USB GPS, you should not need to start gpsd manually,
  118. because the hotplug system will have done it for you. You should be
  119. able to start a test client (such as <code>cgps</code> or
  120. <code>xgps</code>) and watch it report fixes. If this works, you are
  121. done and can skip the rest of this guide.</p>
  122. <h1 id="generaltroubleshooting">General Troubleshooting</h1>
  123. <h2>Make sure gpsd is not running</h2>
  124. <p>Before doing anything else, make sure there is no instance of gpsd
  125. running, as root, do:</p>
  126. <pre># killall gpsd
  127. # killall -9 gpsd</pre>
  128. <p>Remove any sockets gpsd might have left behind, as root, do:</p>
  129. <pre># rm @RUNDIR@/gpsd.sock</pre>
  130. <h2>Ensure no other programs are using your device</h2>
  131. <p>Tools like modemmanager might be using your device, probably
  132. automatically attached to it by udev or systemd. To check if your
  133. device is ready to be used by gpsd try running <b>lsof(8)</b>
  134. and search the output for your GPS device path (for example
  135. <code>lsof -n | grep /dev/ttyUSB0</code>). If something is
  136. listed in the output you'll have to stop these processes and
  137. reconfigure them to ignore your GPS device.
  138. <h2>Use gpsmon to check that your device is emitting data</h2>
  139. <p>Try running <b>gpsmon(1)</b>, giving it your GPS device path as an
  140. argument (for example. <code>"gpsmon /dev/ttyUSB0"</code>). After a
  141. few moments to sync up, it should display a screen full of data on the
  142. device, including displaying the raw packet data streaming from it.</p>
  143. <p>If <b>gpsmon(1)</b> reports no data at all, you may have the device
  144. path wrong; check that using <b>dmesg(8)</b> or by whatever means you
  145. have available. If you have the right device, you may have some
  146. low-level system problem with serial or USB that you'll need to fix
  147. before <code>gpsd</code> will operate. Check your cabling, power, and
  148. kernel configuration.</p>
  149. <h2>Launch gpsd to see its progress messages</h2>
  150. <p>You can launch gpsd with the options -N (don't daemonize) and -D
  151. [0-8] (debug and level). This will let it run and send output,
  152. including traffic from the GPS receiver, to the terminal. This is a
  153. recommended first step because it avoids client issues. For example,
  154. here we give gpsd a control socket but no device:</p>
  155. <pre># gpsd -N -D3 -F @RUNDIR/gpsd.sock
  156. gpsd: launching (Version 2.96~dev)
  157. gpsd: listening on port gpsd
  158. gpsd: running with effective group ID 0
  159. gpsd: running with effective user ID 0
  160. ^Cgpsd: received terminating signal 2.
  161. gpsd: exiting.
  162. #</pre>
  163. <p>If you get something like this error message: "gpsd: error while
  164. loading shared libraries: libgpsd.so.0: cannot open shared object
  165. file: No such file or directory" then run ldconfig(8) and try again.</p>
  166. <p>Here we give it a device file. But the device file isn't there, and
  167. there is no receiver.</p>
  168. <pre># gpsd -N -D3 -F @RUNDIR/gpsd.sock /dev/ttyUSB0
  169. gpsd: launching (Version 2.96~dev)
  170. gpsd: listening on port gpsd
  171. gpsd: running with effective group ID 0
  172. gpsd: running with effective user ID 0
  173. gpsd: stashing device /dev/ttyUSB0 at slot 0
  174. ^Cgpsd: received terminating signal 2.
  175. gpsd: exiting.
  176. #</pre>
  177. <p>This time, gpsd stashes the device file and waits for some outside
  178. agency, like udev, to create it. Like so:</p>
  179. <pre># gpsd -N -D3 -F @RUNDIR/gpsd.sock /dev/ttyUSB0
  180. gpsd: launching (Version 2.96~dev)
  181. gpsd: listening on port gpsd
  182. gpsd: running with effective group ID 0
  183. gpsd: running with effective user ID 0
  184. gpsd: stashing device /dev/ttyUSB0 at slot 0
  185. gpsd: control socket connect on fd 6
  186. gpsd: &lt;= control(6): /dev/ttyUSB0 already active
  187. ^Cgpsd: received terminating signal 2.
  188. gpsd: exiting.
  189. #</pre>
  190. <p>If you have udev on your computer, and you don't see gpsd notice
  191. the device (&quot;control socket connect on fd 6&quot;), check to be
  192. sure <a href="#hotplugtroubleshooting">udev is working correctly</a>.</p>
  193. <p>If you pull the plug on the receiver, gpsd will note the change.</p>
  194. <p>With the receiver plugged in and gpsd running as above, you can
  195. launch a client. <code>xgps</code> comes with the distribution.
  196. On some Linuxes, it may be in a separate package, e.g. gpsd-clients.
  197. You should then see a lot of traffic between gpsd and the client in
  198. the gpsd terminal window. For example, here's a fix as reported by
  199. gpsd:</p>
  200. <pre>gpsd: SiRF: MND 0x02: time=1293859466.85 lat=42.64 lon=-118.21 alt=1315.15 track=0.00 speed=0.00 mode=1 status=0 hdop=0.00 used=0 mask={TIME|LATLON|ALTITUDE|SPEED|TRACK|STATUS|MODE|DOP|USED}</pre>
  201. <p>Note that gpsd doesn't try to activate the receiver until it has a
  202. client, and the client asks for data with a ?WATCH request. It also
  203. shuts down its connection to the receiver when it has no clients. This
  204. is a power saving feature.</p>
  205. <p>Another way to verify that gpsd can open the device file is with
  206. lsof(8) (&quot;list open files&quot;):</p>
  207. <pre># lsof | grep ttyU
  208. gpsd 20895 nobody 7u CHR 188,0 0t0 851138 /dev/ttyUSB0
  209. #</pre>
  210. <h1 id="startuptroubleshooting">Troubleshooting Start at Boot</h1>
  211. <p>If gpsd launches at boot, you should be able to start it up or shut
  212. it down with one of the many utilities that manipulate system-V like
  213. startup environments, e.g. service(8). <code>service gpsd
  214. start</code>, etc. works on some Linuxes. sysv-rc-conf(8) is a handy
  215. curses utility for the job. Watch the output.</p>
  216. <p>You can also look at your boot messages with dmesg(1).</p>
  217. <h2>Ubuntu/Debian</h2>
  218. <p>The .deb package supplied for the Debian and Ubuntu Linux
  219. distributions launch at boot either using systemd with gpsd.socket
  220. and gpsd.service, or on older releases from the system V-like script
  221. <code>/etc/init.d/gpsd</code>. However, both are governed by a control
  222. file, <code>/etc/default/gpsd</code>. If necessary, edit the control
  223. file as root.</p>
  224. <p>Please note that systemd will only start gpsd on request
  225. by clients connecting to the unix or tcp socket. In case you need
  226. gpsd to run always, you'll need to configure systemd to start it.
  227. One way would be to create <code>/etc/systemd/system/gpsd.service</code>
  228. with the following content:
  229. </p>
  230. <pre>
  231. [Unit]
  232. Description=GPS (Global Positioning System) Daemon
  233. Requires=gpsd.socket
  234. # Needed with chrony SOCK refclock
  235. After=chronyd.service
  236. [Service]
  237. EnvironmentFile=-/etc/default/gpsd
  238. EnvironmentFile=-/etc/sysconfig/gpsd
  239. ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $DEVICES
  240. [Install]
  241. WantedBy=multi-user.target
  242. Also=gpsd.socket
  243. </pre>
  244. <p>
  245. To ask systemd to reload its config run
  246. <code>systemctl daemon-reload; systemctl reenable gpsd.service</code>.
  247. Instead of using the EnvironmentFile(s) you could just edit the command
  248. line as necessary for your system. Don't forget to run
  249. <code>systemctl daemon-reload</code> after changing the file.
  250. </p>
  251. <p>You will likely want the gpsd-clients package as a debugging
  252. tool. These are the clients maintained as part of the gpsd
  253. project. Other clients may or may not use the right libgpsd or the
  254. right protocol, or something. So make sure gpsd is working correctly
  255. with the gpsd clients. You can always purge them later.</p>
  256. <p>In case you need to debug the gpsd or its clients using gdb or
  257. the python debugger the gpsd-dbg package is provided. It should
  258. contain all necessary debug symbols to create useful backtraces.</p>
  259. <p>If you have a prior installation of gpsd from a deb package, and
  260. are switching to compiling your own, from a recent tarball or from the
  261. git repository, it is not enough to <code>apt-get remove</code> the
  262. prior installation. You must <code>apt-get purge</code> them. This
  263. removes some configuration files left behind by remove.</p>
  264. <p>If you do compile your own gpsd, be aware that installing gpsd
  265. client packages can force installation of gpsd as well. This can also
  266. happen on debian systems when apt is set up to install recommended
  267. packages as dependencies.</p>
  268. <p>One culprit is packages like
  269. <a href="http://www.tangogps.org/">tangogps</a>, which recommendd gpsd.
  270. Fortunately, since it recommends gpsd, you can install it using
  271. <code>apt-get install --no-install-recommends</code> or disable the
  272. installation of recommended packages permanently. Put the following in
  273. a file with a high leading number in <code>/etc/apt/apt.conf.d</code>,
  274. e.g. <code>90no.recommendations</code>:</p>
  275. <pre>APT::Install-Recommends &quot;false&quot;;
  276. </pre>
  277. <p>Other client packages may not be so lenient, but you can use the
  278. tool <b>equivs</b> to create an empty fake package which provides
  279. gpsd.</p>
  280. <h2>Red Hat</h2>
  281. <p>The rpm package made from the gpsd distribution will launch at boot
  282. from the script <code>/etc/init/rc.d/gpsd</code>. It is governed by
  283. the file <code>/etc/sysconfig/gpsd</code>, although it it doesn't find
  284. that file, it will provide its own defaults.</p>
  285. <p>You will likely want the gpsd-clients package as a debugging
  286. tool. These are the clients maintained by the gpsd developers. Other
  287. clients may or may not use the right libgpsd or the right protocol, or
  288. something. So make sure gpsd is working correctly with the gpsd
  289. clients. You can always purge them later.</p>
  290. <h1 id="telnet">Telnet</h1>
  291. <p>Telnet provides a quick and dirty acceptance test for gpsd. Other
  292. clients (<code>cgps</code>, <code>xgps</code>, and other)
  293. are preferable, so consider telnet a last ditch tool. You can telnet
  294. into gpsd:</p>
  295. <pre>$ telnet localhost 2947
  296. Trying ::1...
  297. Trying 127.0.0.1...
  298. Connected to localhost.
  299. Escape character is '^]'.
  300. {&quot;class&quot;:&quot;VERSION&quot;,&quot;release&quot;:&quot;2.96~dev&quot;,&quot;rev&quot;:&quot;2011-03-15T03:05:33&quot;,&quot;proto_major&quot;:3,&quot;proto_minor&quot;:4}
  301. </pre>
  302. <p>Note that the <code>release</code> strings will be different in
  303. your case.</p>
  304. <p>To see data from the receiver in JSON (if any), enter the command
  305. <samp>?WATCH={&quot;enable&quot;:true,&quot;json&quot;:true}</samp>. To
  306. end JSON output, <samp>?WATCH={&quot;enable&quot;:false}</samp>. Then
  307. control-] and &quot;exit&quot; to exit the telnet client.</p>
  308. <p>For more information, see <a
  309. href="client-howto.html#_how_the_gpsd_wire_protocol_works" >How the
  310. GPSD wire protocol works</a> in the <a href="client-howto.html" >GPSD
  311. Client HOWTO</a>.</p>
  312. <h1 id="hotplugtroubleshooting">Udev Hotplug Troubleshooting</h1>
  313. <p>The Linux udev system has been prone to change out from under us,
  314. breaking our hotplug support for USB receivers. Accordingly, here's a
  315. short guide to verifying that the different pieces are working
  316. correctly, with indications of where to troubleshoot on failure.</p>
  317. <p>First, verify that your USB subsystem can see your receiver. Run
  318. lsusb(1). Plug the receiver in and run lsusb(1) again, looking for
  319. the extra line - it will be identified by a serial-to-USB converter
  320. chip type such as a PL2303. Unplug the receiver and verify that the
  321. line describing the device is gone.</p>
  322. <p>If this test fails, something very basic is wrong at hardware
  323. level. If your receiver has a two-section cable joined by something
  324. like a <a
  325. href="https://en.wikipedia.org/wiki/Mini-DIN_connector">6-pin
  326. mini-DIN connector</a>, with a component housing between that and the
  327. USB plug, be aware that the serial converter may live in that housing
  328. and you have to unplug the <b>entire cable</b> from your computer, not
  329. just separate the halves of the mini-DIN connector. If there is no
  330. such joint, it may be that your receiver is defective or dead. See
  331. your vendor documentation for help in diagnosis. The least likely
  332. failure is for the USB hardware on the PC side to be buggy.</p>
  333. <p>The next thing to try is watching the hotplug events in your system
  334. logs. Do <code>tail -f /var/log/syslog</code>; plug in and unplug the
  335. receiver. You should see messages indicating from the USB subsystem
  336. in the kernel indicating device connect and disconnect. If you don't,
  337. check your kernel configuration; USB support may be absent or
  338. misconfigured.</p>
  339. <p>Now we involve the udev system. Unplug the receiver. If you are
  340. compiling gpsd, run <code>make udev-install</code> from the source
  341. directory to install the required udev rules. (There is a <code>make
  342. udev-uninstall</code> for cleaning up after this test.) If you are
  343. using a package, your package manager will install these files for
  344. you. Do <code>tail -f /var/log/syslog</code>. Now plug in the
  345. receiver.</p>
  346. <p>You should see messages that include something like the following
  347. text (the USB device may vary):</p>
  348. <pre>
  349. gpsd.hotplug: gpsd_control(action=add, arg=/dev/ttyUSB0)
  350. gpsd.hotplug: launching gpsd -F @RUNDIR/gpsd.sock
  351. </pre>
  352. <p>These are from the gpsd.hotplug handler called by udev on a hotplug
  353. event matching one of the known udev types for a USB GPS, and indicating
  354. the launch of a gpsd instance.</p>
  355. <p>If you don't see this, several things could be going wrong. The
  356. udev rules may not be installed correctly. Or the handler they call
  357. may be unable to run for some reason; it has two layers, a shell script
  358. wrapper around a little Python program that does the real work. You
  359. may have to figure out where the udev log messages go on your system
  360. and use udevadm(8) to crank up the log level until you can see what's
  361. going on.</p>
  362. <p>If your GPS uses an unusual serial-to-USB converter, the GPSD rules
  363. may not recognize it as a probable GPS. You'll need to look at the
  364. converter type indicated in the lsusb(1) listing and match it against
  365. the rules in the gpsd.rules file. If it's not known, please report
  366. this as a bug to the GPSD developers.</p>
  367. <p>Once you know that udev can launch gpsd, you'll want to watch what
  368. it's doing with the hotplug notifications. Unplug the receiver and
  369. kill the running gpsd instance, if there is one. Now run <code>make
  370. udev-test</code> and plug in the receiver. (For those using packages,
  371. this is the equivalent of &quot;<code>gpsd -N -n -F @RUNDIR/gpsd.sock
  372. -D 5</code>&quot;.) </p>
  373. <p>You can also launch the hotplug code manually: <code>cd /lib/udev
  374. &amp;&amp; ./gpsd.hotplug add /dev/ttyUSB0</code> If this fails, there is
  375. something wrong with the hotplug code. If it succeeds, the problem may
  376. be in how udev is calling gpsd.hotplug, or udev may never call
  377. gpsd.hotplug.</p>
  378. <p>You should see log messages from gpsd indicating that the control
  379. socket has received a command to add the device, and then data
  380. from the device. When you unplug and replug the device, gpsd
  381. should emit messages about the device closes and opens.</p>
  382. <p>If you don't see this, there's a bug or misconfiguration
  383. somewhere. Check to make sure the hotplug handler and gpsd have
  384. matching expectations about the location of the control socket.</p>
  385. <p>If you do see these device file opens and closes logged, the
  386. udev end of the configuration is working.</p>
  387. <h1 id="systemdtroubleshooting">Systemd Troubleshooting</h1>
  388. <h2>Systemd Interaction</h2>
  389. <p>gpsd must be installed. We want gpsd itself and, for testing, the gpsd clients, at least cgps and possibly xgps.</p>
  390. <p>gpsd must running and reading from the GPS receiver. For general gpsd debugging, it is helpful to know that gpsd is running, and that the GPS receiver device file is present. For a u-blox receiver:</p>
  391. <pre>root@orca:~# ps aux | grep -i gpsd | grep -v grep ; ls /dev/ttyA*
  392. gpsd 14547 0.5 0.0 18092 3504 ? S&lt;sl 15:44 0:00 /usr/sbin/gpsd
  393. /dev/ttyACM0
  394. root@orca:~#</pre>
  395. <p>(Devices file names vary. <code>/dev/ttyU*</code> is typical.)</p>
  396. <p>If gpsd isn't running, check other parts of this document, and <a href="https://gitlab.com/gpsd/gpsd/blob/master/INSTALL" >INSTALL</a> in the root of the <a href="https://gitlab.com/gpsd/gpsd" >git repo</a>.</p>
  397. <p>The next question is, is gpsd controlled by systemd?</p>
  398. <h3>Systemd isn't installed</h3>
  399. <p>Your problem lies elsewhere.</p>
  400. <h3>Systemd is present but but does not manage gpsd.</h3>
  401. <p>You can use systemd's tools to check. <code><a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#status%20PATTERN%E2%80%A6%7CPID%E2%80%A6%5D" >systemctl status</a> gpsd</code> should tell you what systemd thinks gpsd's status is.</p>
  402. <pre>
  403. root@orca:~# <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#status%20PATTERN%E2%80%A6%7CPID%E2%80%A6%5D" >systemctl status</a> gpsd
  404. ● gpsd.service - GPS (Global Positioning System) Daemon
  405. Loaded: loaded (/lib/systemd/system/gpsd.service; enabled; vendor preset: enabled)
  406. Active: active (running) since Thu 2019-10-03 15:07:01 MDT; 1 weeks 2 days ago
  407. Main PID: 32454 (gpsd)
  408. Tasks: 1 (limit: 4915)
  409. Memory: 924.0K
  410. CGroup: /system.slice/gpsd.service
  411. └─32454 /usr/sbin/gpsd
  412. Oct 03 15:07:01 orca systemd[1]: Starting GPS (Global Positioning System) Daemon...
  413. Oct 03 15:07:01 orca systemd[1]: Started GPS (Global Positioning System) Daemon.
  414. root@orca:~#
  415. </pre>
  416. <p>This example shows that systemd clearly does control gpsd. If systemd replies something like <code>Unit gpsd.service could not be found.</code>, systemd is present but does not control gpsd.</p>
  417. <p>Alternatively, see if any of the files <code>gpsd.*</code> are present under systemd's directories. That location is system dependent, but <code>/lib/systemd/system/</code> is typical. Or use <code>locate</code> or your package manager to check.</p>
  418. <p>If systemd is present but does not control gpsd, your problem lies elsewhere.</p>
  419. <h3>Systemd is present and controls gpsd</h3>
  420. <p>Your tool for interacting with systemd is <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html" >systemctl</a>. The typical syntax is</p>
  421. <pre>systemctl [OPTIONS...] COMMAND [UNIT...]</pre>
  422. <p>For the gory details, see the <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html" >systemctl man page</a>. Generally useful commands include: <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#daemon-reload" >daemon-reload</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#disable%20UNIT%E2%80%A6" >disable</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#enable%20UNIT%E2%80%A6" >enable</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#reload%20PATTERN%E2%80%A6" >reload</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#restart%20PATTERN%E2%80%A6" >restart</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#show%20PATTERN%E2%80%A6%7CJOB%E2%80%A6" >show</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#start%20PATTERN%E2%80%A6" >start</a>, <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#status%20PATTERN%E2%80%A6%7CPID%E2%80%A6%5D" >status</a>, and <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#stop%20PATTERN%E2%80%A6" >stop</a>. Note that daemon-reload and reload are not the same command. reload tells a unit to reload its configuration file (if it can do so). daemon-reload has systemd reload all unit files and its own configuration file.</p>
  423. <p>If you want to shut gpsd down, you have to shut down both units. Shutting down gpsd.service alone is not sufficient because gpsd.socket could fire it up again.</p>
  424. <pre><a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#stop%20PATTERN%E2%80%A6" >systemctl stop</a> gpsd.socket gpsd.service</pre>
  425. <p>Note: issuing the stop command may not actually stop the service. On a Debian system out of the box, systemd starts gpsd up again.</p>
  426. <h2>Real World Example</h2>
  427. <p>For security, gpsd by default is shipped set up to listen only on the loopback interface, thereby restricting its audience to clients on the same computer. We'd like to allow other computers to listen in as well. This means:</p>
  428. <ul>
  429. <li>Opening the firewall at the gpsd assigned port, 2947. That is beyond the scope of this document.</li>
  430. <li>Adding the appropriate switch to the command line for gpsd. While we're at it, we'll also add the -n switch.</li>
  431. <li>Changing the gpsd.socket unit so that other clients can connect to the daemon.</li>
  432. </ul>
  433. <p>Once we know gpsd is running, we modify <code>/etc/default/gpsd</code> to provide the options we want. One to listen on all the interfaces (-G), and one to tell gpsd not to wait for a client to connect before polling (-n). The GPSD_OPTIONS stanza now looks like:</p>
  434. <pre>
  435. # Other options you want to pass to gpsd
  436. # GPSD_OPTIONS=""
  437. GPSD_OPTIONS="-Gn"
  438. </pre>
  439. <p>We can stop gpsd. Systemd will restart it for us, this time with the options in place. We then verify that the options are there:</p>
  440. <pre>root@orca:~# <a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#stop%20PATTERN%E2%80%A6" >systemctl stop</a> gpsd.socket gpsd.service
  441. root@orca:~# ps aux | grep -i gpsd | grep -v grep
  442. gpsd 14547 0.5 0.0 18092 3504 ? S&lt;sl 15:44 0:00 /usr/sbin/gpsd -Gn
  443. root@orca:~#</pre>
  444. <p>But we aren't there yet. gpsd may be listening on all interfaces, but systemd's hold on the socket means gpsd can't hear anything on interfaces other than the loopback. We have to tell systemd to allow gpsd to hear other interfaces. We run <code><a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#edit%20UNIT%E2%80%A6" >systemctl edit --full gpsd.socket</a></code>. Then we can edit it. After editing, the [Socket] stanza looks like so:</p>
  445. <pre>
  446. [Socket]
  447. ListenStream=@RUNDIR/gpsd.sock
  448. ListenStream=[::1]:2947
  449. # ListenStream=127.0.0.1:2947
  450. ListenStream=0.0.0.0:2947
  451. SocketMode=0600
  452. </pre>
  453. <p>When you are done editing, systemctl does what it needs to do internally to preserve your changes from being over-written during upgrades. It also does the equivalent of a <code>systemctl daemon-reload</code> for you.</p>
  454. <p>We now restart both gpsd units like so:</p>
  455. <pre><a href="https://www.freedesktop.org/software/systemd/man/systemctl.html#restart%20PATTERN%E2%80%A6" >systemctl restart</a> gpsd.socket gpsd.service</pre>
  456. <p>Now check with a local client, and a client on the remote computer:</p>
  457. <pre>xgps &lt;host&gt;</pre>
  458. <p>Where &lt;host&gt; in our example is orca. As usual, if you see data in the client, you're done.</p>
  459. <hr>
  460. <script src="datestamp.js"></script>
  461. </div>
  462. </body>
  463. </html>