lib/sgs/nmea.rb in sgslib-0.1.0 vs lib/sgs/nmea.rb in sgslib-0.2.1
- old
+ new
@@ -53,11 +53,11 @@
#
# Parse an NMEA string into its component parts.
def parse(str)
str.chomp!
- if str[0] != 36
+ if str[0] != "$"
return -1
end
str, sum = str[1..-1].split('*')
if sum.nil? or sum.to_i(16) != compute_csum(str)
return -1
@@ -78,11 +78,11 @@
def parse_gprmc
if @args.count < 12 or @args.count > 13
return nil
end
gps = SGS::GPS.new
- gps.valid = @args[2] == "A"
+ gps.is_valid if @args[2] == "A"
hh = @args[1][0..1].to_i
mm = @args[1][2..3].to_i
ss = @args[1][4..-1].to_f
us = (ss % 1.0 * 1000000)
ss = ss.to_i
@@ -90,11 +90,11 @@
mn = @args[9][2..3].to_i
yy = @args[9][4..5].to_i + 2000
gps.time = Time.gm(yy, mn, dd, hh, mm, ss, us)
gps.location = Location.parse ll_nmea(@args[3,4]), ll_nmea(@args[5,6])
gps.sog = @args[7].to_f
- gps.cmg = Bearing.degrees_to_radians @args[8].to_f
+ gps.cmg = Bearing.dtor @args[8].to_f
gps
end
#
# Output a GPRMC message
@@ -105,10 +105,10 @@
@args[1] = gps.time.strftime("%H%M%S.") + "%03d" % (gps.time.usec / 1000)
@args[2] = 'A'
@args.concat gps.location.latitude_array
@args.concat gps.location.longitude_array("%03d%07.4f")
@args[7] = "%.2f" % gps.sog
- @args[8] = "%.2f" % Bearing.radians_to_degrees(gps.cmg)
+ @args[8] = "%.2f" % Bearing.radians_to_d(gps.cmg)
@args[9] = gps.time.strftime("%d%m%y")
@args.concat ['', '']
@args << 'A'
end