forked from stilldavid/gopro-utils
-
Notifications
You must be signed in to change notification settings - Fork 36
/
gpmdinfo.go
58 lines (47 loc) · 1.03 KB
/
gpmdinfo.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"flag"
"fmt"
"io"
"os"
"github.com/JuanIrache/gopro-utils/telemetry" //linking to my own repository while the main one is behind. Not sure if this is a good practice
)
func main() {
inName := flag.String("i", "", "Required: telemetry file to read")
flag.Parse()
if *inName == "" {
flag.Usage()
return
}
telemFile, err := os.Open(*inName)
if err != nil {
fmt.Printf("Cannot access telemetry file %s.\n", *inName)
os.Exit(1)
}
defer func(file *os.File) {
err := file.Close()
if err != nil {
fmt.Printf("Cannot close file %s: %s", file.Name(), err)
os.Exit(1)
}
}(telemFile)
// currently processing sentence
t := &telemetry.TELEM{}
for {
t, err = telemetry.Read(telemFile)
if err != nil {
if err == io.EOF {
break
}
fmt.Println(err)
os.Exit(1)
}
if t == nil {
break
}
// this is pretty useless and info overload: change it to pick a field you want
// or mangle it to your wishes into JSON/CSV/format of choice
fmt.Println(t)
t = &telemetry.TELEM{}
}
}