ruboty-pi_gpio 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruboty/pi_gpio/actions/base.rb +8 -0
- data/lib/ruboty/pi_gpio/actions/read.rb +9 -3
- data/lib/ruboty/pi_gpio/version.rb +1 -1
- 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: ce5fdece496978e95494680de50bae38b427cb62
|
4
|
+
data.tar.gz: 349332be9c40271c9044a386480490253833d400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3816299186b9524563cb5c1f4c74b1f16409f8c63ed73bcc9280ab469e8159292f5bd73dd9b7939d0db5f17480fb38beb6416ed0f35f33cc44bf93a855a56688
|
7
|
+
data.tar.gz: 915259760117f15ba6ea890054589c536016411a7e2123b6cb197fbdbcf25da93d0b9d6248bd1f4b1542719b7b10ad84dfcbd782b1601ee25df925decef91ca7
|
@@ -8,6 +8,10 @@ module Ruboty
|
|
8
8
|
message[:pin]
|
9
9
|
end
|
10
10
|
|
11
|
+
def robot
|
12
|
+
message.robot
|
13
|
+
end
|
14
|
+
|
11
15
|
def export
|
12
16
|
open('/sys/class/gpio/export', 'w') { |f| f.write(pin) }
|
13
17
|
rescue => e
|
@@ -27,6 +31,10 @@ module Ruboty
|
|
27
31
|
Ruboty.logger.error(e.backtrace.join("\n") + "\n")
|
28
32
|
end
|
29
33
|
end
|
34
|
+
|
35
|
+
def prefix
|
36
|
+
Ruboty::Action.prefix_pattern(robot.name)
|
37
|
+
end
|
30
38
|
end
|
31
39
|
end
|
32
40
|
end
|
@@ -2,19 +2,25 @@ module Ruboty
|
|
2
2
|
module PiGpio
|
3
3
|
module Actions
|
4
4
|
class Read < Base
|
5
|
+
include Mem
|
6
|
+
|
5
7
|
def call
|
6
|
-
message.
|
8
|
+
robot.receive(message.original.merge(body: body))
|
7
9
|
end
|
8
10
|
|
9
11
|
private
|
10
12
|
|
13
|
+
def body
|
14
|
+
"#{message.body[prefix]}GPIO#{pin} is #{value}"
|
15
|
+
end
|
16
|
+
|
11
17
|
def value
|
12
|
-
File.read("/sys/class/gpio/gpio#{pin}/value")
|
18
|
+
File.read("/sys/class/gpio/gpio#{pin}/value").chomp
|
13
19
|
rescue => e
|
14
20
|
log(e)
|
15
21
|
end
|
22
|
+
memoize :value
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
end
|
20
|
-
|