Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🛰️ GPSD client for Go.

License

NotificationsYou must be signed in to change notification settings

stratoberry/go-gpsd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPSD client for Go.

Go Reference

Installation

Packages

Linux

  • Debian unstable:apt install golang-github-stratoberry-go-gpsd-dev

Packaging status

From source

# go get github.com/stratoberry/go-gpsd

go-gpsd has no external dependencies.

Usage

go-gpsd is a streaming client for GPSD's JSON service and as such can be used only in async manner unlike clients for other languages which support both async and sync modes.

import ("github.com/stratoberry/go-gpsd")funcmain() {gps,err:=gpsd.Dial("localhost:2947")iferr!=nil {panic(err) }}

AfterDialing the server, you should install stream filters. Stream filters allow you to capture only certain types of GPSD reports.

gps.AddFilter("TPV",tpvFilter)

Filter functions have a type ofgps.Filter and should receive one argument of typeinterface{}.

tpvFilter:=func(rinterface{}) {report:=r.(*gpsd.TPVReport)fmt.Println("Location updated",report.Lat,report.Lon)}

Due to the nature of GPSD reports your filter will manually have to cast the type of the argument it received to a proper*gpsd.Report struct pointer.

After installing all needed filters, call theWatch method to start observing reports. Please note that at this time installed filters can't be removed.

done:=gps.Watch()<-done// ...some time later...gps.Close()

Watch() spans a new goroutine in which all data processing will happen,done doesn't send anything.

Currently supported GPSD report types

  • VERSION (gpsd.VERSIONReport)
  • TPV (gpsd.TPVReport)
  • SKY (gpsd.SKYReport)
  • ATT (gpsd.ATTReport)
  • GST (gpsd.GSTReport)
  • PPS (gpsd.PPSReport)
  • TOFF (gpsd.TOFFReport)
  • DEVICES (gpsd.DEVICESReport)
  • DEVICE (gpsd.DEVICEReport)
  • ERROR (gpsd.ERRORReport)

Documentation

For complete library documentation visitGo Reference.

Documentation of GPSD's JSON protocol is available athttps://gpsd.gitlab.io/gpsd/gpsd_json.html.

References

This library was originally developed as a part of a student project atFOI/University of Zagreb.


[8]ページ先頭

©2009-2025 Movatter.jp