Class: Argus::ATCommander

Inherits:
Object
  • Object
show all
Defined in:
lib/argus/at_commander.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender) ⇒ ATCommander

Returns a new instance of ATCommander.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/argus/at_commander.rb', line 8

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

#intervalObject

Returns the value of attribute interval.



6
7
8
# File 'lib/argus/at_commander.rb', line 6

def interval
  @interval
end

#timestampsObject (readonly)

Returns the value of attribute timestamps.



5
6
7
# File 'lib/argus/at_commander.rb', line 5

def timestamps
  @timestamps
end

Instance Method Details

#comwdgObject Also known as: reset_watchdog



62
63
64
65
66
# File 'lib/argus/at_commander.rb', line 62

def comwdg
  @mutex.synchronize do
    command("COMWDG")
  end
end

#config(key, value) ⇒ Object



56
57
58
59
60
# File 'lib/argus/at_commander.rb', line 56

def config(key, value)
  @mutex.synchronize do
    command("CONFIG", "\"#{key}\",\"#{value}\"")
  end
end

#ctrl(mode) ⇒ Object



69
70
71
72
73
# File 'lib/argus/at_commander.rb', line 69

def ctrl(mode)
  @mutex.synchronize do
    command("CTRL", "#{mode},0")
  end
end

#joinObject



44
45
46
# File 'lib/argus/at_commander.rb', line 44

def join
  @thread.join if @thread
end

#pcmd(data) ⇒ Object



52
53
54
# File 'lib/argus/at_commander.rb', line 52

def pcmd(data)
  @mutex.synchronize do @pcmd_data = data end
end

#ref(data) ⇒ Object



48
49
50
# File 'lib/argus/at_commander.rb', line 48

def ref(data)
  @mutex.synchronize do @ref_data = data end
end

#startObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/argus/at_commander.rb', line 20

def start
  @running = true
  @thread = Thread.new do
    while @running
      log_time
      tick
      sleep @interval
    end
  end
end

#stopObject



40
41
42
# File 'lib/argus/at_commander.rb', line 40

def stop
  @running = false
end

#tickObject



31
32
33
34
35
36
37
38
# File 'lib/argus/at_commander.rb', line 31

def tick
  @mutex.synchronize do
    packet do
      command("REF", @ref_data)
      command("PCMD", @pcmd_data)
    end
  end
end