farmbot-serial 0.3.4 → 0.3.5
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 +3 -6
- data/spec/lib/arduino_spec.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9814e7945963d41edb78b97969bac32d1f551ba2
|
4
|
+
data.tar.gz: 267607eb384a3c676d7fb0d079f4d739ed2119d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c1834a9727e23b93da62767de109bb95b05274fbcc73489cf5772b5f3bc97e811d68183b727df1722b2d00544e4c6c34fea245aa1c0e779e0714dbc9539f2f
|
7
|
+
data.tar.gz: f7d001d3d43026d26ce181feb2e50ccf2ba1c1efaa8e3fdb2e843110bb3c53a701e34e210cb7605bf92ce23481778e5b3a9f896d7a1e505b8eb6929825695f93
|
data/lib/arduino.rb
CHANGED
@@ -61,17 +61,14 @@ module FB
|
|
61
61
|
Position.new(status[:X], status[:Y], status[:Z])
|
62
62
|
end
|
63
63
|
|
64
|
-
def maybe_execute_command
|
65
|
-
pop_gcode_off_queue if status.ready?
|
66
|
-
end
|
67
|
-
|
68
64
|
def next_cmd
|
69
65
|
outbound_queue.first
|
70
66
|
end
|
71
67
|
|
72
|
-
def
|
68
|
+
def maybe_execute_command
|
73
69
|
gcode = @outbound_queue.pop
|
74
|
-
|
70
|
+
return unless gcode
|
71
|
+
if status.ready? && gcode.is_a?(FB::Gcode) # Flip flop order for performance?
|
75
72
|
serial_port.puts gcode
|
76
73
|
status[:last] = gcode.name
|
77
74
|
status[:BUSY] = 1 # If not, pi will race arduino and "talk too fast"
|
data/spec/lib/arduino_spec.rb
CHANGED
@@ -66,7 +66,8 @@ describe FB::Arduino do
|
|
66
66
|
it 'pops gcode off queue' 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 { bot.maybe_execute_command }
|
70
71
|
expect(bot.outbound_queue.length).to eq(0)
|
71
72
|
expect(serial_port.message).to eq('A1 B2 C3')
|
72
73
|
expect(bot.status.ready?).to be_falsey
|
@@ -95,7 +96,7 @@ describe FB::Arduino do
|
|
95
96
|
|
96
97
|
it 'Flips out if a message is not a GCode object.' do
|
97
98
|
bot.outbound_queue.push "I don't think so!"
|
98
|
-
bot.
|
99
|
+
bot.maybe_execute_command
|
99
100
|
expect(logger.message).to eq("Outbound messages must be GCode objects. "\
|
100
101
|
"Use of String:\"I don't think so!\" is not permitted.")
|
101
102
|
end
|