gpsd

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout          = errors.New("timeout")
	ErrWatchModeEnabled = errors.New("operation not available while in watch mode")
)
View Source
var ErrUnsupportedProtocolVersion = errors.New("unsupported protocol version")

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Version Version
	// contains filtered or unexported fields
}

Conn represents a socket connection to an GPSd daemon.

func Dial

func Dial(addr string) (*Conn, error)

Dial establishes a socket connection to the GPSd daemon.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the GPSd daemon connection.

func (*Conn) Devices

func (c *Conn) Devices() ([]Device, error)

Devices returns a list of all devices GPSd is aware of.

ErrWatchModeEnabled will be returned if the connection is in watch mode. A nil-slice will be returned if the connection has been closed.

func (*Conn) Next

func (c *Conn) Next() (interface{}, error)

Next returns the next object sent from the daemon, or an error.

The empty interface returned can be any of the following types:

  • Sky: A Sky object reports a sky view of the GPS satellite positions.
  • TPV: A TPV object is a time-position-velocity report.

func (*Conn) NextPos

func (c *Conn) NextPos() (Position, error)

NextPos returns the next reported position.

func (*Conn) NextPosTimeout

func (c *Conn) NextPosTimeout(timeout time.Duration) (Position, error)

NextPosTimeout returns the next reported position, or an empty position on timeout.

func (*Conn) Watch

func (c *Conn) Watch(enable bool) bool

Watch enables or disables the watcher mode.

In watcher mode, GPS reports are dumped as TPV and SKY objects. These objects are available through the Next method.

type Device

type Device struct {
	Path     string `json:"path,omitempty"`
	Flags    *int   `json:"flags,omitempty"`
	Driver   string `json:"driver,omitempty"`
	Subtype  string `json:"subtype,omitempty"`
	Bps      *int   `json:"bps,omitempty"`
	Parity   string `json:"parity"`
	StopBits int    `json:"stopbits"`
}

Device represents a connected sensor/GPS.

type NMEAMode

type NMEAMode int
const (
	ModeUnknown NMEAMode = iota
	ModeNoFix
	Mode2D
	Mode3D
)

type Position

type Position struct {
	Lat, Lon float64   // Latitude/longitude in degrees. +/- signifies north/south.
	Alt      float64   // Altitude in meters.
	Track    float64   // Course over ground, degrees from true north.
	Speed    float64   // Speed over ground, meters per second.
	Time     time.Time // Time as reported by the device.
}

Position holds geographic positioning data.

type Positioner

type Positioner interface {
	Position() Position
	HasFix() bool
}

Positioner implementations provide geographic positioning data.

This is particularly useful for testing if an object returned by Next can be used to determine the device position.

type Satellite

type Satellite struct {
	// PRN ID of the satellite. 1-63 are GNSS satellites, 64-96 are GLONASS satellites, 100-164 are SBAS satellites.
	PRN int `json:"PRN"`

	// Azimuth, degrees from true north.
	Azimuth json.Number `json:"az"`

	// Elevation in degrees.
	Elevation json.Number `json:"el"`

	// Signal strength in dB.
	SignalStrength json.Number `json:"ss"`

	// Used in current solution?
	//
	// (SBAS/WAAS/EGNOS satellites may be flagged used if the solution has corrections from them, but not all drivers make this information available).
	Used bool `json:"used"`
}

Satellite represents a GPS satellite.

type Sky

type Sky struct {
	Device string    `json:"device,omitempty"`
	Time   time.Time `json:"time,omitempty"`

	XDOP, YDOP, VDOP, TDOP, HDOP, PDOP, GDOP json.Number

	Satellites []Satellite `json:"satellites"`
}

A Sky object reports a sky view of the GPS satellite positions.

type TPV

type TPV struct {
	Device string      // Name of originating device.
	Mode   NMEAMode    // NMEA mode: %d, 0=no mode value yet seen, 1=no fix, 2=2D, 3=3D.
	Time   time.Time   // Time/date stamp.  May have a fractional part of up to .001sec precision. May be absent if mode is not 2D or 3D.
	EPT    json.Number // Estimated timestamp error (%f, seconds, 95% confidence). Present if time is present.

	Lat, Lon, Alt       json.Number
	EPX, EPY, EPV       json.Number // Lat, Lon, Alt error estimate in meters, 95% confidence. Present if mode is 2 or 3 and DOPs can be calculated from the satellite view.
	Track, Speed, Climb json.Number
	EPD, EPS, EPC       json.Number
}

A TPV object is a time-position-velocity report.

func (TPV) HasFix

func (t TPV) HasFix() bool

func (TPV) Position

func (t TPV) Position() Position

type Version

type Version struct {
	Release    string `json:"release"`
	Rev        string `json:"rev"`
	ProtoMajor int    `json:"proto_major"`
	ProtoMinor int    `json:"proto_minor"`
}

Version holds GPSd version data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL