udooneorest 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/udooneorest.rb +12 -3
- data/lib/udooneorest/direction.rb +1 -1
- data/lib/udooneorest/validators.rb +5 -5
- data/lib/udooneorest/value.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34262ec7219cedb8d2adbe2f6572bc85051bddc1
|
4
|
+
data.tar.gz: 922373c8b181a581882583375c2eb718f518dfb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f981131c2732cc2064c0b88804fb5a76f0c3e24d43be544a70152c1b4b8bdfbea4cc8496939e039cb42630d00b37a74ec0c5f9bc6400a5ee309a5d6b6a7730c
|
7
|
+
data.tar.gz: 6c6ee991662b996d85f89eacc8b6b513ff33abffa6354b4db381a1edb08af1419659516b297c5c131cb21d8d245fd68b85ecd162e69c82ed4f9b6f8d2a15d2fa
|
data/lib/udooneorest.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative 'udooneorest/barometer'
|
|
11
11
|
require_relative 'udooneorest/temperature'
|
12
12
|
|
13
13
|
|
14
|
-
GPIOS = %w(106 107 180 181 172 173 182 124 25 22 14 15 16 17 18 19 20 21 203 202 177 176 175 174 119 124 127 116 7 6 5 4)
|
14
|
+
GPIOS = %w(178 179 104 143 142 141 140 149 105 148 146 147 100 102 NA NA 106 107 180 181 172 173 182 124 25 22 14 15 16 17 18 19 20 21 203 202 177 176 175 174 119 124 127 116 7 6 5 4)
|
15
15
|
HELP_URL = 'http://github.com/marksull/udooneorest'
|
16
16
|
BASE_PATH = '/sys/class/gpio/'
|
17
17
|
VALUE_LOW = '0'
|
@@ -79,7 +79,11 @@ module UdooNeoRest
|
|
79
79
|
# file : the file to cat
|
80
80
|
#
|
81
81
|
def self.cat(file)
|
82
|
-
|
82
|
+
begin
|
83
|
+
return File.read(file).chomp
|
84
|
+
rescue Exception => e
|
85
|
+
return nil
|
86
|
+
end
|
83
87
|
end
|
84
88
|
|
85
89
|
#############################################################################
|
@@ -133,7 +137,12 @@ module UdooNeoRest
|
|
133
137
|
# file : the file to cat
|
134
138
|
#
|
135
139
|
def self.cat_and_status(file)
|
136
|
-
UdooNeoRest::Base.
|
140
|
+
result = UdooNeoRest::Base.cat file
|
141
|
+
unless result.nil?
|
142
|
+
return UdooNeoRest::Base.status_ok result
|
143
|
+
end
|
144
|
+
|
145
|
+
return UdooNeoRest::Base.status_error 'GPIO/PIN could not be read. Have you already exported the GPIO/PIN?'
|
137
146
|
end
|
138
147
|
|
139
148
|
#############################################################################
|
@@ -64,7 +64,7 @@ module UdooNeoRest
|
|
64
64
|
return gpio_.error_message unless gpio_.valid?
|
65
65
|
|
66
66
|
# get the direction
|
67
|
-
UdooNeoRest::Base.
|
67
|
+
UdooNeoRest::Base.cat_and_status "#{BASE_PATH}gpio#{gpio}/direction"
|
68
68
|
end
|
69
69
|
|
70
70
|
#############################################################################
|
@@ -49,8 +49,8 @@ module UdooNeoRest
|
|
49
49
|
class ValidateGpio < Validate
|
50
50
|
|
51
51
|
def valid?
|
52
|
-
unless GPIOS.include?(@value)
|
53
|
-
@error_message = UdooNeoRest::Base.status_error("GPIO value of '#{@value}' is invalid. Should be one of #{GPIOS.sort.join(',')}.")
|
52
|
+
unless GPIOS.include?(@value) && (@value != 'NA')
|
53
|
+
@error_message = UdooNeoRest::Base.status_error("GPIO value of '#{@value}' is invalid. Should be one of #{(GPIOS - ['NA']).sort.join(',')}.")
|
54
54
|
return false
|
55
55
|
end
|
56
56
|
|
@@ -93,8 +93,8 @@ module UdooNeoRest
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def valid?
|
96
|
-
if (
|
97
|
-
@error_message = UdooNeoRest::Base.status_error("Pin value of
|
96
|
+
if (@value > 47) || (GPIOS[@value] == 'NA')
|
97
|
+
@error_message = UdooNeoRest::Base.status_error("Pin value of #{@value} is invalid. Please refer to UDOO Neo documentation.")
|
98
98
|
return false
|
99
99
|
end
|
100
100
|
|
@@ -107,7 +107,7 @@ module UdooNeoRest
|
|
107
107
|
#
|
108
108
|
def to_gpio
|
109
109
|
return nil unless valid?
|
110
|
-
GPIOS[@value
|
110
|
+
GPIOS[@value]
|
111
111
|
end
|
112
112
|
|
113
113
|
end
|
data/lib/udooneorest/value.rb
CHANGED
@@ -64,7 +64,7 @@ module UdooNeoRest
|
|
64
64
|
return gpio_.error_message unless gpio_.valid?
|
65
65
|
|
66
66
|
# Get the value
|
67
|
-
UdooNeoRest::Base.
|
67
|
+
UdooNeoRest::Base.cat_and_status "#{BASE_PATH}gpio#{gpio}/value"
|
68
68
|
end
|
69
69
|
|
70
70
|
#############################################################################
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: udooneorest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Sullivan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.2.
|
69
|
+
rubygems_version: 2.2.2
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Rest API for interacting with UDOO Neo
|