ruboty-pi_gpio 0.1.1 → 0.1.2
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/.gitignore +1 -0
- data/README.md +3 -7
- data/images/ss.png +0 -0
- data/lib/ruboty/pi_gpio/actions/base.rb +12 -0
- data/lib/ruboty/pi_gpio/actions/mode.rb +2 -3
- data/lib/ruboty/pi_gpio/actions/read.rb +3 -3
- data/lib/ruboty/pi_gpio/actions/write.rb +2 -3
- data/lib/ruboty/pi_gpio/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5277d61c5fc39199fcb1ba9dd02b5a8cf7301e3f
|
4
|
+
data.tar.gz: 5fce6dc8615971328b4bb83541282cc31a738931
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c909882b16b1fef8f18c7f7d8648be395b932322e18b95083dcf832e7481a38b9a443ec46984b8cacffc08437e464ebc496f0b4d5b589a17664f689f5ae9eba
|
7
|
+
data.tar.gz: ced0469dc0d634540b9fb31469c5836c472554ba29f7d7921494b8dbe3c5b8eb652f85eb53a27d9402d133ca0560976f8e56b5d6376a940dc30e64c23e52f0f0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# Ruboty::PiGpio
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruboty/pi_gpio`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
Control GPIO of Raspberry PI via [Ruboty](https://github.com/r7kamura/ruboty).
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -21,8 +18,7 @@ Or install it yourself as:
|
|
21
18
|
$ gem install ruboty-pi_gpio
|
22
19
|
|
23
20
|
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
21
|
+

|
26
22
|
|
27
23
|
## Development
|
28
24
|
|
@@ -32,7 +28,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
28
|
|
33
29
|
## Contributing
|
34
30
|
|
35
|
-
1. Fork it ( https://github.com/
|
31
|
+
1. Fork it ( https://github.com/izumin5210/ruboty-pi_gpio/fork )
|
36
32
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
33
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
34
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/images/ss.png
ADDED
Binary file
|
@@ -10,10 +10,22 @@ module Ruboty
|
|
10
10
|
|
11
11
|
def export
|
12
12
|
open('/sys/class/gpio/export', 'w') { |f| f.write(pin) }
|
13
|
+
rescue => e
|
14
|
+
log(e)
|
13
15
|
end
|
14
16
|
|
15
17
|
def unexport
|
16
18
|
open('/sys/class/gpio/unexport', 'w') { |f| f.write(pin) }
|
19
|
+
rescue => e
|
20
|
+
log(e)
|
21
|
+
end
|
22
|
+
|
23
|
+
def log(e = nil)
|
24
|
+
Ruboty.logger.info(message.body)
|
25
|
+
unless e.nil?
|
26
|
+
Ruboty.logger.error(e.message)
|
27
|
+
Ruboty.logger.error(e.backtrace.join("\n") + "\n")
|
28
|
+
end
|
17
29
|
end
|
18
30
|
end
|
19
31
|
end
|
@@ -5,15 +5,14 @@ module Ruboty
|
|
5
5
|
def call
|
6
6
|
export
|
7
7
|
set_mode
|
8
|
-
message.reply("Set GPIO#{pin} to #{mode} successfully")
|
9
|
-
rescue
|
10
|
-
message.reply("Failed to set GPIO#{pin} to #{mode}")
|
11
8
|
end
|
12
9
|
|
13
10
|
private
|
14
11
|
|
15
12
|
def set_mode
|
16
13
|
open("/sys/class/gpio/gpio#{pin}/direction", 'w') { |f| f.write(mode) }
|
14
|
+
rescue => e
|
15
|
+
log(e)
|
17
16
|
end
|
18
17
|
|
19
18
|
def mode
|
@@ -3,15 +3,15 @@ module Ruboty
|
|
3
3
|
module Actions
|
4
4
|
class Read < Base
|
5
5
|
def call
|
6
|
-
message.reply(
|
7
|
-
rescue
|
8
|
-
message.reply("Failed to get GPIO#{pin} value")
|
6
|
+
message.reply(value)
|
9
7
|
end
|
10
8
|
|
11
9
|
private
|
12
10
|
|
13
11
|
def value
|
14
12
|
File.read("/sys/class/gpio/gpio#{pin}/value")
|
13
|
+
rescue => e
|
14
|
+
log(e)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -7,15 +7,14 @@ module Ruboty
|
|
7
7
|
|
8
8
|
def call
|
9
9
|
set_value
|
10
|
-
message.reply("Set GPIO#{pin} to #{value} successfully")
|
11
|
-
rescue
|
12
|
-
message.reply("Failed to set GPIO#{pin} to #{value}")
|
13
10
|
end
|
14
11
|
|
15
12
|
private
|
16
13
|
|
17
14
|
def set_value
|
18
15
|
open("/sys/class/gpio/gpio#{pin}/value", 'w') { |f| f.write(value) }
|
16
|
+
rescue => e
|
17
|
+
log(e)
|
19
18
|
end
|
20
19
|
|
21
20
|
def value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-pi_gpio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- izumin5210
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- Rakefile
|
68
68
|
- bin/console
|
69
69
|
- bin/setup
|
70
|
+
- images/ss.png
|
70
71
|
- lib/ruboty/handlers/pi_gpio.rb
|
71
72
|
- lib/ruboty/pi_gpio.rb
|
72
73
|
- lib/ruboty/pi_gpio/actions/base.rb
|