Giter VIP home page Giter VIP logo

go-gpsd's Introduction

go-gpsd

GPSD client for Go.

Go Reference

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, err := gpsd.Dial("localhost:2947")
	if err != nil { panic(err) }
}

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
// ...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 visit Go Reference.

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

References

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

go-gpsd's People

Contributors

hrogge avatar josip avatar kdknigga avatar lukaszmoskala avatar swilcox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-gpsd's Issues

Missing License

I can not find the license terms anywhere. Would you mind adding a License file ?

go get not working

$ go get github.com/stratoberry/go-gpsd
go: github.com/stratoberry/go-gpsd: invalid github.com import path "github.com/stratoberry"

JSON parsing error panic

Not sure what to do about this, how to catch it or if it's my fault

I'm talking to GPSd on another machine across an (admittedly terrible) wireless connction instead of localhost. I expect that the connection is causing split packets or something and the JSON parsing fails

GPS location updated 50.335434 -0.1409792
GPS location updated 50.3354333 -0.1409808
GPS location updated 50.3354333 -0.1409808
GPS location updated 50.3354322 -0.1409816
GPS location updated 50.3354322 -0.1409816
JSON parsing error: invalid character 's' looking for beginning of value
JSON parsing error: invalid character ':' looking for beginning of value
JSON parsing error: unexpected end of JSON input
JSON parsing error: unexpected end of JSON input
panic: runtime error: slice bounds out of range [1460:510]

goroutine 35 [running]:
bufio.(*Reader).ReadSlice(0xc000308000, 0x70?)
        C:/Program Files/Go/src/bufio/bufio.go:354 +0x225
bufio.(*Reader).collectFragments(0xc00021fe10?, 0xc5?)
        C:/Program Files/Go/src/bufio/bufio.go:454 +0x6d
bufio.(*Reader).ReadString(0x7ff679041a60?, 0x80?)
        C:/Program Files/Go/src/bufio/bufio.go:501 +0x1f
github.com/stratoberry/go-gpsd.watch(0x0?, 0xc000306000)
        C:/Users/Joe/go/pkg/mod/github.com/stratoberry/[email protected]/gpsd.go:283 +0x45
created by github.com/stratoberry/go-gpsd.(*Session).Watch in goroutine 1
        C:/Users/Joe/go/pkg/mod/github.com/stratoberry/[email protected]/gpsd.go:233 +0xae
        ```

go get github.com/stratoberry/go-gpsd returns an error

IIf I type:

go get github.com/stratoberry/go-gpsd

then the following compiler error is shown (with the GOPATH part of the path replaced by $GOPATH by me):

# $GOPATH/src/github.com/stratoberry/go-gpsd/gpsd.go:170: line declared and not used

'line' is an unused variable in the Dial function.

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.