@@ -9,23 +9,6 @@ import (
99 "time"
1010)
1111
12- const (
13- // TypeUnixTime unix timestamp, parameter: -c
14- TypeUnixTime = "c"
15- // TypeDestinationID destination identification 15char max, parameter: -d
16- TypeDestinationID = "d"
17- // TypeGrouping sentence grouping, parameter: -g
18- TypeGrouping = "g"
19- // TypeLineCount linecount, parameter: -n
20- TypeLineCount = "n"
21- // TypeRelativeTime relative time time, paremeter: -r
22- TypeRelativeTime = "r"
23- // TypeSourceID source identification 15char max, paremter: -s
24- TypeSourceID = "s"
25- // TypeTextString valid character string, parameter -t
26- TypeTextString = "t"
27- )
28-
2912var (
3013 // tagBlockRegexp matches nmea tag blocks
3114 tagBlockRegexp = regexp .MustCompile (`^(.*)\\(\S+)\\(.*)` )
@@ -34,13 +17,13 @@ var (
3417// TagBlock struct
3518type TagBlock struct {
3619 Head string // *
37- Time int64 // -c
38- RelativeTime int64 // -r
39- Destination string // -d 15 char max
40- Grouping string // -g nummeric string
41- LineCount int64 // -n int
42- Source string // -s 15 char max
43- Text string // -t Variable length text
20+ Time int64 // TypeUnixTime unix timestamp, parameter: -c
21+ RelativeTime int64 // TypeRelativeTime relative time time, parameter: -r
22+ Destination string // TypeDestinationID destination identification 15 char max, parameter: -d
23+ Grouping string // TypeGrouping sentence grouping, parameter: -g
24+ LineCount int64 // TypeLineCount line count, parameter: -n
25+ Source string // TypeSourceID source identification 15 char max, parameter: -s
26+ Text string // TypeTextString valid character string, parameter -t
4427}
4528
4629func parseInt64 (raw string ) (int64 , error ) {
@@ -104,7 +87,7 @@ func parseTagBlock(raw string) (TagBlock, string, error) {
10487 continue
10588 }
10689 switch item [:1 ] {
107- case TypeUnixTime :
90+ case "c" : // UNIX timestamp
10891 tagBlock .Time , err = parseInt64 (item )
10992 if err != nil {
11093 return tagBlock , raw , err
@@ -113,23 +96,23 @@ func parseTagBlock(raw string) (TagBlock, string, error) {
11396 if err != nil {
11497 return tagBlock , raw , err
11598 }
116- case TypeDestinationID :
99+ case "d" : // Destination ID
117100 tagBlock .Destination = item [2 :]
118- case TypeGrouping :
101+ case "g" : // Grouping
119102 tagBlock .Grouping = item [2 :]
120- case TypeLineCount :
103+ case "n" : // Line count
121104 tagBlock .LineCount , err = parseInt64 (item )
122105 if err != nil {
123106 return tagBlock , raw , err
124107 }
125- case TypeRelativeTime :
108+ case "r" : // Relative time
126109 tagBlock .RelativeTime , err = parseInt64 (item )
127110 if err != nil {
128111 return tagBlock , raw , err
129112 }
130- case TypeSourceID :
113+ case "s" : // Source ID
131114 tagBlock .Source = item [2 :]
132- case TypeTextString :
115+ case "t" : // Text string
133116 tagBlock .Text = item [2 :]
134117 }
135118 }
0 commit comments