Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get latitude and longitude from Glonass GPS USB stick (U-blox7) using Golang
package main
import (
"fmt"
"github.com/stratoberry/go-gpsd"
"time"
)
func main() {
var gps *gpsd.Session
var err error
fmt.Println("Dialing...")
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()
<-done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment