Class: Argus::ATCommander
- Inherits:
-
Object
- Object
- Argus::ATCommander
- Defined in:
- lib/argus/at_commander.rb
Instance Attribute Summary collapse
-
#timestamps ⇒ Object
readonly
Returns the value of attribute timestamps.
Instance Method Summary collapse
- #comwdg ⇒ Object (also: #reset_watchdog)
- #config(key, value) ⇒ Object
- #ctrl(mode) ⇒ Object
-
#initialize(sender) ⇒ ATCommander
constructor
A new instance of ATCommander.
- #interval=(new_interval) ⇒ Object
- #join ⇒ Object
- #pcmd(data) ⇒ Object
- #ref(data) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(sender) ⇒ ATCommander
Returns a new instance of ATCommander.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/argus/at_commander.rb', line 7 def initialize(sender) @sender = sender @seq = 0 @ref_data = "0" @pcmd_data = "0,0,0,0,0" @buffer = "" @thread = nil @interval = 0.020 @mutex = Mutex.new @timestamps = [] end |
Instance Attribute Details
#timestamps ⇒ Object (readonly)
Returns the value of attribute timestamps.
5 6 7 |
# File 'lib/argus/at_commander.rb', line 5 def @timestamps end |
Instance Method Details
#comwdg ⇒ Object Also known as: reset_watchdog
65 66 67 68 69 |
# File 'lib/argus/at_commander.rb', line 65 def comwdg @mutex.synchronize do command("COMWDG") end end |
#config(key, value) ⇒ Object
59 60 61 62 63 |
# File 'lib/argus/at_commander.rb', line 59 def config(key, value) @mutex.synchronize do command("CONFIG", "\"#{key}\",\"#{value}\"") end end |
#ctrl(mode) ⇒ Object
72 73 74 75 76 |
# File 'lib/argus/at_commander.rb', line 72 def ctrl(mode) @mutex.synchronize do command("CTRL", "#{mode},0") end end |
#interval=(new_interval) ⇒ Object
47 48 49 |
# File 'lib/argus/at_commander.rb', line 47 def interval=(new_interval) @mutex.synchronize do @interval = new_interval end end |
#join ⇒ Object
43 44 45 |
# File 'lib/argus/at_commander.rb', line 43 def join @thread.join if @thread end |
#pcmd(data) ⇒ Object
55 56 57 |
# File 'lib/argus/at_commander.rb', line 55 def pcmd(data) @mutex.synchronize do @pcmd_data = data end end |
#ref(data) ⇒ Object
51 52 53 |
# File 'lib/argus/at_commander.rb', line 51 def ref(data) @mutex.synchronize do @ref_data = data end end |
#start ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/argus/at_commander.rb', line 19 def start @running = true @thread = Thread.new do while @running log_time tick sleep @interval end end end |
#stop ⇒ Object
39 40 41 |
# File 'lib/argus/at_commander.rb', line 39 def stop @running = false end |
#tick ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/argus/at_commander.rb', line 30 def tick @mutex.synchronize do packet do command("REF", @ref_data) command("PCMD", @pcmd_data) end end end |