-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (33 loc) · 820 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"fmt"
"log"
"github.com/darashi/unagi/ubloxm8"
)
var (
flagDevice = flag.String("device", "/dev/ttyUSB0", "serial port")
flagBaudRate = flag.Int("baud-rate", 9600, "baud rate")
flagAll = flag.Bool("all", false, "output all messages; not only $QZQSM")
flagVerbose = flag.Bool("verbose", false, "verbose output")
)
func main() {
flag.Parse()
receiver, err := ubloxm8.NewReceiver(*flagDevice, *flagBaudRate)
if err != nil {
log.Fatal(err)
}
defer receiver.Close()
if err := receiver.EnableQZSSL1S(); err != nil {
log.Fatal(err)
}
if err := receiver.EnableRXMSFRBXOnURAT1(); err != nil {
log.Fatal(err)
}
handler := func(msg string) {
fmt.Println(msg)
}
if err := receiver.Receive(handler, *flagAll, *flagVerbose); err != nil {
log.Fatal(err)
}
}