apiotics_factory 1.0.25 → 1.0.26
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/apiotics_factory/version.rb +1 -1
- data/lib/templates/grove_pi/grove_pi.rb +15 -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: d5c9051459fbe1b16c9546eda84eb619ef9cd1d4
|
4
|
+
data.tar.gz: e42e961590f9b730f480f98b234f435fa2053501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17235765df5bddc91dfdacafb016b9828b400f4268f781fcd75375bcf6fefde59ca2a7acc54a0a99873ba6cb5111ab0cccbbfb833c41b85a5d4bc2fb88af3c4d
|
7
|
+
data.tar.gz: 137f7c38ed3766db8be1c54423d9155a2ff92cf1f7cd807adb1841b618c5ef5a35c317be3ffd2f55f9b79273e29a19ecd1a9eef8023de6c33db70aee6c2bdf1e
|
@@ -62,6 +62,7 @@ module GrovePi
|
|
62
62
|
|
63
63
|
# Initialize the lock file path.
|
64
64
|
LOCK_FILE_PATH = "/tmp/grove"
|
65
|
+
LOCK_REQUEST_PATH = "/tmp/lock_request"
|
65
66
|
|
66
67
|
# The initialized I2C object.
|
67
68
|
@_i2c_grove_pi = nil
|
@@ -69,6 +70,8 @@ module GrovePi
|
|
69
70
|
# Initialize i2c file path
|
70
71
|
@@_i2c_device_file = nil
|
71
72
|
|
73
|
+
# Initialize lock request flag
|
74
|
+
@@_lock_request = nil
|
72
75
|
|
73
76
|
|
74
77
|
# Storage for I2C slave addresses present on ports I2C-1, I2C-2 or I2C-3.
|
@@ -133,17 +136,28 @@ module GrovePi
|
|
133
136
|
while cycle == true
|
134
137
|
begin
|
135
138
|
#puts "Getting lock."
|
136
|
-
|
139
|
+
unless @@_lock_request == false && File.exist?(LOCK_REQUEST_PATH)
|
140
|
+
@@_i2c_device_file = File.open(LOCK_FILE_PATH, File::WRONLY|File::CREAT|File::EXCL)
|
141
|
+
if @@_lock_request == true
|
142
|
+
File.delete(LOCK_REQUEST_PATH)
|
143
|
+
end
|
144
|
+
@@_lock_request = false
|
145
|
+
end
|
137
146
|
if wait == true
|
138
147
|
i = 0
|
139
148
|
while i < 1000000
|
140
149
|
i += 1
|
141
150
|
end
|
151
|
+
wait = false
|
142
152
|
end
|
143
153
|
cycle = false
|
144
154
|
#puts "Lock acquired."
|
145
155
|
rescue
|
146
156
|
#puts "Could not get lock."
|
157
|
+
unless File.exist?(LOCK_REQUEST_PATH)
|
158
|
+
File.open(LOCK_REQUEST_PATH, File::WRONLY|File::CREAT)
|
159
|
+
end
|
160
|
+
@@_lock_request = true
|
147
161
|
wait = true
|
148
162
|
end
|
149
163
|
end
|