beaglebone 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/beaglebone.gemspec +1 -1
- data/lib/beaglebone/spi.rb +27 -4
- metadata +1 -1
data/beaglebone.gemspec
CHANGED
data/lib/beaglebone/spi.rb
CHANGED
@@ -191,7 +191,15 @@ module Beaglebone #:nodoc:
|
|
191
191
|
spi_fd = get_spi_status(spi, :fd_spi)
|
192
192
|
|
193
193
|
spi_fd.ioctl(SPI_IOC_WR_MAX_SPEED_HZ, [speed].pack('L'))
|
194
|
-
|
194
|
+
|
195
|
+
# deal with old versions of ruby that can't handle large number IOCTL
|
196
|
+
# https://bugs.ruby-lang.org/issues/6127
|
197
|
+
begin
|
198
|
+
spi_fd.ioctl(SPI_IOC_RD_MAX_SPEED_HZ, [speed].pack('L'))
|
199
|
+
rescue
|
200
|
+
puts 'Warning, old Ruby detected, cannot set SPI max read speed'
|
201
|
+
end
|
202
|
+
|
195
203
|
set_spi_status(spi, :speed, speed)
|
196
204
|
end
|
197
205
|
|
@@ -204,8 +212,15 @@ module Beaglebone #:nodoc:
|
|
204
212
|
raise ArgumentError, "Mode (#{mode.to_s}) is unknown" unless [SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3].include?(mode)
|
205
213
|
spi_fd = get_spi_status(spi, :fd_spi)
|
206
214
|
|
207
|
-
|
208
|
-
|
215
|
+
# deal with old versions of ruby that can't handle large number IOCTL
|
216
|
+
# https://bugs.ruby-lang.org/issues/6127
|
217
|
+
begin
|
218
|
+
spi_fd.ioctl(SPI_IOC_WR_MODE, [mode].pack('C'))
|
219
|
+
spi_fd.ioctl(SPI_IOC_RD_MODE, [mode].pack('C'))
|
220
|
+
rescue
|
221
|
+
puts 'Warning, old Ruby detected, cannot set SPI mode'
|
222
|
+
end
|
223
|
+
|
209
224
|
end
|
210
225
|
|
211
226
|
# Set the bits per word of the specified SPI device
|
@@ -220,7 +235,15 @@ module Beaglebone #:nodoc:
|
|
220
235
|
spi_fd = get_spi_status(spi, :fd_spi)
|
221
236
|
|
222
237
|
spi_fd.ioctl(SPI_IOC_WR_BITS_PER_WORD, [bpw].pack('C'))
|
223
|
-
|
238
|
+
|
239
|
+
# deal with old versions of ruby that can't handle large number IOCTL
|
240
|
+
# https://bugs.ruby-lang.org/issues/6127
|
241
|
+
begin
|
242
|
+
spi_fd.ioctl(SPI_IOC_RD_BITS_PER_WORD, [bpw].pack('C'))
|
243
|
+
rescue
|
244
|
+
puts 'Warning, old Ruby detected, cannot set SPI read bits per word'
|
245
|
+
end
|
246
|
+
|
224
247
|
set_spi_status(spi, :bpw, bpw)
|
225
248
|
end
|
226
249
|
|