nmea 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +7 -0
- data/Rakefile +2 -2
- data/ext/nmea.cpp +2484 -1938
- data/ext/ruby_nmea.cpp +0 -3
- data/test/helper.rb +0 -1
- data/test/mocks.rb +3 -0
- data/test/nmea.txt +3356 -0
- data/test/parse.log +0 -0
- data/test/points.wpt +10756 -0
- data/test/reader.rb +9 -10
- data/test/speed.txt +10756 -0
- metadata +6 -8
- data/test/test_filters.rb +0 -7
- data/test/test_scan.rb +0 -298
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: nmea
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2007-
|
6
|
+
version: "0.3"
|
7
|
+
date: 2007-11-03 00:00:00 +03:00
|
8
8
|
summary: NMEA (GPS protocol) parser
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,24 +34,22 @@ files:
|
|
34
34
|
- setup.rb
|
35
35
|
- init.rb
|
36
36
|
- test/fixtures
|
37
|
+
- test/fixtures/rmc.txt
|
37
38
|
- test/helper.rb
|
38
39
|
- test/mocks.rb
|
40
|
+
- test/nmea.txt
|
39
41
|
- test/parse.log
|
40
42
|
- test/points.wpt
|
41
43
|
- test/reader.rb
|
42
44
|
- test/speed.txt
|
43
|
-
- test/test_filters.rb
|
44
|
-
- test/test_scan.rb
|
45
|
-
- test/fixtures/rmc.txt
|
46
45
|
- ext/nmea.h
|
47
46
|
- ext/nmea.cpp
|
48
47
|
- ext/ruby_nmea.cpp
|
49
48
|
- ext/extconf.rb
|
50
49
|
- ext/test.rb
|
51
50
|
- lib/nmea.rb
|
52
|
-
test_files:
|
53
|
-
|
54
|
-
- test/test_scan.rb
|
51
|
+
test_files: []
|
52
|
+
|
55
53
|
rdoc_options:
|
56
54
|
- --main=README
|
57
55
|
- --line-numbers
|
data/test/test_filters.rb
DELETED
data/test/test_scan.rb
DELETED
@@ -1,298 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__)+"/helper"
|
2
|
-
|
3
|
-
class TestScanLines < Test::Unit::TestCase
|
4
|
-
def self.handler(name, *params)
|
5
|
-
class_eval <<-EOF
|
6
|
-
def #{name}(#{params.join(", ")})
|
7
|
-
@#{name}_called = (@#{name}_called || 0) + 1
|
8
|
-
#{params.map{|param| "@"+param.to_s+" = "+param.to_s}.join("\n")}
|
9
|
-
end
|
10
|
-
EOF
|
11
|
-
end
|
12
|
-
handler :rmc, :utc, :latitude, :longitude, :speed, :course, :magnetic_variation
|
13
|
-
|
14
|
-
def test_rmc
|
15
|
-
invalid_rmc = "$GPRMC,072458.748,V,,,,,,,080407,,*23"
|
16
|
-
NMEA.scan(invalid_rmc, self)
|
17
|
-
assert_equal 1, @rmc_called, "RMC handler should be called"
|
18
|
-
assert_equal Time.gm(2007, 4, 8, 7, 24, 58, 748), @utc
|
19
|
-
assert_equal nil, @latitude
|
20
|
-
assert_equal nil, @longitude
|
21
|
-
assert_equal nil, @speed
|
22
|
-
assert_equal nil, @course
|
23
|
-
assert_equal nil, @magnetic_variation
|
24
|
-
|
25
|
-
valid_rmc = "$GPRMC,072640.711,A,5546.5537,N,03741.2054,E,0.00,,080407,,*12"
|
26
|
-
NMEA.scan(valid_rmc, self)
|
27
|
-
assert_equal 2, @rmc_called, "RMC handler should be called"
|
28
|
-
assert_equal Time.gm(2007, 4, 8, 7, 26, 40, 711), @utc
|
29
|
-
assert_equal GPS::Latitude.new(55, 46.5537), @latitude
|
30
|
-
assert_equal GPS::Longitude.new(37, 41.2054), @longitude
|
31
|
-
assert_equal 0, @speed
|
32
|
-
assert_equal nil, @course
|
33
|
-
assert_equal nil, @magnetic_variation
|
34
|
-
|
35
|
-
strange_rmc = "$GPRMC,135444,A,3815.4477,N,02349.5804,E,10412.9,243.3,090507,5,E,A*B"
|
36
|
-
NMEA.scan(strange_rmc, self)
|
37
|
-
assert_equal 3, @rmc_called, "RMC handled should be called"
|
38
|
-
assert_equal Time.gm(2007, 5, 9, 13, 54, 44), @utc
|
39
|
-
assert_equal GPS::Latitude.new(38, 15.4477), @latitude
|
40
|
-
assert_equal GPS::Longitude.new(23, 49.5804), @longitude
|
41
|
-
assert_equal 10412.9, @speed
|
42
|
-
assert_equal 243.3, @course
|
43
|
-
assert_equal 5, @magnetic_variation
|
44
|
-
end
|
45
|
-
|
46
|
-
def gsv(flag, satellites)
|
47
|
-
@gsv_called = (@gsv_called || 0) + 1
|
48
|
-
@flag = flag
|
49
|
-
@satellites = [] if flag == :start
|
50
|
-
@satellites ||= []
|
51
|
-
@satellites += satellites
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_gsv
|
55
|
-
empty_gsv = ["$GPGSV,3,1,12,20,00,000,,10,00,000,,25,00,000,,27,00,000,*79",
|
56
|
-
"$GPGSV,3,2,12,22,00,000,,07,00,000,,21,00,000,,24,00,000,*79",
|
57
|
-
"$GPGSV,3,3,12,16,00,000,,28,00,000,,26,00,000,,29,00,000,*78"]
|
58
|
-
empty_gsv.each do |gsv|
|
59
|
-
NMEA.scan(gsv, self)
|
60
|
-
end
|
61
|
-
assert_equal 3, @gsv_called
|
62
|
-
assert_equal 12, @satellites.size
|
63
|
-
assert_equal 20, @satellites.first.number
|
64
|
-
|
65
|
-
good_gsv = ["$GPGSV,3,1,11,19,38,300,33,26,20,035,36,29,13,026,36,18,69,100,*71",
|
66
|
-
"$GPGSV,3,2,11,22,60,191,,03,59,264,31,21,38,095,,16,11,216,*7C",
|
67
|
-
"$GPGSV,3,3,11,08,05,337,,24,02,092,,14,01,167,*48"]
|
68
|
-
good_gsv.each do |gsv|
|
69
|
-
NMEA.scan(gsv, self)
|
70
|
-
end
|
71
|
-
assert_equal 6, @gsv_called
|
72
|
-
assert_equal 11, @satellites.size
|
73
|
-
assert_equal 19, @satellites.first.number
|
74
|
-
assert_equal 38, @satellites.first.elevation
|
75
|
-
assert_equal 300, @satellites.first.azimuth
|
76
|
-
assert_equal 33, @satellites.first.signal_level
|
77
|
-
|
78
|
-
@satellites = []
|
79
|
-
strange_gsv = "$GPGSV,3,3,09,20,04,037,*42"
|
80
|
-
NMEA.scan(strange_gsv, self)
|
81
|
-
assert_equal 7, @gsv_called
|
82
|
-
assert_equal 1, @satellites.size
|
83
|
-
assert_equal 20, @satellites.first.number
|
84
|
-
assert_equal 4, @satellites.first.elevation
|
85
|
-
assert_equal 37, @satellites.first.azimuth
|
86
|
-
assert_equal nil, @satellites.first.signal_level
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
handler :gsa, :mode_state, :mode, :satellites, :pdop, :hdop, :vdop
|
91
|
-
|
92
|
-
def test_gsa
|
93
|
-
empty_gsa = "$GPGSA,A,1,,,,,,,,,,,,,,,*1E"
|
94
|
-
NMEA.scan(empty_gsa, self)
|
95
|
-
assert_equal 1, @gsa_called
|
96
|
-
assert_equal :automatic, @mode_state
|
97
|
-
assert_equal :no_fix, @mode
|
98
|
-
assert_equal [nil, nil, nil,nil,nil,nil,nil,nil,nil,nil,nil,nil], @satellites
|
99
|
-
assert_equal nil, @pdop
|
100
|
-
assert_equal nil, @hdop
|
101
|
-
assert_equal nil, @vdop
|
102
|
-
|
103
|
-
good_gsa = "$GPGSA,A,2,26,29,19,,,,,,,,,,10.6,10.6,1.0*35"
|
104
|
-
NMEA.scan(good_gsa, self)
|
105
|
-
assert_equal 2, @gsa_called
|
106
|
-
assert_equal :automatic, @mode_state
|
107
|
-
assert_equal :gps_2d, @mode
|
108
|
-
assert_equal [26, 29, 19,nil,nil,nil,nil,nil,nil,nil,nil,nil], @satellites
|
109
|
-
assert_equal 10.6, @pdop
|
110
|
-
assert_equal 10.6, @hdop
|
111
|
-
assert_equal 1.0, @vdop
|
112
|
-
end
|
113
|
-
|
114
|
-
handler :gga, :time, :latitude, :longitude, :gps_quality, :active_satellite_count, :hdop, :altitude, :geoidal_height, :dgps_data_age, :dgps_station_id
|
115
|
-
|
116
|
-
def test_gga
|
117
|
-
empty_gga = "$GPGGA,072459.739,,,,,0,00,,,M,0.0,M,,0000*56"
|
118
|
-
NMEA.scan(empty_gga, self)
|
119
|
-
assert_equal 1, @gga_called
|
120
|
-
assert_equal Time.utc(1970, 1, 1, 07, 24, 59, 739), @time
|
121
|
-
assert_equal nil, @latitude
|
122
|
-
assert_equal nil, @longitude
|
123
|
-
assert_equal :invalid, @gps_quality
|
124
|
-
assert_equal 0, @active_satellite_count
|
125
|
-
assert_equal nil, @hdop
|
126
|
-
assert_equal nil, @altitude
|
127
|
-
assert_equal 0, @geoidal_height
|
128
|
-
assert_equal nil, @dgps_data_age
|
129
|
-
assert_equal 0, @dgps_station_id
|
130
|
-
|
131
|
-
good_gga = "$GPGGA,072642.711,5546.5395,N,03741.2180,E,1,03,10.6,174.3,M,14.4,M,,0000*68"
|
132
|
-
NMEA.scan(good_gga, self)
|
133
|
-
assert_equal 2, @gga_called
|
134
|
-
assert_equal Time.utc(1970, 1, 1, 07, 26, 42, 711), @time
|
135
|
-
assert_equal GPS::Latitude.new(55, 46.5395), @latitude
|
136
|
-
assert_equal GPS::Longitude.new(37, 41.2180), @longitude
|
137
|
-
assert_equal :gps, @gps_quality
|
138
|
-
assert_equal 3, @active_satellite_count
|
139
|
-
assert_equal 10.6, @hdop
|
140
|
-
assert_equal 174.3, @altitude
|
141
|
-
assert_equal 14.4, @geoidal_height
|
142
|
-
assert_equal nil, @dgps_data_age
|
143
|
-
assert_equal 0, @dgps_station_id
|
144
|
-
end
|
145
|
-
|
146
|
-
def psrftxt(key, value)
|
147
|
-
@psrftxt_called = (@psrftxt_called || 0) + 1
|
148
|
-
@psrf[key] = (value || true)
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_psrftxt
|
152
|
-
@psrf = {}
|
153
|
-
data = [
|
154
|
-
"$PSRFTXT,Version:GSW3.2.2_3.1.00.12-SDK003P1.01a",
|
155
|
-
"$PSRFTXT,Version2:F-GPS-03-0607211",
|
156
|
-
"$PSRFTXT,WAAS Disable",
|
157
|
-
"$PSRFTXT,TOW: 26833",
|
158
|
-
"$PSRFTXT,WK: 1422",
|
159
|
-
"$PSRFTXT,POS: 2845429 2198159 5250582",
|
160
|
-
"$PSRFTXT,CLK: 96413",
|
161
|
-
"$PSRFTXT,CHNL: 12",
|
162
|
-
"$PSRFTXT,Baud rate: 4800"]
|
163
|
-
data.each do |sentence|
|
164
|
-
NMEA.scan(sentence, self)
|
165
|
-
end
|
166
|
-
assert_equal 9, @psrftxt_called
|
167
|
-
assert_equal "GSW3.2.2_3.1.00.12-SDK003P1.01a", @psrf["Version"]
|
168
|
-
assert_equal "F-GPS-03-0607211", @psrf["Version2"]
|
169
|
-
assert_equal true, @psrf["WAAS Disable"]
|
170
|
-
assert_equal "26833", @psrf["TOW"]
|
171
|
-
assert_equal "1422", @psrf["WK"]
|
172
|
-
assert_equal "2845429 2198159 5250582", @psrf["POS"]
|
173
|
-
assert_equal "96413", @psrf["CLK"]
|
174
|
-
assert_equal "12", @psrf["CHNL"]
|
175
|
-
assert_equal "4800", @psrf["Baud rate"]
|
176
|
-
end
|
177
|
-
|
178
|
-
handler :vtg, :true_course, :magnetic_course, :knot_speed, :kmph_speed, :mode
|
179
|
-
def test_vtg
|
180
|
-
good_vtg = "$GPVTG,225.29,T,,M,2.86,N,5.3,K*64"
|
181
|
-
NMEA.scan(good_vtg, self)
|
182
|
-
assert_equal 1, @vtg_called
|
183
|
-
assert_equal 225.29, @true_course
|
184
|
-
assert_equal nil, @magnetic_course
|
185
|
-
assert_equal 2.86, @knot_speed
|
186
|
-
assert_equal 5.3, @kmph_speed
|
187
|
-
assert_equal nil, @mode
|
188
|
-
end
|
189
|
-
|
190
|
-
handler :gll, :time, :latitude, :longitude
|
191
|
-
def test_gll
|
192
|
-
empty_gll = "$GPGLL,,,,,192642.609,V*1D"
|
193
|
-
NMEA.scan(empty_gll, self)
|
194
|
-
assert_equal 1, @gll_called
|
195
|
-
assert_equal nil, @latitude
|
196
|
-
assert_equal nil, @longitude
|
197
|
-
assert_equal Time.utc(1970, 1, 1, 19, 26, 42, 609), @time
|
198
|
-
|
199
|
-
good_gll = "$GPGLL,5546.5059,N,03741.1635,E,193703.532,A*34"
|
200
|
-
NMEA.scan(good_gll, self)
|
201
|
-
assert_equal 2, @gll_called
|
202
|
-
assert_equal GPS::Latitude.new(55, 46.5059), @latitude
|
203
|
-
assert_equal GPS::Longitude.new(37, 41.1635), @longitude
|
204
|
-
end
|
205
|
-
|
206
|
-
handler :bod, :true_course, :magnetic, :to, :from
|
207
|
-
def test_bod
|
208
|
-
bod1 = "$GPBOD,099.3,T,105.6,M,POINTB,*48"
|
209
|
-
NMEA.scan(bod1, self)
|
210
|
-
assert_equal 1, @bod_called
|
211
|
-
assert_equal 99.3, @true_course
|
212
|
-
assert_equal 105.6, @magnetic
|
213
|
-
assert_equal "POINTB", @to
|
214
|
-
assert_equal nil, @from
|
215
|
-
|
216
|
-
bod2 = "$GPBOD,097.0,T,103.2,M,POINTB,POINTA*4A"
|
217
|
-
NMEA.scan(bod2, self)
|
218
|
-
assert_equal 2, @bod_called
|
219
|
-
assert_equal 97, @true_course
|
220
|
-
assert_equal 103.2, @magnetic
|
221
|
-
assert_equal "POINTB", @to
|
222
|
-
assert_equal "POINTA", @from
|
223
|
-
end
|
224
|
-
|
225
|
-
# TODO
|
226
|
-
# $GPAAM,A,A,0.10,N,WPTNME*43
|
227
|
-
# handler :aam,
|
228
|
-
#
|
229
|
-
# $GPALM,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,*CC
|
230
|
-
# $GPALM,1,1,15,1159,00,441d,4e,16be,fd5e,a10c9f,4a2da4,686e81,58cbe1,0a4,001*5B
|
231
|
-
#
|
232
|
-
# $GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M*82
|
233
|
-
#
|
234
|
-
# $GPBWC,081837,,,,,,T,,M,,N,*13
|
235
|
-
# $GPBWC,220516,5130.02,N,00046.34,W,213.8,T,218.0,M,0004.6,N,EGLM*11
|
236
|
-
#
|
237
|
-
# $GPGRS,024603.00,1,-1.8,-2.7,0.3,,,,,,,,,*6C
|
238
|
-
#
|
239
|
-
# $GPGST,024603.00,3.2,6.6,4.7,47.3,5.8,5.6,22.0*58
|
240
|
-
#
|
241
|
-
# $GPHDT,x.x,T
|
242
|
-
#
|
243
|
-
# $GPMSK,318.0,A,100,M,2*45
|
244
|
-
#
|
245
|
-
# $GPMSS,55,27,318.0,100,*66
|
246
|
-
# $GPMSS,0.0,0.0,0.0,25,2*6D
|
247
|
-
#
|
248
|
-
# $GPR00,EGLL,EGLM,EGTB,EGUB,EGTK,MBOT,EGTB,,,,,,,*58
|
249
|
-
# $GPR00,MINST,CHATN,CHAT1,CHATW,CHATM,CHATE,003,004,005,006,007,,,*05
|
250
|
-
#
|
251
|
-
# $GPRMA,A,lll,N,lll,W,x,y,ss.s,ccc,vv.v,W*hh
|
252
|
-
#
|
253
|
-
# $GPRMB,A,0.66,L,003,004,4917.24,N,12309.57,W,001.3,052.5,000.5,V*0B
|
254
|
-
# $GPRMB,A,4.08,L,EGLL,EGLM,5130.02,N,00046.34,W,004.6,213.9,122.9,A*3D
|
255
|
-
# $GPRMB,A,x.x,a,c--c,d--d,llll.ll,e,yyyyy.yy,f,g.g,h.h,i.i,j*kk
|
256
|
-
#
|
257
|
-
# $GPRTE,2,1,c,0,PBRCPK,PBRTO,PTELGR,PPLAND,PYAMBU,PPFAIR,PWARRN,PMORTL,PLISMR*73
|
258
|
-
# $GPRTE,2,2,c,0,PCRESY,GRYRIE,GCORIO,GWERR,GWESTG,7FED*34
|
259
|
-
#
|
260
|
-
# $GPTRF,hhmmss.ss,xxxxxx,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,x.x,xxx
|
261
|
-
#
|
262
|
-
# $GPSTN,xx
|
263
|
-
#
|
264
|
-
# $--VBW,x.x,x.x,A,x.x,x.x,A
|
265
|
-
#
|
266
|
-
# $GPWPL,4917.16,N,12310.64,W,003*65
|
267
|
-
# $GPWPL,5128.62,N,00027.58,W,EGLL*59
|
268
|
-
#
|
269
|
-
# $GPXTE,A,A,0.67,L,N
|
270
|
-
# $GPXTE,A,A,4.07,L,N*6D
|
271
|
-
#
|
272
|
-
# $GPZDA,hhmmss.ss,xx,xx,xxxx,xx,xx
|
273
|
-
# $GPZDA,024611.08,25,03,2002,00,00*6A
|
274
|
-
#
|
275
|
-
# ====== GARMIN ========
|
276
|
-
#
|
277
|
-
# $HCHDG,101.1,,,7.1,W*3C
|
278
|
-
#
|
279
|
-
# $PGRMB,1,2,3,4,5,6,7,8,9*HH
|
280
|
-
#
|
281
|
-
# $PGRME,15.0,M,45.0,M,25.0,M*22
|
282
|
-
#
|
283
|
-
# $PGRMF,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15*HH
|
284
|
-
#
|
285
|
-
# $PGRMM,Astrln Geod '66*51
|
286
|
-
# $PGRMM,NAD27 Canada*2F
|
287
|
-
#
|
288
|
-
# $PGRMT,1,2,3,4,5,6,7,8,9*HH
|
289
|
-
#
|
290
|
-
# $PGRMV,1,2,3*HH
|
291
|
-
#
|
292
|
-
# $PGRMZ,246,f,3*1B
|
293
|
-
#
|
294
|
-
# $PGRMZ,93,f,3*21
|
295
|
-
# $PGRMZ,201,f,3*18
|
296
|
-
#
|
297
|
-
#
|
298
|
-
end
|