Add a GNSS simulator for dev without gpsd running
bin/gnss_simulator.rb speaks gpsd's own JSON wire protocol directly on its default port -- GpsdClient connects to it exactly as it would to real gpsd, no app changes needed, and no gpsd install/daemon required either (unlike the existing fake-NMEA-source approach in docs/development.adoc, which still needs gpsd itself in front of it). Drives a loop around a center point at a driving-ish pace rather than sitting still, since a fixed position isn't much of a "GNSS position" to look at. Verified end to end: started it, pointed a dev server at it, and confirmed /api/gnss/position reports a moving fix across two polls.
This commit is contained in:
1 parent
4aafe332a7
commit
61ba86c6e6
3 files changed
+95
-4
No files matched your search
+22
-3
@@ -52,9 +52,28 @@ up as). On openSUSE, `gpsd` is a package with systemd units
|
||||
package manager. No app-side configuration is needed — it just
|
||||
connects to `127.0.0.1:2947`, gpsd's default port.
|
||||
|
||||
To test without hardware, feed gpsd a fake NMEA stream over TCP
|
||||
instead of a real serial device — gpsd accepts a `tcp://host:port`
|
||||
source:
|
||||
To test without hardware or gpsd itself installed/running, run
|
||||
`bin/gnss_simulator.rb` — it speaks gpsd's own JSON wire protocol
|
||||
directly on gpsd's default port (`127.0.0.1:2947`), so
|
||||
`Maptool::GpsdClient` connects to it exactly as it would to real
|
||||
gpsd, no app-side changes needed. Drives a loop around a center point
|
||||
(Bratislava by default) at a driving-ish pace instead of sitting at a
|
||||
fixed position, since a stationary "GNSS position" isn't much to look
|
||||
at on the map:
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
bin/gnss_simulator.rb # loop around Bratislava, 300m radius
|
||||
bin/gnss_simulator.rb 48.85 2.35 500 # custom center/radius (Paris, 500m)
|
||||
----
|
||||
|
||||
`GET /api/gnss/position` should report a fix within a couple of
|
||||
seconds, moving on every poll.
|
||||
|
||||
To test against gpsd itself instead (e.g. to exercise the actual
|
||||
NMEA-parsing path, not just gpsd's JSON output), feed it a fake NMEA
|
||||
stream over TCP instead of a real serial device — gpsd accepts a
|
||||
`tcp://host:port` source:
|
||||
|
||||
[source,shell]
|
||||
----
|
||||
|
||||
Reference in new issue
Block a user