|
| 1 | +package nmea |
| 2 | + |
| 3 | +import ( |
| 4 | + "strings" |
| 5 | +) |
| 6 | + |
| 7 | +const ( |
| 8 | + // TypePKLDS type for PKLDS sentences |
| 9 | + TypePKLDS = "KLDS" |
| 10 | +) |
| 11 | + |
| 12 | +// PKLDS is Kenwood propirtary sentance it is RMC with the addition of Fleetsync ID and status information. |
| 13 | +// http://aprs.gids.nl/nmea/#rmc |
| 14 | +// |
| 15 | +// Format: $PKLDS,hhmmss.ss,A,ddmm.mm,a,dddmm.mm,a,x.x,x.x,xxxx,x.x,a*hh<CR><LF> |
| 16 | +// Example: $PKLDS,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W00,100,2000,25,00*6E |
| 17 | +type PKLDS struct { |
| 18 | + BaseSentence |
| 19 | + Time Time // Time Stamp |
| 20 | + Validity string // validity - A-ok, V-invalid |
| 21 | + Latitude float64 // Latitude |
| 22 | + Longitude float64 // Longitude |
| 23 | + Speed float64 // Speed in knots |
| 24 | + Course float64 // True course |
| 25 | + Date Date // Date |
| 26 | + Variation float64 // Magnetic variation |
| 27 | + SentanceVersion string // 00 to 15 |
| 28 | + Fleet string // 100 to 349 |
| 29 | + UnitID string // 1000 to 4999 |
| 30 | + Status string // 10 to 99 |
| 31 | + Extension string // 00 to 99 |
| 32 | +} |
| 33 | + |
| 34 | +// newPKLDS constructor |
| 35 | +func newPKLDS(s BaseSentence) (Sentence, error) { |
| 36 | + p := NewParser(s) |
| 37 | + p.AssertType(TypePKLDS) |
| 38 | + m := PKLDS{ |
| 39 | + BaseSentence: s, |
| 40 | + Time: p.Time(0, "time"), |
| 41 | + Validity: p.EnumString(1, "validity", ValidRMC, InvalidRMC), |
| 42 | + Latitude: p.LatLong(2, 3, "latitude"), |
| 43 | + Longitude: p.LatLong(4, 5, "longitude"), |
| 44 | + Speed: p.Float64(6, "speed"), |
| 45 | + Course: p.Float64(7, "course"), |
| 46 | + Date: p.Date(8, "date"), |
| 47 | + Variation: p.Float64(9, "variation"), |
| 48 | + SentanceVersion: p.String(10, "sentance version, range of 00 to 15"), |
| 49 | + Fleet: p.String(11, "fleet, range of 100 to 349"), |
| 50 | + UnitID: p.String(12, "subscriber unit id, range of 1000 to 4999"), |
| 51 | + Status: p.String(13, "subscriber unit status id, range of 10 to 99"), |
| 52 | + Extension: p.String(14, "reserved for future use, range of 00 to 99"), |
| 53 | + } |
| 54 | + if strings.HasPrefix(m.SentanceVersion, "W") == true { |
| 55 | + m.Variation = 0 - m.Variation |
| 56 | + } |
| 57 | + m.SentanceVersion = strings.TrimPrefix(strings.TrimPrefix(m.SentanceVersion, "W"), "E") |
| 58 | + return m, p.Err() |
| 59 | +} |
0 commit comments