gpsd.adoc 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. = gpsd(8)
  2. :date: 12 November 2021
  3. :keywords: gps, gpsd, gnss
  4. :manmanual: GPSD Documentation
  5. :mansource: GPSD, Version {gpsdver}
  6. :robots: index,follow
  7. :sectlinks:
  8. :toc: macro
  9. :type: manpage
  10. :webfonts!:
  11. include::../www/inc-menu.adoc[]
  12. == NAME
  13. gpsd - interface daemon for GPS receivers
  14. == SYNOPSSIS
  15. *gpsd* [OPTIONS]
  16. *gpsd* -h
  17. *gpsd* -V
  18. == QUICK START
  19. If you have a GPS attached on the lowest-numbered USB port of a Linux
  20. system, and want to read reports from it on TCP/IP port 2947, it will
  21. normally suffice to do this, as root:
  22. ----
  23. # gpsd /dev/ttyUSB0
  24. ----
  25. For the lowest-numbered serial port:
  26. ----
  27. # gpsd /dev/ttyS0
  28. ----
  29. *gpsd* may be started as a normal user, or by using sudo, but some
  30. functionality will be lost.
  31. Change the device number as appropriate if you need to use a different
  32. port. Command-line flags enable verbose logging, a control port, and
  33. other optional extras but should not be needed for basic operation; the
  34. one exception, on very badly designed hardware, might be *-b* (which
  35. see).
  36. On Linux systems supporting udev, *gpsd* is normally started automatically
  37. when a USB plugin event fires (if it is not already running) and is
  38. handed the name of the newly active device. In that case no invocation
  39. is required at all.
  40. For your initial tests set your GPS hardware to speak NMEA, as *gpsd* is
  41. guaranteed to be able to process that. If your GPS has a native or
  42. binary mode with better performance that *gpsd* knows how to speak, *gpsd*
  43. may autoconfigure that mode.
  44. You can verify correct operation by first starting *gpsd*. Then *xgps*,
  45. the X windows test client or *cgps* the curses based terminal client.
  46. If you have problems, the GPSD project maintains a FAQ to assist
  47. troubleshooting.
  48. == DESCRIPTION
  49. *gpsd* is a monitor daemon that collects information from GPSes,
  50. differential-GPS radios, or AIS receivers attached to the host machine.
  51. Each GPS, DGPS radio, or AIS receiver is expected to be directly
  52. connected to the host via a USB or RS232C serial device. The serial
  53. device may be specified to *gpsd* at startup, or it may be set via a
  54. command shipped down a local control socket (e.g. by a USB hotplug
  55. script). Given a GPS device by either means, *gpsd* discovers the
  56. correct port speed and protocol for it.
  57. *gpsd* should be able to query any GPS that speaks either the standard
  58. textual NMEA 0183 protocol, or the (differing) extended NMEA dialects
  59. used by MKT-3301, iTrax, Motorola OnCore, Sony CXD2951, Ashtech/Thales
  60. and some other devices. It can also interpret the binary protocols used
  61. by EverMore, Garmin, Javad, Navcom, Rockwell/Zodiac, SiRF, Trimble, and
  62. u-blox devices. Under Linux it can read NMEA2000 packets through the
  63. kernel CAN socket. It can read heading and attitude information from the
  64. Oceanserver 5000 or TNT Revolution digital compasses.
  65. The GPS reporting formats supported by your binary of *gpsd* may differ
  66. depending on how it was compiled; general-purpose versions support many,
  67. but it can be built with protocol subsets down to a singleton for use in
  68. constrained environments. For a list of the GPS protocols supported by
  69. your binary, see the output of *gpsd -l*
  70. *gpsd* effectively hides the differences among the GPS types it supports.
  71. It also knows about and uses commands that tune these GPSes for lower
  72. latency. By using *gpsd* as an intermediary, applications avoid contention
  73. for serial devices.
  74. *gpsd* can use differential-GPS corrections from a DGPS radio or over
  75. the net, from a ground station running a DGPSIP server or a Ntrip
  76. broadcaster that reports RTCM-104 data; this may shrink position errors.
  77. When *gpsd* opens a serial device emitting RTCM-104, it automatically
  78. recognizes this and uses the device as a correction source for all
  79. connected GPSes that accept RTCM corrections (this is dependent on the
  80. type of the GPS; not all GPSes have the firmware capability to accept
  81. RTCM correction packets).
  82. Client applications typically communicate with *gpsd* via a TCP/IP port,
  83. port 2947 by default. Both IPv4 and IPv6 connections are supported and a
  84. client may connect via either.
  85. == OPTIONS
  86. The program accepts the following options:
  87. *-?*, *-h*, *---help*::
  88. Display help message and terminate.
  89. *-b*, *--readonly*::
  90. Broken-device-safety mode, otherwise known as read-only mode. A few
  91. bluetooth and USB receivers lock up or become totally inaccessible
  92. when probed or reconfigured; see the hardware compatibility list on
  93. the GPSD project website for details. This switch prevents *gpsd* from
  94. writing to a receiver. This means that *gpsd* cannot configure the
  95. receiver for optimal performance, but it also means that *gpsd* cannot
  96. break the receiver. A better solution would be for Bluetooth to not be
  97. so fragile. A platform independent method to identify
  98. serial-over-Bluetooth devices would also be nice.
  99. *-D LVL*, *--debug LVL*::
  100. Set debug level. Default is 0. At debug levels 2 and above, *gpsd*
  101. reports incoming sentence and actions to standard error if *gpsd* is in
  102. the foreground (*-N*) or to syslog if in the background. See <<LOGGING>>
  103. below.
  104. *-F FILE*, *--sockfile FILE*::
  105. Create a control socket for device addition and removal commands.
  106. Default is None. You must specify a valid pathname on your local
  107. filesystem; this will be created as a Unix-domain socket to which you
  108. can write commands that edit the daemon's internal device list.
  109. *-f FRAME*, *--framing FRAME*::
  110. Fix the framing to the GNSS device. The framing parameter is of the
  111. form: [78][ENO][012]. Most GNSS are 8N1. Some Trimble default to 8O1.
  112. The default is to search for the correct framing.
  113. *-G*, *--listenany*::
  114. This flag causes *gpsd* to listen on all addresses (INADDR_ANY) rather
  115. than just the loop back (INADDR_LOOPBACK) address. For the sake of
  116. privacy and security, *gpsd* information is private by default to the
  117. local machine until the user makes an effort to expose this to the
  118. world.
  119. *-l*, *--drivers*::
  120. List all drivers compiled into this *gpsd* instance. The letters to the
  121. left of each driver name are the *gpsd* control commands supported by
  122. that driver. Then exit.
  123. *-n*, *--nowait*::
  124. Don't wait for a client to connect before polling whatever GPS is
  125. associated with it. Some RS232 GPSes wait in a standby mode (drawing
  126. less power) when the host machine is not asserting DTR, and some
  127. cellphone and handheld embedded GPSes have similar behaviors.
  128. Accordingly, waiting for a watch request to open the device may save
  129. battery power. (This capability is rare in consumer-grade devices).
  130. You should use this option if you plan to use *gpsd* to provide
  131. reference clock information to ntpd or chronyd. This option will also
  132. enable clients to see data from the receiver sooner on connection.
  133. *-N*, *--foreground*::
  134. Don't daemonize; run in foreground. This switch is mainly useful for
  135. debugging.
  136. *-p*, *--passive*::
  137. Passive mode. Do not autoconfigure the receiver, but allow manual
  138. configuration changes.
  139. *-P FILE*, *--pidfile FILE*::
  140. Specify the name and path to record the daemon's process ID.
  141. *-r*, *--badtime*::
  142. Use GPS time even with no current fix. Some GPSs have battery powered
  143. Real Time Clocks (RTC's) built in, making them a valid time source
  144. even before a fix is acquired. This can be useful on a Raspberry Pi,
  145. or other device that has no battery powered RTC, and thus has no valid
  146. time at startup. Use with caution.
  147. *--port PORT*, *-S PORT*::
  148. Set TCP/IP port on which to listen for GPSD clients (default is 2947).
  149. *-s SPEED*, *--speed SPEED*::
  150. Fix the serial port speed to the GNSS device. Allowed speeds are:
  151. 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800 and 921600. The
  152. default is to autobaud. Note that some devices with integrated USB
  153. ignore port speed.
  154. *-V*, *--version*::
  155. Dump version and exit.
  156. Arguments are interpreted as the names of data sources. Normally, a data
  157. source is the device pathname of a local device from which the daemon
  158. may expect GPS data. But there are three other special source types
  159. recognized, for a total of four:
  160. Local serial or USB device::
  161. A normal Unix device name of a serial or USB device to which a sensor
  162. is attached. Examples: */dev/ttyS0*, or */dev/ttyUSB0*.
  163. Local PPS device::
  164. A normal Unix device name of a PPS device to which a PPS source is
  165. attached. The device name must start with "/dev/pps" and a local
  166. serial or USB GPS device must also be available. Example:
  167. */dev/pps0*.
  168. TCP feed::
  169. A URI with the prefix "tcp://", followed by a hostname, a colon, and a
  170. port number. The daemon will open a socket to the indicated address
  171. and port and read data packets from it, which will be interpreted as
  172. though they had been issued by a serial device. Example:
  173. *tcp://data.aishub.net:4006*.
  174. UDP feed::
  175. A URI with the prefix "udp://", followed by a hostname, a colon, and a
  176. port number. The daemon will open a socket listening for UDP datagrams
  177. arriving in the indicated address and port, which will be interpreted
  178. as though they had been issued by a serial device. Example:
  179. *udp://127.0.0.1:5000*.
  180. Ntrip caster::
  181. A URI with the prefix "ntrip://" followed by the name of an Ntrip
  182. caster (Ntrip is a protocol for broadcasting differential-GPS fixes
  183. over the net). For Ntrip services that require authentication, a
  184. prefix of the form "username:password@" can be added before the name
  185. of the Ntrip broadcaster. For Ntrip service, you must specify which
  186. stream to use; the stream is given in the form "/streamname". An
  187. example DGPSIP URI could be "dgpsip://dgpsip.example.com" and a Ntrip
  188. URI could be "ntrip://foo:bar@ntrip.example.com:80/example-stream".
  189. Corrections from the caster will be sent to each attached GPS with the
  190. capability to accept them.
  191. DGPSIP server::
  192. A URI with the prefix "dgpsip://" followed by a hostname, a colon, and
  193. an optional colon-separated port number (defaulting to 2101). The
  194. daemon will handshake with the DGPSIP server and read RTCM2 correction
  195. data from it. Corrections from the server will be set to each attached
  196. GPS with the capability to accept them. Example:
  197. *dgpsip://dgps.wsrcc.com:2101*.
  198. Remote gpsd feed::
  199. A URI with the prefix "gpsd://", followed by a hostname and optionally
  200. a colon and a port number (if the port is absent the default *gpsd* port
  201. will be used). Then followed optionally by a second colon and the
  202. remote device name The daemon will open a socket to the indicated
  203. address and port and emulate a *gpsd* client, collecting JSON reports
  204. from the remote *gpsd* instance that will be passed to local clients.
  205. Example: *gpsd://gpsd.io:2947:/dev/ttyAMA0*.
  206. NMEA2000 CAN data::
  207. A URI with the prefix "nmea2000://", followed by a CAN devicename.
  208. Only Linux socket CAN interfaces are supported. The interface must be
  209. configured to receive CAN messages before *gpsd* can be started. If
  210. there is more than one unit on the CAN bus that provides GPS data,
  211. *gpsd* chooses the unit from which a GPS message is first seen. Example:
  212. *nmea2000://can0*.
  213. (The "ais:://" source type supported in some older versions of the
  214. daemon has been retired in favor of the more general "tcp://".)
  215. Additionally, two serial device name have a side effect, if your
  216. binary was compiled with the MAGIC_HAT option:
  217. /dev/ttyAMA0::
  218. The UART device on a Raspberry Pi. Has the side effect of opening
  219. /dev/pps0 for RFC2783 1PPS data.
  220. /dev/gpsd0::
  221. Generic GPS device 0. Has the side effect of opening /dev/pps0 for
  222. RFC2783 1PPS data.
  223. Note, however, that if /dev/pps0 is the fake "ktimer" PPS, then
  224. /dev/pps1 will be used instead.
  225. Internally, the daemon maintains a device pool holding the pathnames of
  226. devices and remote servers known to the daemon. Initially, this list is
  227. the list of device-name arguments specified on the command line. That
  228. list may be empty, in which case the daemon will have no devices on its
  229. search list until they are added by a control-socket command. Daemon
  230. startup will abort with an error if no devices and no control socket is
  231. specified.
  232. When a device is activated (i.e. a client requests data from it), *gpsd*
  233. attempts to execute a hook from */etc/gpsd/device-hook* with first
  234. command line argument set to the pathname of the device and the second
  235. to *ACTIVATE*. On deactivation, it does the same passing
  236. *DEACTIVATE* for the second argument.
  237. *gpsd* can export data to client applications in three ways: via a sockets
  238. interface, via a shared-memory segment, and via D-Bus. The next three
  239. major sections describe these interfaces.
  240. == LOGGING
  241. When *gpsd* is running as a daemon (not in the foreground) is sends
  242. all of its logging to *syslog*(3). Logging is sent with ident "gpsd"
  243. using facility "LOG_USER".
  244. If you are using syslog-ng, then you can send all *gpsd*
  245. logs to a file */var/log/gpsd*. Put this at the end of your
  246. */etc/syslog-ng/syslog-ng.conf* file:
  247. ----
  248. destination gpsdf { file("/var/log/gpsd"); };
  249. filter f_gpsd { program("gpsd"); };
  250. log { source(src); filter(f_gpsd); destination(gpsdf); };
  251. ----
  252. == THE SOCKET INTERFACE
  253. Clients may communicate with the daemon via textual request and
  254. responses over a socket. It is a bad idea for applications to speak the
  255. protocol directly: rather, they should use the libgps client library and
  256. take appropriate care to conditionalize their code on the major and
  257. minor protocol version symbols.
  258. The request-response protocol for the socket interface is fully
  259. documented in gpsd_json(5).
  260. == SHARED-MEMORY AND DBUS INTERFACES
  261. *gpsd* has two other (read-only) interfaces.
  262. Whenever the daemon recognizes a packet from any attached device, it
  263. writes the accumulated state from that device to a shared memory
  264. segment. The C and C++ client libraries shipped with GPSD can read this
  265. segment. Client methods, and various restrictions associated with the
  266. read-only nature of this interface, are documented at libgps(3). The
  267. shared-memory interface is intended primarily for embedded deployments
  268. in which *gpsd* monitors a single device, and its principal advantage is
  269. that a daemon instance configured with shared memory but without the
  270. sockets interface loses a significant amount of runtime weight.
  271. The daemon may be configured to emit a D-Bus signal each time an
  272. attached device delivers a fix. The signal path is "path /org/gpsd", the
  273. signal interface is "org.gpsd", and the signal name is "fix". The signal
  274. payload layout is as follows:
  275. .Satellite object
  276. [cols=",",options="header",]
  277. |===
  278. |Type |Description
  279. |DBUS_TYPE_DOUBLE |Time (seconds since Unix epoch)
  280. |DBUS_TYPE_INT32 |mode
  281. |DBUS_TYPE_DOUBLE |Time uncertainty (seconds).
  282. |DBUS_TYPE_DOUBLE |Latitude in degrees.
  283. |DBUS_TYPE_DOUBLE |Longitude in degrees.
  284. |DBUS_TYPE_DOUBLE |Horizontal uncertainty in meter.
  285. |DBUS_TYPE_DOUBLE |Altitude MSL in meters.
  286. |DBUS_TYPE_DOUBLE |Altitude uncertainty in meters.
  287. |DBUS_TYPE_DOUBLE |Course in degrees from true north.
  288. |DBUS_TYPE_DOUBLE |Course uncertainty in meters
  289. |DBUS_TYPE_DOUBLE |Speed, meters per second.
  290. |DBUS_TYPE_DOUBLE |Speed uncertainty in meters per second.
  291. |DBUS_TYPE_DOUBLE |Climb, meters per second.
  292. |DBUS_TYPE_DOUBLE |Climb uncertainty in meters per second.
  293. |DBUS_TYPE_STRING |Device name
  294. |===
  295. Uncertainty values are provided by the GNSS receiver. Check your
  296. receiver documentation to see if is specifies what its "uncertainty"
  297. means.
  298. == GPS DEVICE MANAGEMENT
  299. *gpsd* maintains an internal list of GPS devices (the "device pool"). If
  300. you specify devices on the command line, the list is initialized with
  301. those pathnames, otherwise the list starts empty. Commands to add and
  302. remove GPS device paths from the daemon's device list must be written to
  303. a local Unix-domain socket which will be accessible only to programs
  304. running as root. This control socket will be located wherever the *-F*
  305. option specifies it.
  306. A device may will also be dropped from the pool if GPSD gets a zero
  307. length read from it. This end-of-file condition indicates that the
  308. device has been disconnected.
  309. When *gpsd* is installed along with working hotplug notifier scripts
  310. feeding it device-add commands over the control socket, *gpsd* should
  311. require no configuration or user action to find hotplug devices.
  312. Sending SIGHUP to a running *gpsd* forces it to close all GPSes and all
  313. client connections. It will then attempt to reconnect to any GPSes on
  314. its device list and resume listening for client connections. This may be
  315. useful if your GPS enters a wedged or confused state but can be
  316. soft-reset by pulling down DTR.
  317. When *gpsd* is called with no initial devices (thus, expecting devices
  318. to be passed to it by notifications to the control socket), and reaches
  319. a state where there are no devices connected and no subscribers after
  320. some devices have been seen, it shuts down gracefully. It is expected
  321. that future device hotplug events will reactivate it.
  322. To point *gpsd* at a device that may be a GPS, write to the control socket
  323. a plus sign ('\+') followed by the device name followed by LF or CR-LF.
  324. Thus, to point the daemon at */dev/foo*. send "+/dev/foo\n". To tell
  325. the daemon that a device has been disconnected and is no longer
  326. available, send a minus sign ('-') followed by the device name followed
  327. by LF or CR-LF. Thus, to remove */dev/foo* from the search list, send
  328. "-/dev/foo\n".
  329. To send a control string to a specified device, write to the control
  330. socket a '!', followed by the device name, followed by '=', followed by
  331. the control string.
  332. To send a binary control string to a specified device, write to the
  333. control socket a '&', followed by the device name, followed by '=',
  334. followed by the control string in paired hex digits.
  335. Your client may await a response, which will be a line beginning with
  336. either "OK" or "ERROR". An ERROR response to an 'add' command means the
  337. device did not emit data recognizable as GPS packets, an ERROR response
  338. to a remove command means the specified device was not in *gpsd*'s device
  339. pool. An ERROR response to a '!' command means the daemon did not
  340. recognize the devicename specified.
  341. The control socket is intended for use by hotplug scripts and other
  342. device-discovery services. This control channel is separate from the
  343. public *gpsd* service port, and only locally accessible, in order to
  344. prevent remote denial-of-service and spoofing attacks.
  345. == ACCURACY
  346. The base User Estimated Range Error (UERE) of GPSes is 8 meters or less
  347. at 66% confidence, 15 meters or less at 95% confidence. Actual
  348. horizontal error will be UERE times a dilution factor dependent on
  349. current satellite position. Altitude determination is more sensitive to
  350. variability in ionospheric signal lag than latitude/longitude is, and is
  351. also subject to errors in the estimation of local mean sea level, base
  352. error is 12 meters at 66% confidence, 23 meters at 95% confidence.
  353. Again, this will be multiplied by a vertical dilution of precision
  354. (VDOP) dependent on satellite geometry, and VDOP is typically larger
  355. than HDOP. Users should _not_ rely on GPS altitude for life-critical
  356. tasks such as landing an airplane.
  357. These errors are intrinsic to the design and physics of the GPS system.
  358. *gpsd* does its internal computations at sufficient accuracy that it will
  359. add no measurable position error of its own.
  360. DGPS correction may reduce UERE, provided you are within about 100
  361. miles (160 km) of a DGPS ground station from which you are receiving
  362. corrections.
  363. On a 4800bps connection, the time latency of fixes provided by *gpsd* will
  364. be one second or less 95% of the time. Most of this lag is due to the
  365. fact that GPSes normally emit fixes once per second, thus expected
  366. latency is 0.5sec. On the personal-computer hardware available in 2005
  367. and later, computation lag induced by *gpsd* will be negligible, on the
  368. order of a millisecond. Nevertheless, latency can introduce significant
  369. errors for vehicles in motion, at 50 km/h (31 mi/h) of speed over
  370. ground, 1 second of lag corresponds to 13.8 meters change in position
  371. between updates.
  372. The time reporting of the GPS system itself has an intrinsic accuracy
  373. limit of 14 nanoseconds, but this can only be approximated by
  374. specialized receivers using that send the high-accuracy PPS
  375. (Pulse-Per-Second) over RS232 to cue a clock crystal. Most GPS receivers
  376. only report time to a precision of 0.01s or 0.001s, and with no accuracy
  377. guarantees below 1sec.
  378. If your GPS uses a SiRF chipset at firmware level 231, reported UTC time
  379. may be off by the difference between whatever default leap-second offset
  380. has been compiled in and whatever leap-second correction is currently
  381. applicable, from startup until complete subframe information is
  382. received. Firmware levels 232 and up don't have this problem. You may
  383. run *gpsd* at debug level 4 to see the chipset type and firmware revision
  384. level.
  385. There are exactly two circumstances under which *gpsd* relies on the
  386. host-system clock:
  387. In the GPS broadcast signal, GPS time is represented using a week number
  388. that rolls over after 2^10 or 2^13 weeks (about 19.6 years, or 157
  389. years), depending on the spacecraft. Receivers are required to
  390. disambiguate this to the correct date, but may have difficulty due to
  391. not knowing time to within half this interval, or may have bugs. Users
  392. have reported incorrect dates which appear to be due to this issue. *gpsd*
  393. uses the startup time of the daemon detect and compensate for rollovers
  394. while it is running, but otherwise reports the date as it is reported by
  395. the receiver without attempting to correct it.
  396. If you are using an NMEA-only GPS (that is, not using SiRF or Garmin or
  397. Zodiac binary mode), *gpsd* relies on the system clock to tell it the
  398. current century. If the system clock returns an invalid value near zero,
  399. and the GPS does not emit GPZDA at the start of its update cycle (which
  400. most consumer-grade NMEA GPSes do not) then the century part of the
  401. dates *gpsd* delivers may be wrong. Additionally, near the century
  402. turnover, a range of dates as wide in seconds as the accuracy of your
  403. system clock may be referred to the wrong century.
  404. [[ntp]]
  405. == USE WITH NTP
  406. *gpsd* can provide reference clock information to ntpd or chronyd, to
  407. keep the system clock synchronized to the time provided by the GPS
  408. receiver.
  409. On Linux, *gpsd* includes support for interpreting the PPS pulses emitted
  410. at the start of every clock second on the carrier-detect lines of some
  411. serial GPSes, this pulse can be used to update NTP at much higher
  412. accuracy than message time provides. You can determine whether your GPS
  413. emits this pulse by running at *-D 5* and watching for carrier-detect
  414. state change messages in the logfile. In addition, if your kernel
  415. provides the RFC 2783 kernel PPS API then *gpsd* will use that for extra
  416. accuracy.
  417. *gpsd* communicates with *ntpd* using shared memory segments (SHMs).
  418. The SHMs are numbered SHM(0) to SHM(7). and have a name (key) of
  419. NTP0 to NTP7. The first local time source on the command line may
  420. use NTP0 and NTP1. The second may use NTP2 and NTP3, etc.
  421. You can see the output of *gpsd* to *ntpd* in real time with the
  422. *ntpshmmon* command.
  423. Other daemons, such as *ptp4l* may also be using the same SHMs to
  424. talk to *ntpd*.
  425. Detailed instructions for using GPSD to set up a high-quality time
  426. service can be found among the documentation on the GPSD website.
  427. [[dbus]]
  428. == USE WITH D-BUS
  429. On operating systems that support D-BUS, *gpsd* can be built to broadcast
  430. GPS fixes to D-BUS-aware applications. As D-BUS is still at a pre-1.0
  431. stage, we will not attempt to document this interface here. Read the
  432. *gpsd* source code to learn more.
  433. [[security]]
  434. == SECURITY AND PERMISSIONS ISSUES
  435. *gpsd*, if given the -G flag, will listen for connections from any
  436. reachable host, and then disclose the current position. Before using the
  437. -G flag, consider whether you consider your computer's location to be
  438. sensitive data to be kept private or something that you wish to publish.
  439. *gpsd* must start up as root in order to open the NTPD shared-memory
  440. segment, open its logfile, and create its local control socket.
  441. Note that starting gpsd with sudo is not the same as starting as
  442. root. Before doing any processing of GPS data, it tries to drop root
  443. privileges by setting its UID to "nobody" (or another configured userid)
  444. and its group ID to the group of the initial GPS passed on the command
  445. line -- or, if that device doesn't exist, to the group of */dev/ttyS0*.
  446. Privilege-dropping is a hedge against the possibility that carefully
  447. crafted data, either presented from a client socket or from a subverted
  448. serial device posing as a GPS, could be used to induce misbehavior in
  449. the internals of *gpsd*. It ensures that any such compromises cannot be
  450. used for privilege elevation to root.
  451. The assumption behind *gpsd*'s particular behavior is that all the tty
  452. devices to which a GPS might be connected are owned by the same non-root
  453. group and allow group read/write, though the group may vary because of
  454. distribution-specific or local administrative practice. If this
  455. assumption is false, *gpsd* may not be able to open GPS devices in order
  456. to read them (such failures will be logged).
  457. In order to fend off inadvertent denial-of-service attacks by port
  458. scanners (not to mention deliberate ones), *gpsd* will time out inactive
  459. client connections. Before the client has issued a command that requests
  460. a channel assignment, a short timeout (60 seconds) applies. There is no
  461. timeout for clients in watcher or raw modes; rather, *gpsd* drops these
  462. clients if they fail to read data long enough for the outbound socket
  463. write buffer to fill. Clients with an assigned device in polling mode
  464. are subject to a longer timeout (15 minutes).
  465. == LIMITATIONS
  466. If multiple NMEA talkers are feeding RMC, GLL, and GGA sentences to the
  467. same serial device (possible with an RS422 adapter hooked up to some
  468. marine-navigation systems), a 'TPV' response may mix an altitude from
  469. one device's GGA with latitude/longitude from another's RMC/GLL after
  470. the second sentence has arrived.
  471. *gpsd* may change control settings on your GPS (such as the emission
  472. frequency of various sentences or packets) and not restore the original
  473. settings on exit. This is a result of inadequacies in NMEA and the
  474. vendor binary GPS protocols, which often do not give clients any way to
  475. query the values of control settings in order to be able to restore them
  476. later.
  477. Some receivers do not report VDOP/TDOP/GDOP figures and associated error
  478. estimates. In that case they may be computed by *gpsd* instead. This
  479. computation does not exactly match what chips do internally, which
  480. includes some satellite weighting using parameters *gpsd* cannot see.
  481. Autobauding on the Trimble GPSes can take as long as 20 seconds, or
  482. more, if the device speed is not matched to the GPS speed. Use the
  483. *-s* option to avoid autobaud delays.
  484. Generation of position error estimates (eph, epv, epd, eps, epc) from
  485. the incomplete data handed back by GPS reporting protocols involves both
  486. a lot of mathematical black art and fragile device-dependent
  487. assumptions. This code has been bug-prone in the past and problems may
  488. still lurk there.
  489. AIDVM decoding of types 16-17, 22-23, and 25-26 is unverified.
  490. GPSD presently fully recognizes only the 2.1 level of RTCM2 (message
  491. types 1, 3, 4, 5, 6, 7, 9, 16). The 2.3 message types 13, 14, and 31 are
  492. recognized and reported. Message types 8, 10-12, 15-27, 28-30
  493. (undefined), 31-37, 38-58 (undefined), and 60-63 are not yet supported.
  494. The ISGPS used for RTCM2 and subframes decoder logic is sufficiently
  495. convoluted to confuse some compiler optimizers, notably in GCC 3.x at
  496. -O2, into generating bad code.
  497. Devices meant to use PPS for high-precision timekeeping may fail if they
  498. are specified after startup by a control-socket command, as opposed to
  499. on the daemon's original command line. Root privileges are dropped
  500. early, and some Unix variants require them in order to set the PPS line
  501. discipline. Under Linux the POSIX capability to set the line discipline
  502. is retained, but other platforms cannot use this code.
  503. USB GPS devices often do not identify themselves through the USB
  504. subsystem; they typically present as the class 00h (undefined) or class
  505. FFh (vendor-specific) of USB-to-serial adapters. Because of this, the
  506. Linux hotplug scripts must tell *gpsd* to sniff data from every
  507. USB-to-serial adapter that goes active and is known to be of a type used
  508. in GPSes. No such device is sent configuration strings until after it
  509. has been identified as a GPS, and *gpsd* never opens a device that is
  510. opened by another process. But there is a tiny window for non-GPS
  511. devices not opened; if the application that wants them loses a race with
  512. GPSD its device open will fail and have to be retried after GPSD sniffs
  513. the device (normally less than a second later).
  514. == FILES
  515. */dev/ttyS0*::
  516. Prototype TTY device. After startup, *gpsd* sets its group ID to the
  517. owning group of this device if no GPS device was specified on the
  518. command line does not exist.
  519. */etc/gpsd/device-hook*::
  520. Optional file containing the device activation/deactivation script.
  521. Note that while */etc/gpsd* is the default system configuration
  522. directory, it is possible to build the GPSD source code with different
  523. assumptions. See above for further details on the device-hook
  524. mechanism.
  525. == ENVIRONMENT VARIABLES
  526. By setting the environment variable *GPSD_SHM_KEY*, you can control
  527. the key value used to create the shared-memory segment used for
  528. communication with the client library. This will be useful mainly when
  529. isolating test instances of *gpsd* from production ones.
  530. == RETURN VALUES
  531. *0*:: on success.
  532. *1*:: on failure
  533. == APPLICABLE STANDARDS
  534. The official NMEA protocol standards for NMEA0183 and NMEA2000 are
  535. available from the National Marine Electronics Association, but are
  536. proprietary and expensive; the maintainers of *gpsd* have made a point of
  537. not looking at them. The GPSD project website links to several documents
  538. that collect publicly disclosed information about the protocol.
  539. *gpsd* parses the following NMEA sentences: RMC, GGA, GLL, GSA, GSV, VTG,
  540. ZDA, GBS, HDT, DBT, GST. It recognizes these with either the normal GP
  541. talker-ID prefix, or with the GN prefix used by GLONASS, or with the II
  542. prefix emitted by Seahawk Autohelm marine navigation systems, or with
  543. the IN prefix emitted by some Garmin units, or with the EC prefix
  544. emitted by ECDIS units, or with the SD prefix emitted by depth sounders,
  545. or with the HC and TI prefix emitted by some Airmar equipment. It
  546. recognizes some vendor extensions: the PGRME emitted by some Garmin GPS
  547. models, the OHPR emitted by Oceanserver digital compasses, the PTNTHTM
  548. emitted by True North digital compasses, the PMTK omitted by some San
  549. Jose Navigation GPSes, and the PASHR sentences emitted by some Ashtech
  550. GPSes.
  551. Note that *gpsd* JSON returns pure decimal degrees, not the hybrid
  552. degree/minute format described in the NMEA standard.
  553. Differential-GPS corrections are conveyed by the RTCM protocols. The
  554. applicable standard for RTCM-104 V2 is RTCM Recommended Standards for
  555. Differential GNSS (Global Navigation Satellite) Service RTCM Paper
  556. 136-2001/SC 104-STD. The applicable standard for RTCM-104 V3 is RTCM
  557. Standard 10403.1 for Differential GNSS Services - Version 3 RTCM Paper
  558. 177-2006-SC104-STD. Ordering instructions for the RTCM standards are
  559. accessible from the website of the Radio Technical Commission for
  560. Maritime Services under "Publications".
  561. AIS is defined by ITU Recommendation M.1371, Technical Characteristics
  562. for a Universal Shipborne Automatic Identification System Using Time
  563. Division Multiple Access. The AIVDM/AIVDO format understood by this
  564. program is defined by IEC-PAS 61162-100, Maritime navigation and
  565. radiocommunication equipment and systems. A more accessible description
  566. of both can be found at AIVDM/AIVDO Protocol Decoding, on the references
  567. page of the GPSD project website.
  568. Subframe data is defined by IS-GPS-200, GLOBAL POSITIONING SYSTEM WING
  569. (GPSW) SYSTEMS ENGINEERING & INTEGRATION, INTERFACE SPECIFICATION
  570. IS-GPS-200. The format understood by this program is defined
  571. in Section 20 (Appendix II),
  572. JSON is specified by RFC 7159, The JavaScript Object Notation (JSON)
  573. Data Interchange Format.
  574. The API for PPS time service is specified by RFC 2783, Pulse-Per-Second
  575. API for UNIX-like Operating Systems, Version 1.0
  576. == AUTHORS
  577. Authors: Eric S. Raymond, Chris Kuethe, Gary Miller. Former authors
  578. whose bits have been plowed under by code turnover: Remco Treffcorn,
  579. Derrick Brashear, Russ Nelson.
  580. This manual page by Eric S. Raymond <esr@thyrsus.com>.
  581. == SEE ALSO
  582. *gpsd*(8), *gpsctl*(1), *gps*(1), *gpsprof*(1), *gpsfake*(1). *gpscat(1),
  583. *ntpshmmon*(1), *libgps*(3), *libgpsmm*(3), *gpsd_json*(5), *gpsdctl*(8),
  584. *ntpd*(8)
  585. == RESOURCES
  586. *Project web site:* {gpsdweb}
  587. *GPSD Time Service HOWTO:* {gpsdweb}gpsd-time-service-howto.html
  588. *Introduction to Time Service:* {gpsdweb}time-service-intro.html
  589. == COPYING
  590. This file is Copyright 2013 by the GPSD project +
  591. SPDX-License-Identifier: BSD-2-clause