farmbot-serial 0.2.2 → 0.2.3
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/arduino/incoming_handler.rb +1 -2
- data/lib/arduino/outgoing_handler.rb +1 -0
- data/lib/arduino/status.rb +14 -4
- data/lib/gcode.rb +4 -0
- 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: 7ab299472231f9765ad9f25cf45fbc9ee02a8daf
|
4
|
+
data.tar.gz: 61cdd2c8d32a6d5faea497d335b217c1113b4335
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 736508d897f2f552e277fbc3713eccab3075b3e73896177ba3c534e55750dbb31b0b08597d81cadd9150ee20eb78641b12d3d2fc365303cb2664c5740bd9d2ee
|
7
|
+
data.tar.gz: fd005c33a0519e801ef33ce4531ed1a474371f4c936b31860c2d50e57a1a7be5d52415eb5baada1b0fe8391390c8d8770dfd8ca6a904e5a210d905ccf7fac1e6
|
@@ -20,7 +20,6 @@ module FB
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def report_parameter_value(gcode)
|
23
|
-
# This is not correct. We need to store pin values in an array somewhere.
|
24
23
|
bot.status.gcode_update(gcode)
|
25
24
|
end
|
26
25
|
|
@@ -33,7 +32,7 @@ module FB
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def report_status_value(gcode)
|
36
|
-
bot.status.
|
35
|
+
bot.status.set_pin(gcode.value_of(:P), gcode.value_of(:V))
|
37
36
|
end
|
38
37
|
|
39
38
|
def received(gcode)
|
@@ -11,6 +11,7 @@ module FB
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def emergency_stop(*)
|
14
|
+
# This message is special- it is the only method that bypasses the queue.
|
14
15
|
bot.outbound_queue = [] # Dump pending commands.
|
15
16
|
bot.serial_port.puts "E" # Don't queue this one- write to serial line.
|
16
17
|
bot.status[:last] = :emergency_stop
|
data/lib/arduino/status.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module FB
|
2
2
|
class Status
|
3
3
|
# Map of informational status and default values for status within Arduino.
|
4
|
-
DEFAULT_INFO = {X: 0, Y: 0, Z: 0, S: 10,
|
5
|
-
W: 0, L: 0, E: 0, M: 0, XA: 0, XB: 0, YA: 0, YB: 0, ZA: 0,
|
6
|
-
ZB: 0,YR: 0, R: 0, BUSY: 1, LAST: 'none'}
|
4
|
+
DEFAULT_INFO = {X: 0, Y: 0, Z: 0, S: 10, BUSY: 1, LAST: 'none', PINS: {}}
|
7
5
|
Info = Struct.new(*DEFAULT_INFO.keys)
|
8
6
|
|
9
7
|
def initialize
|
@@ -36,7 +34,10 @@ module FB
|
|
36
34
|
|
37
35
|
def gcode_update(gcode)
|
38
36
|
transaction do
|
39
|
-
gcode.params.each
|
37
|
+
gcode.params.each do |p|
|
38
|
+
setter = "#{p.head}="
|
39
|
+
@info.send(setter, p.tail) if @info.respond_to?(setter)
|
40
|
+
end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -47,5 +48,14 @@ module FB
|
|
47
48
|
def ready?
|
48
49
|
self[:BUSY] == 0
|
49
50
|
end
|
51
|
+
|
52
|
+
def pin(num)
|
53
|
+
@info[:PINS][num] || :unknown
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_pin(num, val)
|
57
|
+
val = [true, 1, '1'].include?(val) ? :on : :off
|
58
|
+
transaction { |info| info.PINS[num] = val }
|
59
|
+
end
|
50
60
|
end
|
51
61
|
end
|
data/lib/gcode.rb
CHANGED
@@ -38,6 +38,10 @@ module FB
|
|
38
38
|
GcodeToken.new(cmd.any? ? cmd.first : "NULL0")
|
39
39
|
end
|
40
40
|
|
41
|
+
def value_of(param)
|
42
|
+
params.find{ |p| p.head == param.to_sym.upcase }.tail
|
43
|
+
end
|
44
|
+
|
41
45
|
# A head/tail pair of a single node of GCode. Ex: R01 = [:R, '01']
|
42
46
|
class GcodeToken
|
43
47
|
attr_reader :head, :tail
|