Coder Social home page Coder Social logo

go-gpsd's Introduction

go-gpsd

GPSD client for Go.

Installation

# 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")

func main() {
	gps := gpsd.Dial("localhost:2947")
}

After Dialing 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 of gps.Filter and should receive one argument of type interface{}.

tpvFilter := func(r interface{}) {
	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 the Watch method to start observing reports. Please note that at this time installed filters can't be removed.

done := gps.Watch()
<-done

Watch() will span a new goroutine in which all data processing will happen, done channel won'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)
  • Devices (gpsd.DEVICESReport)
  • DEVICE (gpsd.DEVICEReport)
  • ERROR (gpsd.ERRORReport)

Documentation

For complete library docs, visit GoDoc.org or take a look at the gpsd.go file in this repository.

GPSD's documentation on their JSON protocol can be found at http://catb.org/gpsd/gpsd_json.html

To learn more about the Stratoberry Pi project, visit our website at stratoberry.foi.hr.

License

go-gpsd's People

Contributors

josip avatar kdknigga avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.