gpsd_baud_rate 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acdc0604312e1797841f53b9925306879c7033d06c66121669e34427f78d8e42
4
- data.tar.gz: 2fb9cfbfa998def80fdd4adfa08a3e0970ae43bb76b3231fb26bdb73c015233d
3
+ metadata.gz: 16dfe1b4f78b68d169e579548fc6fece7cd65dbbd1114f70865af22069418887
4
+ data.tar.gz: 90a67d3bc104cd38623b856e05d3585e5ef4272de86b3a7aafcc7ebf01b5b166
5
5
  SHA512:
6
- metadata.gz: bf0297ffc543ce07e7c3553ba421680aa0029933e4d27141a913e16cd55e200aae28aed51f2058a48ba601ecc52ec9538efa32edc255c094fab855a9c7bc01a6
7
- data.tar.gz: 11a1a01b429f81a75ae24f8eeeba8fd863d9ac5cfc4b98423ed6e98e739651c6a02f957b789e882024c029bfaa113b568d08995cea6f5a1eca5eb921024807e8
6
+ metadata.gz: 44c84a67ac0ab6f83ed61c3bf1cc75fac39ee958707b8e763ccb6cffa493a2535db77a2646457447eceb1adf97be7f605fa59449c666d729cc6ac752ef04b36d
7
+ data.tar.gz: 001663ed32e69d5d9353de94faa783ef307d0b3b60d695117df7e3de85052944c61b4b590c8d3ebb4febdde8a2dbce5a482ee02f1016132779578dbe43768b06
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gpsd_baud_rate (0.1.4)
4
+ gpsd_baud_rate (0.1.5)
5
5
  serialport (~> 1.3)
6
6
 
7
7
  GEM
@@ -1,5 +1,6 @@
1
1
  require "gpsd_baud_rate/version"
2
2
  require "serialport"
3
+ require 'logger'
3
4
 
4
5
 
5
6
  class GpsdBaudRate
@@ -17,41 +18,40 @@ class GpsdBaudRate
17
18
 
18
19
  def initialize goal_rate = @@baud_rates[0]
19
20
 
20
- # puts "\n\n\n"
21
+ # @@logger.debug "\n\n\n"
21
22
 
22
23
  # pid= %x|pgrep -f "ruby /home/deploy/bin/set_baud.rb"|
23
- # puts "Pid: #{pid}, $$: #{$$}, $BASHPID: #{$BASHPID}"
24
+ # @@logger.debug "Pid: #{pid}, $$: #{$$}, $BASHPID: #{$BASHPID}"
24
25
 
25
26
  @goal_rate = goal_rate.to_i
26
27
  @@logger.debug "Hello from gpsd_baud_rate!"
27
28
  @@logger.debug "Goal_rate: #{@goal_rate}"
28
29
 
29
- =begin
30
+
30
31
  gpsd_start unless gpsd_active? #make sure it's running
31
32
 
32
- puts "Service Status: #{gpsd_active?}"
33
- puts "Baud Rate: #{@active_rate = baud_rate}"
33
+ @@logger.debug "Service Status: #{gpsd_active?}"
34
+ @@logger.debug "Baud Rate: #{@active_rate = baud_rate}"
34
35
  gpsd_stop
35
- puts "Service Status: #{gpsd_active?}"
36
- puts "Baud Rate: #{@inactive_rate = baud_rate}"
36
+ @@logger.debug "Service Status: #{gpsd_active?}"
37
+ @@logger.debug "Baud Rate: #{@inactive_rate = baud_rate}"
37
38
 
38
- puts "\n~~~~~~~~~~~~ Read at #{@active_rate} baud ~~~~~~~~~~~~~~"
39
+ @@logger.debug "\n~~~~~~~~~~~~ Read at #{@active_rate} baud ~~~~~~~~~~~~~~"
39
40
  if (read_from_device @active_rate) && (@active_rate != @goal_rate)
40
- puts "Setting Goal Rate (#{goal_rate})"
41
+ @@logger.debug "Setting Goal Rate (#{goal_rate})"
41
42
  set_PMTK_baud_rate @goal_rate
42
43
  if read_from_device @goal_rate
43
- puts "Goal Baud Rate (#{@goal_rate}) has been set"
44
+ @@logger.debug "Goal Baud Rate (#{@goal_rate}) has been set"
44
45
  end
45
46
  else
46
- puts "Already at Goal Baud Rate"
47
+ @@logger.debug "Already at Goal Baud Rate"
47
48
  end
48
49
 
49
50
 
50
51
  #
51
52
  # Cleanup
52
53
  gpsd_start
53
- puts "Service Status: #{gpsd_active?}"
54
- =end
54
+ @@logger.debug "Service Status: #{gpsd_active?}"
55
55
  end #initiallize
56
56
 
57
57
  #~~~~~~~~~~~~~~~~~~~~~ gosd_status ~~~~~~~~~~~~~~~~~
@@ -89,7 +89,7 @@ class GpsdBaudRate
89
89
  # returns original baud_rate
90
90
  def baud_rate=( b_rate)
91
91
  msg= %x| sudo stty #{b_rate} -F "#{@@device}"|
92
- msg.each {|m| puts m}
92
+ msg.each {|m| @@logger.debug m}
93
93
  end
94
94
 
95
95
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -111,20 +111,20 @@ class GpsdBaudRate
111
111
  count = 0
112
112
  ser = SerialPort.open(@@device, baud.to_i, 8, 1, SerialPort::NONE ) { |ser|
113
113
  ser.read_timeout = 900
114
- puts "ReadTimeout: #{ser.read_timeout} ms"
114
+ @@logger.debug "ReadTimeout: #{ser.read_timeout} ms"
115
115
  5.times { results << ser.readline(100)}
116
- results.each { |s| puts s}
116
+ results.each { |s| @@logger.debug s}
117
117
  results.each do |r|
118
118
  count += 1 if @@NMEA_sentences.any? { |s| s == r[0,6]}
119
119
  end
120
- puts "Count: #{count}"
120
+ @@logger.debug "Count: #{count}"
121
121
  }
122
122
  rescue IOError => e
123
- puts "IOError: #{e.inspect}"
123
+ @@logger.debug "IOError: #{e.inspect}"
124
124
  rescue => e
125
- puts "Error: #{e.inspect}"
125
+ @@logger.debug "Error: #{e.inspect}"
126
126
  end
127
- puts "SerialPort Closed"
127
+ @@logger.debug "SerialPort Closed"
128
128
  gpsd_start
129
129
  count >= 2
130
130
  end
@@ -134,54 +134,54 @@ class GpsdBaudRate
134
134
  results=[]
135
135
 
136
136
  begin
137
- puts "Send to device"
137
+ @@logger.debug "Send to device"
138
138
  ser = SerialPort.open( @@device, baud, 8, 1, SerialPort::NONE) { |ser|
139
139
  count = ser.write cmmd+"\r\n"
140
140
  }
141
141
  rescue IOError => e
142
- puts "IOError: #{e.inspect}"
142
+ @@logger.debug "IOError: #{e.inspect}"
143
143
  rescue => e
144
- puts "Error: #{e.inspect}"
144
+ @@logger.debug "Error: #{e.inspect}"
145
145
  end
146
- puts "Bytes Written: #{count}"
146
+ @@logger.debug "Bytes Written: #{count}"
147
147
 
148
148
  begin
149
- puts "Receive response"
149
+ @@logger.debug "Receive response"
150
150
  ser = SerialPort.open( @@device, @goal_rate, 8, 1, SerialPort::NONE) { |ser|
151
151
  ser.read_timeout = 900
152
152
  10.times {results << ser.readline(100)}
153
153
  }
154
154
  rescue IOError => e
155
- puts "IOError: #{e.inspect}"
155
+ @@logger.debug "IOError: #{e.inspect}"
156
156
  rescue => e
157
- puts "Error: #{e.inspect}"
157
+ @@logger.debug "Error: #{e.inspect}"
158
158
  end
159
- results.each { |r| puts "Results: #{r}"}
159
+ results.each { |r| @@logger.debug "Results: #{r}"}
160
160
 
161
161
  end
162
162
 
163
163
 
164
164
  def find_baud_rate
165
- puts %x| sudo stty -F "#{@@device}"|
165
+ @@logger.debug %x| sudo stty -F "#{@@device}"|
166
166
  gpsd_stop
167
- puts %x|sudo stty -F "#{@@device}"|
167
+ @@logger.debug %x|sudo stty -F "#{@@device}"|
168
168
  gpsd_start
169
169
  end
170
170
 
171
171
  def set_PMTK_baud_rate rate
172
- puts "In set_PMTK_baud_rate"
172
+ @@logger.debug "In set_PMTK_baud_rate"
173
173
  type = 251
174
174
  cmmd = nmea_checksum("PMTK#{type},#{rate}")
175
175
  write_to_device cmmd, @active_rate
176
176
  end
177
177
 
178
178
  def nmea_checksum cmmd
179
- puts "In nmea_checksum, cmmd: #{cmmd}"
179
+ @@logger.debug "In nmea_checksum, cmmd: #{cmmd}"
180
180
  sum=0
181
181
  cmmd.each_byte { |i| sum = sum ^ i.ord}
182
182
  sum = sum & 0xff
183
183
  new_cmmd = "\$#{cmmd}*#{sum.to_s(16)}".upcase
184
- puts "new_cmmd: #{new_cmmd}"
184
+ @@logger.debug "new_cmmd: #{new_cmmd}"
185
185
  new_cmmd
186
186
  end
187
187
 
@@ -1,3 +1,3 @@
1
1
  class GpsdBaudRate
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpsd_baud_rate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Finnegan