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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0590af716d23cb629ad4def4bea23c2e0a925c17'
4
- data.tar.gz: c782f6364204665a8a538dd30ac5fa886c4632a7
3
+ metadata.gz: d5c9051459fbe1b16c9546eda84eb619ef9cd1d4
4
+ data.tar.gz: e42e961590f9b730f480f98b234f435fa2053501
5
5
  SHA512:
6
- metadata.gz: 95761531428a001435e8372542b088f3250c2b5d2727bae9722ff455510f106a27b72087f7e3c4a0732fb9afe3a8b62ce5a001e70e8dd312beb1cb43cafb8c09
7
- data.tar.gz: 3fd9d5048d5e12be4e0a6ffed3e35be43c40e0a993d621a7d8b1e0064359da6e14c57ce5c60333f2895ca4c91025e1f2d39b0d3f1f182f7f98353026d1a9791a
6
+ metadata.gz: 17235765df5bddc91dfdacafb016b9828b400f4268f781fcd75375bcf6fefde59ca2a7acc54a0a99873ba6cb5111ab0cccbbfb833c41b85a5d4bc2fb88af3c4d
7
+ data.tar.gz: 137f7c38ed3766db8be1c54423d9155a2ff92cf1f7cd807adb1841b618c5ef5a35c317be3ffd2f55f9b79273e29a19ecd1a9eef8023de6c33db70aee6c2bdf1e
@@ -1,3 +1,3 @@
1
1
  module ApioticsFactory
2
- VERSION = '1.0.25'
2
+ VERSION = '1.0.26'
3
3
  end
@@ -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
- @@_i2c_device_file = File.open(LOCK_FILE_PATH, File::WRONLY|File::CREAT|File::EXCL)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiotics_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.25
4
+ version: 1.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apiotics