Created
March 28, 2017 10:38
-
-
Save suapapa/9186fac814f3906b714cfd0c2e398522 to your computer and use it in GitHub Desktop.
go gps tacho-meter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
nmea "github.com/adrianmo/go-nmea" | |
) | |
func main() { | |
scanner := bufio.NewScanner(os.Stdin) | |
for scanner.Scan() { | |
line := scanner.Text() // Println will add back the final '\n' | |
m, err := nmea.Parse(line) | |
if err != nil { | |
continue | |
// log.Println(line, err) | |
} | |
s := m.GetSentence() | |
if "GPVTG" == s.Type { | |
// fmt.Printf("%+v\n", s) | |
vtg := nmea.NewGPVTG(s) | |
fmt.Println(vtg.GroundSpeedKPH) | |
} | |
} | |
if err := scanner.Err(); err != nil { | |
fmt.Fprintln(os.Stderr, "reading standard input:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment