my_gpsd_client 0.02.03 → 0.02.04
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/lib/my_gpsd_client.rb +63 -10
- data/lib/my_gpsd_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4f1c4c5206353cb073d29786bcf42843ad23fc79db633a52db546311c7f94d
|
4
|
+
data.tar.gz: d460dbb1f143ed168e897b61e957e071bf5ee050c54698b22c8cec2efa32e4c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7fa5f1b82865b37d52c00e509ea4dc3dd2cc4f73d85f60dcd07d7ff9c77f137d21b2d04aa29dda38f34b82d18452ea054db7da73142390e792e53b82fb2a901
|
7
|
+
data.tar.gz: 506bcb5d6b8d151709a3419768940151d05add153719457d56cd84a69b40d44c21c074c8952e44dc734154b068eb768e935f97ed791cda1f30a625e462629d65
|
data/lib/my_gpsd_client.rb
CHANGED
@@ -5,14 +5,23 @@ require 'date'
|
|
5
5
|
require 'logger'
|
6
6
|
|
7
7
|
class MyGpsdClient
|
8
|
-
attr_accessor :host, :port, :command, :
|
9
|
-
|
8
|
+
attr_accessor :host, :port, :command, :min_speed, :watchdog_max, :watchdog_force,
|
9
|
+
:log_progname, :log_level, :log_path, :log_format, :log_time_format
|
10
|
+
attr_reader :version, :last_watch, :socket_ready, :socket, :msg_counts, :watchdog_fired_count,
|
11
|
+
:readthread, :socket_init_thread, :watchdogthread, :watchdog_count
|
12
|
+
|
10
13
|
|
11
14
|
DEFAULT_HOST = 'localhost'
|
12
15
|
DEFAULT_PORT = 2947
|
13
|
-
DEFAULT_WATCH = {"enable":false,"json":false,"nmea":false}
|
14
|
-
DEFAULT_LOG_LEVEL = 0
|
16
|
+
DEFAULT_WATCH = {"class":"WATCH", "enable":false,"json":false,"nmea":false}
|
15
17
|
DEFAULT_WATCHDOG_MAX = 5.0
|
18
|
+
|
19
|
+
DEFAULT_LOG_PROGNAME = "MyGpsdClient"
|
20
|
+
DEFAULT_LOG_LEVEL = Logger::DEBUG
|
21
|
+
DEFAULT_LOG_PATH = 'log/MyGpsdClient.log'
|
22
|
+
DEFAULT_LOG_FORMAT = ''
|
23
|
+
DEFAULT_LOG_TIME_FORMAT = '%Y-%m-%d %T.%N %z %Z'
|
24
|
+
|
16
25
|
WATCHDOG_STEP = 0.1 # Check watchdog ten times per second
|
17
26
|
|
18
27
|
THREAD_NAMES = { # Keep displayed names the same length
|
@@ -23,6 +32,8 @@ class MyGpsdClient
|
|
23
32
|
}
|
24
33
|
Thread.current[:name]=THREAD_NAMES[:MainThread]
|
25
34
|
|
35
|
+
@@logger = nil
|
36
|
+
|
26
37
|
|
27
38
|
# A simple gpsd client that dump's json objects contianing all info received from the gpsd deamon
|
28
39
|
# you need to at least setup either the raw callback (on_raw_change) or position callback (on_position_change) to use GPSD2JSON. the raw callback just passes the json objects it received from the daemon on to the block you pass it. the on_position_change and on_satellites_change are a bit easier to use.
|
@@ -44,7 +55,12 @@ class MyGpsdClient
|
|
44
55
|
@host = host
|
45
56
|
@port = port
|
46
57
|
@last_watch = watch
|
58
|
+
|
47
59
|
@log_level = log_level
|
60
|
+
@log_path = DEFAULT_LOG_PATH
|
61
|
+
@log_format = DEFAULT_LOG_FORMAT
|
62
|
+
@log_time_format = DEFAULT_LOG_TIME_FORMAT
|
63
|
+
@log_progname = DEFAULT_LOG_PROGNAME
|
48
64
|
|
49
65
|
@socket = nil
|
50
66
|
@socket_ready = false
|
@@ -68,13 +84,12 @@ class MyGpsdClient
|
|
68
84
|
toff: 0, pol: 0, pps: 0, dev: 0, devs: 0, err: 0,
|
69
85
|
unk: 0}
|
70
86
|
|
71
|
-
|
72
|
-
MyGpsdClient.logger.level = @log_level
|
87
|
+
@logger = new_logger path: @log_path, progname: @log_progname, time_format: @log_time_format, level: @log_level
|
73
88
|
my_logger level: 'info', msg: "MyGpsdClient Gem - Version: #{@version}"
|
74
89
|
end
|
75
90
|
|
76
91
|
#
|
77
|
-
#
|
92
|
+
# attribute_writters additional actions
|
78
93
|
#
|
79
94
|
def command=(val)
|
80
95
|
@command = val
|
@@ -85,9 +100,34 @@ class MyGpsdClient
|
|
85
100
|
|
86
101
|
def log_level=(val)
|
87
102
|
@log_level = val
|
88
|
-
|
103
|
+
@logger.level = @log_level
|
104
|
+
end
|
105
|
+
|
106
|
+
def log_progname=(val)
|
107
|
+
@log_progname = val
|
108
|
+
@logger.progname = @log_progname
|
109
|
+
end
|
110
|
+
|
111
|
+
def log_format=(val)
|
112
|
+
@log_format = val
|
113
|
+
@logger.format = @log_format
|
114
|
+
end
|
115
|
+
|
116
|
+
def log_time_format=(val)
|
117
|
+
@log_time_format = val
|
118
|
+
@logger.datetime_format = @log_time_format
|
89
119
|
end
|
90
120
|
|
121
|
+
def log_path=(val)
|
122
|
+
@log_path = val
|
123
|
+
@logger = new_logger path: @log_path, progname: @log_progname, time_format: @log_time_format, level: @log_level
|
124
|
+
end
|
125
|
+
#
|
126
|
+
# End attribute_writters additional actions
|
127
|
+
#
|
128
|
+
|
129
|
+
|
130
|
+
|
91
131
|
def log_marker level: 'debug', msg: "Log Marker"
|
92
132
|
my_logger level: level, msg: "~~~~~~~~~~~~~~~~~~~~~~~ #{msg} ~~~~~~~~~~~~~~~~~~~~~~~"
|
93
133
|
end
|
@@ -185,6 +225,7 @@ class MyGpsdClient
|
|
185
225
|
@watchdog_count = 0.0
|
186
226
|
@watchdog_enabled = true
|
187
227
|
while @watchdog_enabled do
|
228
|
+
my_logger msg: "Watchdog Thread: Watchdog Tick"
|
188
229
|
if @watchdog_force
|
189
230
|
@watchdog_force = false
|
190
231
|
# force the watchdog to fire by killing the socket
|
@@ -452,16 +493,28 @@ LOG_LEVELS = {debug: Logger::DEBUG, info: Logger::INFO, warn: Logger::WARN,
|
|
452
493
|
error: Logger::ERROR, fatal: Logger::FATAL, unknown: Logger::UNKNOWN}
|
453
494
|
|
454
495
|
def my_logger(level: 'debug', msg: "Blank")
|
455
|
-
|
496
|
+
@logger.add (LOG_LEVELS[level.to_sym]) {"#{Thread.current[:name]} -- #{msg}"}
|
456
497
|
end
|
457
498
|
|
499
|
+
def new_logger( progname: nil, path:, format: nil, time_format: nil, level: LOG_LEVELS[:debug])
|
500
|
+
logger = Logger.new(path)
|
501
|
+
logger.progname = progname if progname
|
502
|
+
logger.format = format if format
|
503
|
+
logger.level = level if level
|
504
|
+
logger.datetime_format = time_format if time_format
|
505
|
+
logger
|
506
|
+
end
|
507
|
+
|
508
|
+
=begin
|
458
509
|
def self.logger
|
510
|
+
puts "In self.logger: log_path => #{@log_path}, @@logger.nil? => #{@@logger.nil?}"
|
459
511
|
@@logger ||= defined?(Rails) ? Rails.logger : Logger.new("log/MyGpsdClient.log")
|
512
|
+
puts "Exiting self.logger: @@logger => #{@@logger}"
|
460
513
|
end
|
461
514
|
|
462
515
|
def self.logger=(logger)
|
463
516
|
@@logger = logger
|
464
517
|
end
|
465
|
-
|
518
|
+
=end
|
466
519
|
|
467
520
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_gpsd_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.02.
|
4
|
+
version: 0.02.04
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Finnegan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|