serialport_gps 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/lib/serialport_gps.rb +77 -0
- data.tar.gz.sig +0 -0
- metadata +110 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7cf834c9fd4965f0c1b3f13a4c43535f09eec5a
|
4
|
+
data.tar.gz: f680d77a1081a32dd6658d15f764a0b690e3fcc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9204ff8ed73f0e8357c05d06c22818880b52698be7e8662ab8aaf5b8cd838ac052c2a613ddc0643f3bba4aa733bc2d75e02a19fb8ad35a23c29dc122635575ff
|
7
|
+
data.tar.gz: 04226a3063ba2d0c592d6acdbb3c0336ad85b112696b99240088c55f16e3f2337e1766697264b01cc95335312dde3f190a9018fe3707a510180fbddca5180f46
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: serialport_gps.rb
|
4
|
+
|
5
|
+
require 'nmea_parser'
|
6
|
+
require 'run_every'
|
7
|
+
require 'serialport'
|
8
|
+
|
9
|
+
class SerialPortGPS
|
10
|
+
|
11
|
+
attr_reader :time, :latitude, :longitude, :to_h
|
12
|
+
|
13
|
+
def initialize(port: "/dev/ttyAMA0", baud_rate: 9600,
|
14
|
+
refresh_rate: 8, callback: Proc.new {puts self.to_h.inspect})
|
15
|
+
|
16
|
+
|
17
|
+
# if the refresh rate is any less than 8 seconds the serial connection
|
18
|
+
# will have a higher probability of containing corrupted data
|
19
|
+
|
20
|
+
refresh_rate = 8 if refresh_rate < 8
|
21
|
+
@refresh_rate = refresh_rate - 4
|
22
|
+
@callback = callback
|
23
|
+
|
24
|
+
#params for serial port
|
25
|
+
@port = port
|
26
|
+
@baud_rate = baud_rate
|
27
|
+
@data_bits = 8
|
28
|
+
@stop_bits = 1
|
29
|
+
@parity = SerialPort::NONE
|
30
|
+
|
31
|
+
@np = NMEAParser.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def start
|
35
|
+
|
36
|
+
@running = true
|
37
|
+
#sp = @sp
|
38
|
+
|
39
|
+
RunEvery.new(seconds: @refresh_rate) do
|
40
|
+
|
41
|
+
Thread.stop unless @running
|
42
|
+
|
43
|
+
begin
|
44
|
+
|
45
|
+
sp = SerialPort.new(@port, @baud_rate, @data_bits, @stop_bits, @parity)
|
46
|
+
sleep 4
|
47
|
+
s = ''
|
48
|
+
|
49
|
+
(s = sp.gets; @np.parse(s.scrub)) until s =~ /^\$GPGGA/
|
50
|
+
|
51
|
+
rescue
|
52
|
+
puts 'warning: ' +($!).inspect
|
53
|
+
retry
|
54
|
+
end
|
55
|
+
|
56
|
+
sp.close
|
57
|
+
|
58
|
+
@time, @latitude, @longitude = @np.time, @np.latitude, @np.longitude
|
59
|
+
@to_h = @np.to_h
|
60
|
+
@callback.call
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def stop()
|
66
|
+
|
67
|
+
@running = false
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
if __FILE__ == $0 then
|
74
|
+
|
75
|
+
gps = SerialPortGPS.new
|
76
|
+
gps.start
|
77
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serialport_gps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDmDCCAoCgAwIBAgIBATANBgkqhkiG9w0BAQUFADBJMRIwEAYDVQQDD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fyf6GFty3sW9Dzt16CVWROHxNivTJOZ8caUEi1ZiTpQA
|
29
|
+
nH+orEuALR7Ij3KNElz/Z5h6/wFA14MzcnwLgvtUVJVQ3U4tgoPAkNIPgCFyWlWH
|
30
|
+
2CpeHHPCDD4w/jiogUijTb137uYhI+eu3+t+63Um2FWuzhBB4BhoNDsuQ0G/3TTI
|
31
|
+
ewjgWJOdFqxFejbi9KWKC5p41B61CLUVpBaNg+MMy6q1GwkifCJIdi2tKu5b/O0K
|
32
|
+
Z4KfhyVeTsL078HV
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2014-07-05 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: nmea_parser
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: run_every
|
52
|
+
requirement: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: serialport
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description:
|
79
|
+
email: james@r0bertson.co.uk
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files: []
|
83
|
+
files:
|
84
|
+
- lib/serialport_gps.rb
|
85
|
+
homepage: https://github.com/jrobertson/serialport_gps
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.1.2
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.2
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Fetches, and converts GPS coordinates using the SerialPort gem.
|
109
|
+
test_files: []
|
110
|
+
has_rdoc:
|
metadata.gz.sig
ADDED
Binary file
|