ruby_i2c 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49170a795e7181cf2a8e20e1c3abcdeba1d6ade6
4
- data.tar.gz: d340797751200129b4394fbccccaf0f7100acba3
3
+ metadata.gz: 368ed10e5646a4420a5e8ddd23e32dd61a8c509b
4
+ data.tar.gz: eb5cca7b05f79d1a9d044ef6b35efbeb5d15e9b0
5
5
  SHA512:
6
- metadata.gz: 62616b57c1d960803134379df709e9958a67bb37b481fd58862d0531df49d3795458e7ecbd70605d5c0ebdca8131da2c02c298df903eb9440684d1c326fb4e38
7
- data.tar.gz: 138695e83abc42a86b1a79143b667ea8eb0231b0226fe80571ce72769f6776f45e4b123d6ed4dc554a5f0c731059e2f67cddb8edb32d5700f08080e70df11e6a
6
+ metadata.gz: e30d9b613a08317e7a4f3e4a6a3dfaeea616320244df15233f8fdc434da07ca14e27ce227c7ff396c7b8bfbae1717ef39245cc91c1f914259e50bde87ed2f6c3
7
+ data.tar.gz: a663bab6d57bcc74ec5d729c578e5f85268cc7efd820c1413143a845c767bfa7fe8da63198aabbd03062e7391adc73deb3b2bb098f881dc28212159cc4f987cc
data/README.md CHANGED
@@ -12,7 +12,7 @@ Yet another Ruby I2C interface
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'ruby-i2c'
15
+ gem 'ruby_i2c'
16
16
  ```
17
17
 
18
18
  And then execute:
@@ -21,7 +21,7 @@ And then execute:
21
21
 
22
22
  Or install it yourself as:
23
23
 
24
- $ gem install ruby-i2c
24
+ $ gem install ruby_i2c
25
25
 
26
26
  ## Usage
27
27
 
@@ -1,7 +1,7 @@
1
1
  module RubyI2C
2
2
  class Adapter
3
3
  class Dummy < Base
4
- # For testing devices
4
+ # An Adapter with no hardware (for unit testing a Device)
5
5
 
6
6
  def initialize(force: false, returns: {})
7
7
  super
@@ -1,6 +1,8 @@
1
1
  module RubyI2C
2
2
  class Adapter
3
- class Device < Base
3
+ class UnixDevice < Base
4
+ # File-based Adapter via the Unix /dev filesystem
5
+
4
6
 
5
7
  def self.default_device_file; Dir.glob('/dev/i2c-*').sort.first; end
6
8
  def self.default_mutex; Mutex.new; end
@@ -64,6 +66,11 @@ module RubyI2C
64
66
  end
65
67
 
66
68
 
69
+ def encode(*data)
70
+ data.flatten.pack "C*"
71
+ end
72
+
73
+
67
74
  def handle(e)
68
75
  STDERR.puts "EIO (#{e.errno})"
69
76
  raise
@@ -82,11 +89,6 @@ module RubyI2C
82
89
  end
83
90
 
84
91
 
85
- def encode(*data)
86
- data.flatten.pack "C*"
87
- end
88
-
89
-
90
92
  def prep_handle(address)
91
93
  open
92
94
  select address
@@ -1,18 +1,14 @@
1
1
  require 'pp'
2
2
  module RubyI2C
3
3
  class Adapter
4
+ # An Adapter interfaces with hardware to speak the I2C protocol to a Device
4
5
 
5
6
  autoload :Base, File.join('ruby_i2c', 'adapter', 'base')
6
- autoload :Device, File.join('ruby_i2c', 'adapter', 'device')
7
7
  autoload :Dummy, File.join('ruby_i2c', 'adapter', 'dummy')
8
+ autoload :UnixDevice, File.join('ruby_i2c', 'adapter', 'unix_device')
8
9
 
9
10
  I2C_SLAVE = 0x0703
10
11
  I2C_SLAVE_FORCE = 0x0706
11
- I2C_TENBIT = 0x070
12
- I2C_FUNCS = 0x0705
13
- I2C_RDWR = 0x0707
14
- I2C_ACK_TEST = 0x0710
15
- I2C_SMBUS = 0x0720
16
12
 
17
13
  end
18
14
  end
@@ -4,7 +4,7 @@ module RubyI2C
4
4
 
5
5
  attr_reader :adapter, :address
6
6
 
7
- def initialize(adapter: RubyI2C::Adapter::Device.new, address: nil)
7
+ def initialize(adapter: RubyI2C::Adapter::UnixDevice.new, address: nil)
8
8
  @adapter = adapter
9
9
  @address = address
10
10
  end
@@ -1,5 +1,6 @@
1
1
  module RubyI2C
2
2
  class Device
3
+ # A piece of hardware that speaks the I2C protocol
3
4
 
4
5
  autoload :Base, File.join('ruby_i2c', 'device', 'base')
5
6
  autoload :SI70XX, File.join('ruby_i2c', 'device', 'si70xx')
@@ -1,4 +1,4 @@
1
1
  module RubyI2C
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  def self.version; VERSION; end
4
4
  end
data/lib/ruby_i2c.rb CHANGED
@@ -3,7 +3,6 @@ module RubyI2C
3
3
 
4
4
  autoload :Adapter, File.join('ruby_i2c','adapter')
5
5
  autoload :Device, File.join('ruby_i2c', 'device')
6
- autoload :Protocol, File.join('ruby_i2c', 'protocol')
7
6
 
8
7
  end
9
8
 
data/ruby_i2c.gemspec CHANGED
@@ -26,14 +26,11 @@ Gem::Specification.new do |spec|
26
26
  'lib/ruby_i2c.rb',
27
27
  'lib/ruby_i2c/adapter.rb',
28
28
  'lib/ruby_i2c/adapter/base.rb',
29
- 'lib/ruby_i2c/adapter/device.rb',
30
29
  'lib/ruby_i2c/adapter/dummy.rb',
30
+ 'lib/ruby_i2c/adapter/unix_device.rb',
31
31
  'lib/ruby_i2c/device.rb',
32
32
  'lib/ruby_i2c/device/base.rb',
33
33
  'lib/ruby_i2c/device/si70xx.rb',
34
- 'lib/ruby_i2c/protocol.rb',
35
- 'lib/ruby_i2c/protocol/full.rb',
36
- 'lib/ruby_i2c/protocol/smbus.rb',
37
34
  'lib/ruby_i2c/version.rb',
38
35
  'ruby_i2c.gemspec'
39
36
  ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_i2c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Brundage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2016-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,14 +78,11 @@ files:
78
78
  - lib/ruby_i2c.rb
79
79
  - lib/ruby_i2c/adapter.rb
80
80
  - lib/ruby_i2c/adapter/base.rb
81
- - lib/ruby_i2c/adapter/device.rb
82
81
  - lib/ruby_i2c/adapter/dummy.rb
82
+ - lib/ruby_i2c/adapter/unix_device.rb
83
83
  - lib/ruby_i2c/device.rb
84
84
  - lib/ruby_i2c/device/base.rb
85
85
  - lib/ruby_i2c/device/si70xx.rb
86
- - lib/ruby_i2c/protocol.rb
87
- - lib/ruby_i2c/protocol/full.rb
88
- - lib/ruby_i2c/protocol/smbus.rb
89
86
  - lib/ruby_i2c/version.rb
90
87
  - ruby_i2c.gemspec
91
88
  homepage: https://github.com/brundage/ruby_i2c
@@ -1,6 +0,0 @@
1
- module RubyI2C
2
- module Protocol
3
- module Full
4
- end
5
- end
6
- end
@@ -1,23 +0,0 @@
1
- module RubyI2C
2
- module Protocol
3
- module SMBus
4
-
5
- I2C_FUNC_SMBUS_QUICK = 0x00010000
6
- I2C_FUNC_SMBUS_READ_BYTE = 0x00020000
7
- I2C_FUNC_SMBUS_WRITE_BYTE = 0x00040000
8
- I2C_FUNC_SMBUS_READ_BYTE_DATA = 0x00080000
9
- I2C_FUNC_SMBUS_WRITE_BYTE_DATA = 0x00100000
10
- I2C_FUNC_SMBUS_READ_WORD_DATA = 0x00200000
11
- I2C_FUNC_SMBUS_WRITE_WORD_DATA = 0x00400000
12
- I2C_FUNC_SMBUS_PROC_CALL = 0x00800000
13
- I2C_FUNC_SMBUS_READ_BLOCK_DATA = 0x01000000
14
- I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
15
- I2C_FUNC_SMBUS_READ_I2C_BLOCK = 0x04000000
16
- I2C_FUNC_SMBUS_WRITE_I2C_BLOCK = 0x08000000
17
-
18
- def quick(addr, bit)
19
- end
20
-
21
- end
22
- end
23
- end
@@ -1,6 +0,0 @@
1
- module RubyI2C
2
- module Protocol
3
- autoload :Full, File.join('ruby_i2c', 'protocol', 'full')
4
- autoload :SMBus, File.join('ruby_i2c', 'protocol', 'smbus')
5
- end
6
- end