Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get latitude and longitude from Glonass GPS USB stick (U-blox7) using Golang
package main
import (
func main() {
var gps *gpsd.Session
var err error
if gps, err = gpsd.Dial(gpsd.DefaultAddress); err != nil {
panic(fmt.Sprintf("Failed to connect to GPSD: %s", err))
fmt.Println("Adding filter...")
gps.AddFilter("TPV", func(r interface{}) {
tpv := r.(*gpsd.TPVReport)
fmt.Println("Lat", tpv.Lat, "Lon", tpv.Lon)
time.Sleep(5 * time.Second)
fmt.Println("Watching for location data...")
done := gps.Watch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment