farmbot-serial 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arduino.rb +4 -6
- data/spec/lib/arduino_spec.rb +2 -4
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06ce110c398cd6a9a9ffc89454d7de2127bd7627
|
4
|
+
data.tar.gz: 5be8458098c21f5b89255b876d10a3c349cde7bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ebc3d04479030e9bef35605e625bad436c8785ded69c77103ff2b627c542e00a20c46759393b40e85fe8322c4924eb85ff7a0094e69397665539c65f2aa0b2
|
7
|
+
data.tar.gz: 7aae26c6e3fa5fb346e0552c776c849248c0cdb014ed148700ff3fcf2407c2328bba12b6c5f877f88ca7f73d465974309cf24e9878a0061ba27c8a110be93f63
|
data/lib/arduino.rb
CHANGED
@@ -24,6 +24,8 @@ module FB
|
|
24
24
|
@commands = FB::OutgoingHandler.new(self)
|
25
25
|
@inputs = FB::IncomingHandler.new(self)
|
26
26
|
@status = FB::Status.new
|
27
|
+
|
28
|
+
start_event_listeners
|
27
29
|
end
|
28
30
|
|
29
31
|
# Log to screen/file/IO stream
|
@@ -64,6 +66,7 @@ module FB
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def maybe_execute_command
|
69
|
+
sleep 0.05 # Throttle CPU
|
67
70
|
gcode = @outbound_queue.pop
|
68
71
|
return unless gcode
|
69
72
|
if status.ready? && gcode.is_a?(FB::Gcode) # Flip flop order for performance?
|
@@ -77,6 +80,7 @@ module FB
|
|
77
80
|
end
|
78
81
|
|
79
82
|
def start_event_listeners
|
83
|
+
EM.tick_loop { maybe_execute_command }
|
80
84
|
status.onchange { |diff| @onchange.call(diff) if @onchange }
|
81
85
|
inbound_queue.subscribe do |gcodes|
|
82
86
|
Array(gcodes).each do |gcode|
|
@@ -86,12 +90,6 @@ module FB
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
|
-
def start
|
90
|
-
# A noble experiment.
|
91
|
-
EventMachine::PeriodicTimer.new(0.1) { maybe_execute_command }
|
92
|
-
start_event_listeners
|
93
|
-
end
|
94
|
-
|
95
93
|
private
|
96
94
|
|
97
95
|
# Highest priority method for processing incoming Gcode. Use for system
|
data/spec/lib/arduino_spec.rb
CHANGED
@@ -67,9 +67,7 @@ describe FB::Arduino do
|
|
67
67
|
bot.outbound_queue.push(command)
|
68
68
|
expect(bot.outbound_queue.length).to eq(1)
|
69
69
|
bot.status[:BUSY] = 0
|
70
|
-
within_event_loop {
|
71
|
-
bot.start
|
72
|
-
bot.maybe_execute_command }
|
70
|
+
within_event_loop { bot.maybe_execute_command }
|
73
71
|
expect(bot.outbound_queue.length).to eq(0)
|
74
72
|
expect(serial_port.message).to eq('A1 B2 C3')
|
75
73
|
expect(bot.status.ready?).to be_falsey
|
@@ -90,7 +88,7 @@ describe FB::Arduino do
|
|
90
88
|
called_onchange += 1
|
91
89
|
end
|
92
90
|
|
93
|
-
within_event_loop {
|
91
|
+
within_event_loop { nil }
|
94
92
|
|
95
93
|
expect(called_onmessage).to eq(1)
|
96
94
|
expect(called_onchange).to eq(1)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farmbot-serial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Evers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|