Documentation
¶
Overview ¶
Package gps reads a position from gpsd and turns it into a Maidenhead grid square.
gpsd (https://gpsd.io) owns the GPS receiver and shares it with any number of programs over a small TCP protocol: a client sends ?WATCH and receives one JSON object per line. hamstack only ever reads.
Index ¶
Constants ¶
const DefaultPort = 2948
DefaultPort is the port hamstack's own gpsd service listens on. gpsd's standard port is 2947; using a different one keeps hamstack from fighting a system-wide gpsd that may already be running there.
Variables ¶
var ErrNoFix = errors.New("the GPS receiver has no fix yet")
ErrNoFix means gpsd answered but the receiver has no position yet.
Functions ¶
func Addr ¶
Addr completes an address typed by the user: "host" gets gpsd's standard port, ":2948" means this machine, and a bare IPv6 address is bracketed ("::1" becomes "[::1]:2947").
Types ¶
type Status ¶
type Status struct {
Version string // gpsd's release
Devices []string // receivers gpsd has open (their paths)
Mode int // 0 unknown, 1 no fix, 2 two-dimensional fix, 3 three-dimensional
HasPos bool // Lat and Lon are valid
Lat, Lon float64
Alt float64 // metres, with a 3D fix
Time string // the receiver's UTC time of the fix
SatsUsed int // satellites in the solution
SatsSeen int
// contains filtered or unexported fields
}
Status is what gpsd reported.
func Query ¶
Query connects to gpsd at addr and watches until it has a position, or, when needFix is false, until it has also seen one position report and one satellite report. If the time runs out it returns what it saw so far; the error is ErrNoFix when gpsd was reachable but the receiver had no position.