Documentation ¶
Overview ¶
gpsd contains Go types (structs) wich defines how the encoding/json parser should interpret JSON documents from a gpsd (gps service) daemon (gpsd upstream website: http://www.catb.org/gpsd/ )
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilByteSlice = errors.New("<nil> byte slice input") ErrEmptyByteSlice = errors.New("non-nil, but empty byte slice") ErrEmptyString = errors.New("The empty string") )
var (
DebugDurationUnmarshalJSON bool
)
Functions ¶
This section is empty.
Types ¶
type ATT ¶
type ATT struct { //Fixed: "ATT" //Always? Yes. Type: string Class string `json:"class"` //Name of originating device //Always? Yes. Type: string Device string `json:"device"` //Seconds since the Unix epoch, UTC. //May have a fractional part of up to .001sec precision. //Always? Yes. Type: time.Duration Time Duration `json:"time"` //Heading, degrees from true north. //Always? No. Type: numeric Heading float64 `json:"heading,omitempty"` //Magnetometer status. //Always? No. Type: string MagSt string `json:"mag_st,omitempty"` //Pitch in degrees. //Always? No. Type: numeric Pitch float64 `json:"pitch,omitempty"` //Pitch sensor status. //Always? No. Type: string PitchSt string `json:"pitch_st,omitempty"` //Yaw in degrees //Always? No. Type: numeric Yaw float64 `json:"yaw,omitempty"` //Yaw sensor status. //Always? No. Type: string YawSt string `json:"yaw_st,omitempty"` //Roll in degrees. //Always? No. Type: numeric Roll float64 `json:"roll,omitempty"` //Roll sensor status. //Always? No. Type: numeric RollSt string `json:"roll_st,omitempty"` //Local magnetic inclination, degrees, //positive when the magnetic field points downward (into the Earth). //Always? No. Type: numeric Dip float64 `json:"dip,omitempty"` //Scalar magnetic field strength. //(Comment by Lars Tørnes Hansen: micro Teslas ?) //Always? No. Type: numeric MagLen float64 `json:"mag_len,omitempty"` //X component of magnetic field strength. //Always? No. Type: numeric MagX float64 `json:"mag_x,omitempty"` //Y component of magnetic field strength. //Always? No. Type: numeric MagY float64 `json:"mag_y,omitempty"` //Z component of magnetic field strength. //Always? No. Type: numeric MagZ float64 `json:"mag_z,omitempty"` //Scalar acceleration. //Always? No. Type: numeric AccLen float64 `json:"acc_len,omitempty"` //X component of acceleration. //Always? No. Type: numeric AccX float64 `json:"acc_x,omitempty"` //Y component of acceleration. //Always? No. Type: numeric AccY float64 `json:"acc_y,omitempty"` //Z component of acceleration. //Always? No. Type: numeric AccZ float64 `json:"acc_z,omitempty"` //X component of acceleration (gyro). //Always? No. Type: numeric GyroX float64 `json:"gyro_x,omitempty"` //Y component of acceleration (gyro). //Always? No. Type: numeric GyroY float64 `json:"gyro_y,omitempty"` //Water depth in meters. //Always? No. Type: numeric Depth float64 `json:"depth,omitempty"` //Temperature at sensor, degrees centigrade. //Always? No. Type: numeric Temperature float64 `json:"temperature,omitempty"` }
ATT is a vehicle-attitude report type.
It is returned by digital-compass and gyroscope sensors; depending on device, it may include: heading, pitch, roll, yaw, gyroscope, and magnetic-field readings.
Because such sensors are often bundled as part of marine-navigation systems, the ATT response may also include water depth.
The "class" and "mode" fields will reliably be present. Others may be reported or not depending on the specific device type.
type DEVICE ¶
type DEVICE struct { //Fixed: "DEVICE" // //Always? Yes. Type: string Class string `json:"class"` //Name the device for which the control bits are being reported, //or for which they are to be applied. This attribute may be omitted //only when there is exactly one subscribed channel. // //Always? No. Type: string Path string `json:"path,omitempty"` //Time the device was activated as an ISO8601 timestamp. //If the device is inactive this attribute is absent. // //Always? No. Type: string Activated string `json:"activated,omitempty"` //Bit vector of property flags. Currently defined flags are: //describe packet types seen so far (GPS, RTCM2, RTCM3, AIS). //Won't be reported if empty, e.g. before gpsd has seen //identifiable packets from the device. // //Always? No. Type: integer Flags DeviceFlags `json:"flags,omitempty"` //GPSD's name for the device driver type. Won't be reported before //gpsd has seen identifiable packets from the device. // //Always? No. Type: string Driver string `json:"driver,omitempty"` //Whatever version information the device returned. // // Always? // //When the daemon sees a delayed response to a probe //for subtype or firmware-version information. // // Type // //string Subtype string `json:"subtype,omitempty"` //Device speed in bits per second. // //Always? No. Type: integer Bps int `json:"bps,omitempty"` //N, O or E for no parity, odd, or even. // //Always? No. Type: string Parity string `json:"parity,omitempty"` //Stop bits (1 or 2). // //Always? No. Type: string Stopbits string `json:"stopbits,omitempty"` //0 means NMEA mode and 1 means alternate mode //(binary if it has one, for SiRF and Evermore //chipsets in particular). // //Attempting to set this mode on a non-GPS device //will yield an error. // //Always? No. Type: integer Native int `json:"native,omitempty"` //Device cycle time in seconds. // //Always? No. Type: real Cycle float64 `json:"cycle,omitempty"` //Device minimum cycle time in seconds. //Reported from ?CONFIGDEV when (and only when) //the rate is switchable. // //It is read-only and not settable. // //Always? No. Type: real Mincycle float64 `json:"mincycle,omitempty"` }
DEVICE is the request and response type from a "?DEVICE" command.
If CommandDEVICE is followed by a ';' the state of a device, or sets (when followed by '=' and a DEVICE object) device-specific control bits, notably the device's speed and serial mode and the native-mode bit. The parameter-setting form (a request) will be rejected if more than one client is attached to the channel.
Pay attention to the response, because it is possible for this command to fail if the GPS does not support a speed-switching command or only supports some combinations of serial modes. In case of failure, the daemon and GPS will continue to communicate at the old speed.
Use the parameter-setting form with caution. On USB and Bluetooth GPSes it is also possible for serial mode setting to fail either because the serial adaptor chip does not support non-8N1 modes or because the device firmware does not properly synchronize the serial adaptor chip with the UART on the GPS chipset when the speed changes. These failures can hang your device, possibly requiring a GPS power cycle or (in extreme cases) physically disconnecting the NVRAM backup battery.
The serial parameters will be omitted in a response describing a TCP/IP source such as an Ntrip, DGPSIP, or AIS feed.
The gpsd daemon occasionally ships a bare DEVICE object to the client (that is, one not inside a DEVICES wrapper).
type DEVICES ¶
type DEVICES struct { //Fixed: "DEVICES" // //Always? Yes. Type: string Class string `json:"class"` //List of device descriptions // //Always? Yes. Type: list Devices []DEVICE `json:"devices"` //URL of the remote daemon reporting the device set. //If empty, this is a DEVICES response from the local daemon. // //Always? No. Type: string Remote string `json:"remote,omitempty"` }
DEVICES is the response type from a "?DEVICES" command.
The gpsd daemon occasionally ships a bare DEVICE object to the client (that is, one not inside a DEVICES wrapper)
type DeviceFlags ¶
type DeviceFlags int32
DeviceFlags contains flags about wether or not GPS, RTCM2, RTCM3, AIS, or nothing had been seen.
DeviceFlags can SeenNothing or one to many of the other flags.
const ( //SeenNothing means that nothing had been seen. SeenNothing DeviceFlags = iota //SeenGPS means that GPS data had been seen. SeenGPS DeviceFlags = 1 //SeenRTCM2 means that RTCM version 2 data had been seen. SeenRTCM2 DeviceFlags = 2 //SeenRTCM3 means that RTCM version 3 data had been seen. SeenRTCM3 DeviceFlags = 4 //SeenAIS means that AIS data had been seen. SeenAIS DeviceFlags = 8 )
type Duration ¶
Duration is a type that embeds time.Duration, and has support for JSON.
The duration is stored in seconds, if marshaled to JSON.
func (*Duration) MarshalJSON ¶
MarshalJSON can marshal itself into valid JSON.
MarshalJSON implements interface encoding/json.Marshaler
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON can unmarshal a JSON description of itself.
UnmarshalJSON implements interface encoding/json.Unmarshaler
type ERROR ¶
type ERROR struct { //Fixed: "ERROR" // //Always? Yes. Type: string Class string `json:"class"` //Textual error message // //Always? Yes. Type: string Message string `json:"message"` }
ERROR is an error message from the gpsd daemon in response to a syntactically invalid command or an unknown command.
type GST ¶
type GST struct { //Fixed: "GST" //Always? Yes. Type: string Class string `json:"class"` //Name of originating device //Always? No. Type: numeric Device string `json:"device,omitempty"` //Seconds since the Unix epoch, UTC. //May have a fractional part of up to .001sec precision. //Always? No. Type: time.Duration Time Duration `json:"time,omitempty"` //Value of the standard deviation of the range inputs to the navigation //process (range inputs include pseudoranges and DGPS corrections). //Always? No. Type: numeric Rms float64 `json:"rms,omitempty"` //Standard deviation of semi-major axis of error ellipse, in meters. //Always? No. Type: numeric Major float64 `json:"major,omitempty"` //Standard deviation of semi-minor axis of error ellipse, in meters. //Always? No. Type: numeric Minor float64 `json:"minor,omitempty"` //Orientation of semi-major axis of error ellipse, in degrees from true north. //Always? No. Type: numeric Orient float64 `json:"orient,omitempty"` //Standard deviation of latitude error, in meters. //Always? No. Type: numeric Lat float64 `json:"lat,omitempty"` //Standard deviation of longitude error, in meters. //Always? No. Type: numeric Lon float64 `json:"lon,omitempty"` //Standard deviation of altitude error, in meters. //Always? No. Type: numeric Alt float64 `json:"alt,omitempty"` }
GST is a type for pseudorange noise reports.
type POLL ¶
type POLL struct { //Fixed: "POLL" // //Always? Yes. Type: string Class string `json:"class"` //Timestamp in ISO 8601 format. //May have a fractional part of up to .001sec precision. // //Always? Yes. Type: Time Duration `json:"time"` //Count of active devices. // //Always? Yes. Type: numeric Active float64 `json:"active"` //Comma-separated list of TPV objects. // //Always? Yes. Type: JSON Array Fixes []TPV `json:"tpv"` //Comma-separated list of SKY objects. // //Always? Yes. Type: JSON Array SkyViews []SKY `json:"sky"` }
POLL is a type that contains the data from the response from a a "?POLL" command.
The POLL command requests data from the last-seen fixes on all active GPS devices. Devices must previously have been activated by ?WATCH to be pollable.
Polling can lead to possibly surprising results when it is used on a device such as an NMEA GPS for which a complete fix has to be accumulated from several sentences. If you poll while those sentences are being emitted, the response will contain the last complete fix data and may be as much as one cycle time (typically 1 second) stale.
The POLL response will contain a timestamped list of TPV objects describing cached data, and a timestamped list of SKY objects describing satellite configuration. If a device has not seen fixes, it will be reported with a mode field of zero.
Note ¶
Client software should not assume the field inventory of the POLL response is fixed for all time. As gpsd collects and caches more data from more sensor types, those data are likely to find their way into this response.
type PPS ¶
type PPS struct { //Fixed: "PPS" // //Always? Yes. Type: string Class string `json:"class"` //Name of originating device // //Always? Yes. Type: string Device float64 `json:"device"` //Seconds from the GPS clock // //Always? Yes. Type: numeric RealSec float64 `json:"real_sec"` //Nanoseconds from the GPS clock // //Always? Yes. Type: numeric RealNsec float64 `json:"real_nsec"` //Seconds from the system clock // //Always? Yes. Type: numeric ClockSec float64 `json:"clock_sec"` //Nanoseconds from the system clock // //Always? Yes. Type: numeric ClockNsec float64 `json:"clock_nsec"` }
PPS is type that contains a message which is emitted each time the gpsd server sees a PPS (Pulse Per Second) strobe from a device.
Type PPS is emitted once per second to watchers of a device emitting PPS, and is intended to report the offset between the start of the GPS second (when the 1PPS arrives) and seconds as reported by the system clock (which may be NTP-corrected).
Type PPS contains second/nanosecond pairs for two clocks; the realtime clock without NTP correction (the result of clock_gettime(CLOCK_REALTIME), but only to microsecond precision) and the ordinary system clock (which may be NTP corrected).
There are various sources of error in the reported clock times. For PPS delivered via a real serial-line strobe, serial-interrupt latency plus processing time to the timer call should be bounded above by about 10 microseconds; USB-to-serial control-line emulation is known to add jitter of about 50 microseconds. (Both figures are for GPSD running in non-realtime mode on an x86 with a gigahertz clock and are estimates based on measured latency in other applications.)
type SKY ¶
type SKY struct { //Fixed: "SKY" //Always? Yes. Type: string Class string `json:"class"` //Name of originating device. //Always? No. Type: string Device string `json:"device,omitempty"` //Time/date stamp in ISO8601 format, UTC. //May have a fractional part of up to .001sec precision. //Always? No. Type: time.Time Time time.Time `json:"time,omitempty"` //Longitudinal dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Xdop float64 `json:"xdop,omitempty"` //Latitudinal dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Ydop float64 `json:"ydop,omitempty"` //Altitude dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Vdop float64 `json:"vdop,omitempty"` //Time dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Tdop float64 `json:"tdop,omitempty"` //Horizontal dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Hdop float64 `json:"hdop,omitempty"` //Spherical dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Pdop float64 `json:"pdop,omitempty"` //Hyperspherical dilution of precision, a dimensionless factor which //should be multiplied by a base UERE to get an error estimate. //Always? No. Type: numeric Gdop float64 `json:"gdop,omitempty"` //List of satellite objects in skyview //Always? Yes. Type: list Satellites []Satellite `json:"satellites"` }
SKY is a type used to report a sky view of the GPS satellite positions.
If there is no GPS device available, or no skyview has been reported yet, only the "class" field will reliably be present.
Many devices compute dilution of precision factors but do not include them in their reports. Many that do report DOPs report only HDOP, two-dimensional circular error. gpsd always passes through whatever the device actually reports, then attempts to fill in other DOPs by calculating the appropriate determinants in a covariance matrix based on the satellite view. DOPs may be missing if some of these determinants are singular. It can even happen that the device reports an error estimate in meters when the corresponding DOP is unavailable; some devices use more sophisticated error modeling than the covariance calculation.
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 //Always? Yes. Type: numeric PRN float64 `json:"PRN"` //Azimuth, degrees from true north. //Always? Yes. Type: numeric Az float64 `json:"az"` //Elevation in degrees. //Always? Yes. Type: numeric El float64 `json:"el"` //Signal strength in dB. //Always? Yes. Type: numeric Ss float64 `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. //Always? Yes. Type: bool Used bool `json:"used"` }
Satellite is a type that does not have a "class" field, as they are never shipped outside of a SKYReport.
type TOFF ¶
type TOFF struct { //Fixed: "TOFF" // //Always? Yes. Type: string Class string `json:"class"` //Name of originating device // //Always? Yes. Type: string Device float64 `json:"device"` //Seconds from the GPS clock // //Always? Yes. Type: numeric RealSec float64 `json:"real_sec"` //Nanoseconds from the GPS clock // //Always? Yes. Type: numeric RealNsec float64 `json:"real_nsec"` //Seconds from the system clock // //Always? Yes. Type: numeric ClockSec float64 `json:"clock_sec"` //Nanoseconds from the system clock // //Always? Yes. Type: numeric ClockNsec float64 `json:"clock_nsec"` }
TOFF is a type that contains the message that is emitted on each cycle and reports the offset between the host's clock time and the GPS time at top of second (actually, when the first data for the reporting cycle is received).
Type TOFF is emitted once per second to watchers of a device and is intended to report the offset between the in-band report of the GPS, and seconds as reported by the system clock (which may be NTP-corrected) when the first valid timestamp of the reporting cycle is seen.
Type TOFF contains second/microsecond pairs for two clocks; the realtime clock without NTP correction (the result of clock_gettime(CLOCK_REALTIME), but only to microsecond precision), and the ordinary system clock (which may be NTP corrected).
type TPV ¶
type TPV struct { //Fixed: "TPV". // //Always? Yes. Type: string Class string `json:"class"` //Name of originating device. // //Always? Yes. Type: string Device string `json:"device"` //NMEA mode: %d, 0=no mode value yet seen, 1=no fix, 2=2D, 3=3D. // ////Always? Yes. Type: Mode Fix gpsfix.FixMode `json:"mode"` //Time/date stamp in ISO8601 format, UTC. //May have a fractional part of up to .001sec precision. //May be absent if mode is not 2 or 3. // //Always? No. Type: time.Time Time string `json:"time,omitempty"` //Estimated timestamp error (%f, seconds, 95% confidence). //Present if time is present. // //Always? No. Type: numeric Ept float64 `json:"ept,omitempty"` //Latitude in degrees: +/- signifies North/South. //Present when mode is 2 (2D fix) or 3 (3D fix). // //Always? No. Type: numeric Lat float64 `json:"lat,omitempty"` //Longitude in degrees: +/- signifies East/West. //Present when mode is 2 (2D fix) or 3 (3D fix). // //Always? No. Type: numeric Lon float64 `json:"lon,omitempty"` //Altitude in meters. //Present if mode is 3 (3D fix). // //Always? No. Type: numeric Alt float64 `json:"alt,omitempty"` //Longitude error estimate in meters, 95% confidence. //Present if mode is 2 (2D fix) or 3 (3D fix), //and DOPs can be calculated from the satellite view. // //Always? No. Type: numeric Epx float64 `json:"epx,omitempty"` //Latitude error estimate in meters, 95% confidence. //Present if mode is 2 (2D fix) or 3 (3D fix), //and DOPs can be calculated from the satellite view. // //Always? No. Type: numeric Epy float64 `json:"epy,omitempty"` //Estimated vertical error in meters, 95% confidence. //Present if mode is 2 (2D fix) or 3 (3D fix), //and DOPs can be calculated from the satellite view. // //Always? No. Type: numeric Epv float64 `json:"epv,omitempty"` //Course over ground, degrees from true north. // //Always? No. Type: numeric Track float64 `json:"track,omitempty"` //Speed over ground, meters/sec. // //Always? No. Type: numeric Speed float64 `json:"speed,omitempty"` //Climb (positive) or sink (negative) rate, meters/sec. // //Always? No. Type: numeric Climb float64 `json:"climb,omitempty"` //Direction error estimate in degrees, 95% confidence. // //Always? No. Type: numeric Epd float64 `json:"epd,omitempty"` //Speed error estinmate in meters/sec, 95% confidence. // //Always? No. Type: numeric Eps float64 `json:"eps,omitempty"` //Climb/sink error estimate in meters/sec, 95% confidence. // //Always? No. Type: numeric Epc float64 `json:"epc,omitempty"` }
TPV is type that contains a time-position-velocity report.
The "class" and "mode" fields will reliably be present. The "mode" field will be emitted before optional fields that may be absent when there is no fix.
Error estimates will be emitted after the fix components they're associated with.
Others may be reported or not depending on the fix quality.
The documentation text for this type is from http://catb.org/gpsd/gpsd_json.html
type VERSION ¶
type VERSION struct { //Fixed: "VERSION" // //Always? Yes. Type: string Class string `json:"class"` //Public release level // //Always? Yes. Type: string Release string `json:"release"` //Internal revision-control level. // //Always? Yes. Type: string Rev string `json:"rev"` //API major revision level. // //Always? Yes. Type: numeric ProtoMajor int `json:"proto_major"` //API minor revision level. // //Always? Yes. Type: numeric ProtoMinor int `json:"proto_minor"` //URL of the remote daemon reporting this version. //If empty, this is the version of the local daemon. // //Always? No. Type: string Remote string `json:"remote,omitempty"` }
VERSION is a type that contains the response from a "?VERION" command.
The gpsd daemon ships a VERSION response to each client when the client first connects to it.
type WATCH ¶
type WATCH struct { //Fixed: "WATCH" // //Always? Yes. Type: string Class string `json:"class"` //Enable (true) or disable (false) the watcher mode. //Default is true. // //Always? No. Type: boolean Enable bool `json:"enable,omitempty"` //Enable (true) or disable (false) dumping of JSON reports. //Default is false. // //Always? No. Type: boolean JSON bool `json:"json,omitempty"` //Enable (true) or disable (false) //dumping of binary packets as pseudo-NMEA. //Default is false. // //Always? No. Type: boolean Nmea bool `json:"nmea,omitempty"` //Controls 'raw' mode. When this attribute is set to 1 for a channel, //gpsd reports the unprocessed NMEA or AIVDM data stream from whatever //device is attached. //Binary GPS packets are hex-dumped. //RTCM2 and RTCM3 packets are not dumped in raw mode. //When this attribute is set to 2 for a channel that processes binary //data, gpsd reports the received data verbatim without hex-dumping. // //Always? No. Type: numeric Raw float64 `json:"raw,omitempty"` //If true, apply scaling divisors to output before dumping; //default is false. // //Always? No. Type: boolean Scaled bool `json:"scaled,omitempty"` //If true, aggregate AIS type24 sentence parts. //If false, report each part as a separate JSON object, //leaving the client to match MMSIs and aggregate. //Default is false. //Applies only to AIS reports. // //Always? No. Type: boolean Split24 bool `json:"split24,omitempty"` //If true, emit the TOFF JSON message on each cycle, // and a PPS JSON message when the device issues 1PPS. //Default is false. // //Always? No. Type: boolean Pps bool `json:"pps,omitempty"` //If present, enable watching only of //the specified device rather than all devices. //Useful with raw and NMEA modes in which device responses aren't tagged. //Has no effect when used with enable:false. // //Always? No. Type: string Device string `json:"device,omitempty"` //URL of the remote daemon reporting the watch set. //If empty, this is a WATCH response from the local daemon. // //Always? No. Type: string Remote string `json:"remote,omitempty"` }
WATCH is type used both for a "?WATCH" command request and the response from that command.
A WATCH command (CommandWATCH) sets the watcher mode. In watcher mode, the gpsd daemon reports are dumped as TPV and SKY responses.
A WATCH request changes the subscriber's policy. A WATCH request also sets or elicits a report of per-subscriber policy and the raw bit.
A WATCH response describes the subscriber's policy, and will also include a DEVICES object.
Undocumented struct field ¶
There is an additional boolean "timing" struct field which is undocumented because that portion of the interface is considered unstable and for (gpsd-)developers use only.
Struct field "Timing" is not implemented in this Go library.