Skip to main content

rf-bench-drivers-gpsd

gpsd client driver for the rf-bench bench automation framework.

Connects to a running gpsd daemon over its JSON/TCP protocol and exposes GPS position, speed, altitude, heading, and fix quality. Both metric and imperial units are provided. A background thread maintains the connection and auto-reconnects with exponential back-off on any failure or data stall.

Requirements

  • Python ≥ 3.9
  • gpsd running and accessible (default: localhost:2947)
  • No additional Python dependencies — uses stdlib socket, json, threading only

Installation

pip install rf-bench-drivers-gpsd

Or as part of the full rf-bench suite:

pip install rf-bench

Quick start

from rf_bench.gpsd import GPSD, GPSDNoFixError

with GPSD() as gps:
    # Block until 2D fix (or raise GPSDNoFixError after 30 s)
    fix = gps.wait_for_fix(timeout=30)
    print(f"Position : {fix.latitude:.6f}, {fix.longitude:.6f}")
    print(f"Altitude : {fix.altitude_m:.1f} m  /  {fix.altitude_ft:.0f} ft")
    print(f"Speed    : {fix.speed_kmh:.1f} km/h  /  {fix.speed_knots:.1f} kn  /  {fix.speed_mph:.1f} mph")
    print(f"Heading  : {fix.heading}°")
    print(f"Fix mode : {fix.fix_mode}  (sats used: {fix.satellites_used})")
    print(f"HDOP     : {fix.hdop}  VDOP: {fix.vdop}  PDOP: {fix.pdop}")

API

GPSD(host='localhost', port=2947, stale_timeout=10, reconnect_delay=2, max_reconnect_delay=60)

The main driver class. Spawns a background daemon thread on construction.

Method / property Description
get_fix() Return a GPSFix snapshot (non-blocking, may have no fix)
wait_for_fix(timeout=30, require_3d=False) Block until fix; raises GPSDNoFixError on timeout
is_connected True while TCP socket to gpsd is open
is_stale True if no TPV update received within stale_timeout seconds
has_fix True if 2D or 3D fix is available
has_3d_fix True if 3D fix with altitude is available
fix_mode FIX_UNKNOWN/FIX_NONE/FIX_2D/FIX_3D (0–3)
latitude Decimal degrees, +N
longitude Decimal degrees, +E
altitude_m Metres MSL (or HAE fallback)
altitude_ft Feet
speed_ms m/s over ground
speed_kmh km/h
speed_mph mph
speed_knots knots
heading True heading, 0–360°
hdop / vdop / pdop Dilution of precision
satellites_used / satellites_visible Satellite counts
close() Stop background thread

GPSD is a context manager (with GPSD() as gps: ...).

GPSFix

Dataclass snapshot returned by get_fix() and wait_for_fix(). Contains all the same fields as the GPSD properties above, plus:

  • time_utc — ISO 8601 timestamp from the GPS receiver
  • received_at — time.monotonic() when the fix was stored
  • age_s — seconds since received_at
  • error_lat_m, error_lon_m, error_alt_m, error_speed_ms — 1-sigma error estimates in SI units
  • as_dict(units='metric') — all fields as a plain dict; pass 'imperial' for ft/mph/knots

Fix mode constants

from rf_bench.gpsd import FIX_UNKNOWN, FIX_NONE, FIX_2D, FIX_3D

Exceptions

from rf_bench.gpsd import GPSDError, GPSDNoFixError

GPSDNoFixError is raised by wait_for_fix() on timeout.

Remote gpsd

gps = GPSD(host="10.1.0.20", port=2947)

Auto-reconnect behaviour

The background thread reconnects automatically on:

  • Connection refused or network error
  • Socket read error or remote disconnect
  • No TPV update received for stale_timeout seconds (default 10 s)

Reconnect delay starts at reconnect_delay seconds (default 2 s), doubles on each consecutive failure, and caps at max_reconnect_delay (default 60 s). The delay resets to the initial value after a successful connection cycle.

Metadata

Release files for rf-bench-drivers-gpsd 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rf-bench-drivers-gpsd 0.1.1
File Size Uploaded Provenance Actions
rf_bench_drivers_gpsd-0.1.1.tar.gz 10.9 kB Without provenance Details for rf_bench_drivers_gpsd-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rf-bench-drivers-gpsd 0.1.1
File Interpreter ABI Platform Actions
rf_bench_drivers_gpsd-0.1.1-py3-none-any.whl Python 3 none any Details for rf_bench_drivers_gpsd-0.1.1-py3-none-any.whl

Total release size: 21.3 kB

Release files / rf_bench_drivers_gpsd-0.1.1.tar.gz

Download URL rf_bench_drivers_gpsd-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2e21a73b255c8fa6d78f1801c12a9e164f02632330897af1988ec4298796270a
BLAKE2b-256 checksum
How to use checksums
b9c33fe869c66c0b939330397b57e43199561b01b5a7e17db8e7f7c92fb7eef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / rf_bench_drivers_gpsd-0.1.1-py3-none-any.whl

Download URL rf_bench_drivers_gpsd-0.1.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb6d80eb32c2836449331a62afc10a821fd74803e648d3965fb06d49024faede
BLAKE2b-256 checksum
How to use checksums
6bb87b35610b20c5070b7828f89aaa3f89dbf25fa1c0f24e2c3cff7b0d713f70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Security for rf-bench-drivers-gpsd 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page