nmea_gps 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/nmea_gps/gps.rb +19 -13
- data/lib/nmea_gps/version.rb +1 -1
- data/lib/nmea_gps.rb +3 -4
- data/nmea_gps.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 057dc086fbc62478f210459a628ca8837798717e
|
4
|
+
data.tar.gz: 4b4bdd5adf65ae06517a9c78db1ec70d1e8bd432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d32f4bdce6f704592d7be01c7ff2a2e00d1b342813649b65a16946de5daf3b540bfc8d922a2663230a304235d60ac68726e2f082f8ccf7710f968db36cadf3
|
7
|
+
data.tar.gz: 6d108b7a93ceed09b3050e36d75a92a0f1353293f20260769828759eb219f989c2741c64c6cc37da142bbe340586fac0e4323b748acac4a48f5a35390ea6b159
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Why another NMEA gem?
|
2
|
+
I was looking for a NMEA gem, but none of them I could find were written in the ruby-way.
|
3
|
+
I wanted to get GPS data pushed when it gets updated, so I created one.
|
4
|
+
|
1
5
|
## Installation
|
2
6
|
|
3
7
|
Add this line to your application's Gemfile:
|
@@ -16,6 +20,10 @@ Or install it yourself as:
|
|
16
20
|
|
17
21
|
```ruby
|
18
22
|
|
23
|
+
# set your zone if you want to get time in you local time zone.
|
24
|
+
# otherwise it will be UTC
|
25
|
+
Nmea::Config.time_zone = "Tokyo"
|
26
|
+
|
19
27
|
# create a serialport to your GPS receiver
|
20
28
|
# you should know how to open a connection between your GPS device
|
21
29
|
# mine runs on `9600 baudrate`, `8bit`, `1stop bit`, `none parity`
|
data/lib/nmea_gps/gps.rb
CHANGED
@@ -48,7 +48,7 @@ module Nmea
|
|
48
48
|
loop do
|
49
49
|
line = self.gps_serial_port.gets("\r\n").strip
|
50
50
|
# %w[ GLL RMC VTG GGA GSA GSV ZDA].join.chars.uniq.sort.join
|
51
|
-
|
51
|
+
next unless match = line.match(/\A\$#{TALKER_ID}([ACDGLMRSTVZ]{3})/)
|
52
52
|
|
53
53
|
sentence = match[1].downcase.to_sym
|
54
54
|
set[sentence] << line
|
@@ -60,20 +60,26 @@ module Nmea
|
|
60
60
|
def callback!
|
61
61
|
this_set = line_set
|
62
62
|
this_set.keys.each do |sentence|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
63
|
+
# TODO: error handling
|
64
|
+
begin
|
65
|
+
this_callback = self.callbacks[sentence]
|
66
|
+
next unless this_callback
|
67
|
+
|
68
|
+
target_class = "Nmea::Gps::#{sentence.to_s.camelcase}".constantize
|
69
|
+
|
70
|
+
object = if sentence == :gsv
|
71
|
+
this_set[sentence].sort.collect do |line|
|
72
|
+
target_class.new line
|
73
|
+
end
|
74
|
+
else
|
75
|
+
target_class.new(this_set[sentence].first)
|
71
76
|
end
|
72
|
-
else
|
73
|
-
target_class.new(this_set[sentence].first)
|
74
|
-
end
|
75
77
|
|
76
|
-
|
78
|
+
this_callback.call object
|
79
|
+
rescue => ex
|
80
|
+
puts "#{ex.message} sentence:#{sentence} / #{this_set[sentence]}"
|
81
|
+
puts ex.backtrace.join "\n"
|
82
|
+
end
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
data/lib/nmea_gps/version.rb
CHANGED
data/lib/nmea_gps.rb
CHANGED
@@ -4,21 +4,18 @@ require "ostruct"
|
|
4
4
|
|
5
5
|
require 'active_support'
|
6
6
|
require 'active_support/core_ext'
|
7
|
-
Time.zone = "UTC"
|
8
7
|
|
9
8
|
require "nmea_gps/version"
|
10
9
|
require "nmea_gps/config"
|
11
10
|
require "nmea_gps/gps"
|
12
11
|
|
13
|
-
require "nmea_gps/sentence_base"
|
14
|
-
Dir[Pathname(__FILE__).join("../sentences/*.rb")].each {|file| require file }
|
15
|
-
|
16
12
|
module Nmea
|
17
13
|
|
18
14
|
module UtcTimeable
|
19
15
|
protected
|
20
16
|
def hhmmss_to_local_time(text)
|
21
17
|
hh, mm, ss = text.chars.each_slice(2).collect{|chars| chars.join }
|
18
|
+
Time.zone = "UTC"
|
22
19
|
utc_today = Time.zone.today
|
23
20
|
Time.zone.local(utc_today.year, utc_today.month, utc_today.day, hh, mm, ss).
|
24
21
|
in_time_zone(Nmea::Config.time_zone)
|
@@ -38,3 +35,5 @@ module Nmea
|
|
38
35
|
|
39
36
|
end
|
40
37
|
|
38
|
+
require "nmea_gps/sentence_base"
|
39
|
+
Dir[Pathname(__FILE__).join("../nmea_gps/sentences/*.rb")].each {|file| require file }
|
data/nmea_gps.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["orenoimac@gmail.com"]
|
11
11
|
spec.summary = %q{NMEA GPS logs to trigger a callback on each NMEA 0183 sentence.}
|
12
12
|
spec.description = %q{add your serialport object, and you'll get callbacks every time the serialport gets logs.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/github0013/nmea_gps"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nmea_gps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ore
|
@@ -164,7 +164,7 @@ files:
|
|
164
164
|
- spec/nmea_gps_spec.rb
|
165
165
|
- spec/spec_helper.rb
|
166
166
|
- spec/utc_timeable_spec.rb
|
167
|
-
homepage:
|
167
|
+
homepage: https://github.com/github0013/nmea_gps
|
168
168
|
licenses:
|
169
169
|
- MIT
|
170
170
|
metadata: {}
|