numato-gpio 0.1 → 0.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
- SHA1:
3
- metadata.gz: 4ed0c74fedbbd1190b321c5fed6a53466d2ff493
4
- data.tar.gz: 105fe2322d41835d88d2839ecfcb0997c50b67ae
2
+ SHA256:
3
+ metadata.gz: 39b03bd4a2d74ed88c1853b0da07dd31b23a0045f2f59c425c62089692aac29b
4
+ data.tar.gz: f7d79edc76c542826a0342ac2939ab1a0f4f5b523ef30f37a8996a56cdb11edf
5
5
  SHA512:
6
- metadata.gz: e9bc747ca1d6258cf9a4a1150a324fdb6238816d4abc2784b42f42d0c19d3d336b30b2fe8a55a277fffa4c93f0e92e0b70d6aabe127b038eb134d1b6af37c321
7
- data.tar.gz: ad8e224c2a02e753306627af3d01663330a72608e750bec7981f3c0787df2437c15450799666e62c2a84f126c5d20a40b907be95435a9ab9a8a2a1f2a64df40e
6
+ metadata.gz: bd0f5dc815b36a218b16f326180579122f391886a3acfebd1bfc080557ee382a9da7bce475f8221d600e1bd0d577f25f08abb6bd6b3d9581f2e85230635c5e2e
7
+ data.tar.gz: 982d9ed92e589d478f85de0feacbb961859dcfd2ca962158dcfd3651c09df06ea05cb13a50d92e52392fd1275d1b54ee3b75b0b6d4d06677c0932d0fa978c9ef
data/.gitignore CHANGED
@@ -1,35 +1,3 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
- /tmp/
11
-
12
- ## Specific to RubyMotion:
13
- .dat*
14
- .repl_history
15
- build/
16
-
17
- ## Documentation cache and generated files:
18
- /.yardoc/
19
- /_yardoc/
20
- /doc/
21
- /rdoc/
22
-
23
- ## Environment normalisation:
24
- /.bundle/
25
- /vendor/bundle
26
- /lib/bundler/man/
27
-
28
- # for a library or gem, you might want to ignore these files since the code is
29
- # intended to run in multiple environments; otherwise, check them in:
1
+ .DS_Store
30
2
  Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
33
-
34
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
- .rvmrc
3
+ *.gem
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in mill.gemspec
4
- gemspec
3
+ gemspec
4
+
5
+ gem 'rubyserial'
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # numato-gpio
2
2
 
3
- Ruby gem to interface with Numato GPIO board via USB interface.
3
+ Ruby gem to interface with [Numato GPIO board](https://numato.com/product/32-channel-usb-gpio-module-with-analog-inputs/) via USB interface.
4
+
5
+ Technical information is here: [32 Channel USB GPIO Module With Analog Inputs](https://numato.com/docs/32-channel-usb-gpio-module-with-analog-inputs/)
4
6
 
5
7
  Sorry for the lack of documentation. See source.
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
- require 'bundler/gem_tasks'
1
+ require 'bundler/gem_tasks'
2
+ Bundler.require
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.test_files = FileList['test/*_test.rb']
7
+ end
8
+
9
+ task :default => :test
data/lib/numato-gpio.rb CHANGED
@@ -1,31 +1,28 @@
1
1
  require 'rubyserial'
2
2
 
3
- require 'numato-gpio/version'
4
-
5
3
  class NumatoGPIO
6
4
 
7
5
  attr_accessor :device
8
- attr_accessor :io_map
9
6
  attr_accessor :mock
10
7
  attr_accessor :verbose
11
8
 
12
9
  def initialize(params={})
13
10
  {
14
11
  mock: false,
12
+ device: nil,
15
13
  verbose: false,
16
- io_map: {},
17
14
  }.merge(params).each { |k, v| send("#{k}=", v) }
18
15
  open_device
19
16
  end
20
17
 
21
18
  def open_device
22
19
  return if @mock
23
- unless @device
24
- devices = Dir.glob('/dev/tty.usbmodem*')
25
- raise "More than one device: #{devices.join(', ')}" if devices.length > 2
26
- @device = devices.first
20
+ raise "No device set!" unless @device
21
+ begin
22
+ @port = Serial.new(@device)
23
+ rescue RubySerial::Error => e
24
+ raise "Can't open device #{@device.inspect}: #{e}"
27
25
  end
28
- @port = Serial.new(@device)
29
26
  warn "connected to device #{@device}" if @verbose
30
27
  end
31
28
 
@@ -43,15 +40,15 @@ class NumatoGPIO
43
40
  end
44
41
 
45
42
  def set(x)
46
- command("gpio set #{gpio_str(io_id_to_num(x))}", false)
43
+ command("gpio set #{gpio_name(x)}", false)
47
44
  end
48
45
 
49
46
  def clear(x)
50
- command("gpio clear #{gpio_str(io_id_to_num(x))}", false)
47
+ command("gpio clear #{gpio_name(x)}", false)
51
48
  end
52
49
 
53
50
  def read(x)
54
- status = command("gpio read #{gpio_str(io_id_to_num(x))}", true)
51
+ status = command("gpio read #{gpio_name(x)}", true)
55
52
  case status
56
53
  when '1'
57
54
  true
@@ -81,28 +78,19 @@ class NumatoGPIO
81
78
  end
82
79
  end
83
80
 
84
- IONames = ('0'..'9').to_a + ('A'..'V').to_a.freeze
85
-
86
- def gpio_str(x)
87
- IONames[x] or raise "Can't convert GPIO number #{x.inspect} to string"
88
- end
81
+ GPIONames = ('0'..'9').to_a + ('A'..'V').to_a.freeze
89
82
 
90
- def io_id_to_num(x)
91
- case x
92
- when Numeric
93
- x
94
- when Symbol
95
- @io_map[x] or raise "No IO ID #{x.inspect}"
96
- else
97
- raise "Can't convert #{x.class} to IO: #{x.inspect}"
98
- end
83
+ def gpio_name(x)
84
+ GPIONames[x] or raise "Can't convert GPIO number #{x.inspect} to name"
99
85
  end
100
86
 
101
87
  end
102
88
 
103
89
  if $0 == __FILE__
104
90
 
105
- gpio = NumatoGPIO.new(mock: true)
91
+ gpio = NumatoGPIO.new(device: '/dev/tty.usbmodem1101', verbose: true)
92
+
93
+ puts "ID: #{gpio.id}"
106
94
 
107
95
  gpio.clear(0)
108
96
  gpio.clear(1)
data/numato-gpio.gemspec CHANGED
@@ -1,13 +1,8 @@
1
1
  #encoding: utf-8
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'numato-gpio/version'
7
-
8
3
  Gem::Specification.new do |s|
9
4
  s.name = 'numato-gpio'
10
- s.version = NumatoGPIO::VERSION
5
+ s.version = '0.2'
11
6
  s.summary = 'Interfaces with Numato GPIO board via USB interface.'
12
7
  s.author = 'John Labovitz'
13
8
  s.email = 'johnl@johnlabovitz.com'
@@ -20,8 +15,8 @@ NumatoGPIO interfaces with Numato GPIO board via USB interface.
20
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
16
  s.require_path = 'lib'
22
17
 
23
- s.add_dependency 'rubyserial'
18
+ s.add_dependency 'rubyserial', '~> 0.6'
24
19
 
25
- s.add_development_dependency 'bundler'
26
- s.add_development_dependency 'rake'
20
+ s.add_development_dependency 'bundler', '~> 2.4'
21
+ s.add_development_dependency 'rake', '~> 13.1'
27
22
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numato-gpio
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Labovitz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2023-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyserial
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.4'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '13.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '13.1'
55
55
  description: "\nNumatoGPIO interfaces with Numato GPIO board via USB interface.\n
56
56
  \ "
57
57
  email: johnl@johnlabovitz.com
@@ -65,12 +65,11 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - lib/numato-gpio.rb
68
- - lib/numato-gpio/version.rb
69
68
  - numato-gpio.gemspec
70
69
  homepage: http://github.com/jslabovitz/numato-gpio
71
70
  licenses: []
72
71
  metadata: {}
73
- post_install_message:
72
+ post_install_message:
74
73
  rdoc_options: []
75
74
  require_paths:
76
75
  - lib
@@ -85,10 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
84
  - !ruby/object:Gem::Version
86
85
  version: '0'
87
86
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.5.0
90
- signing_key:
87
+ rubygems_version: 3.4.22
88
+ signing_key:
91
89
  specification_version: 4
92
90
  summary: Interfaces with Numato GPIO board via USB interface.
93
91
  test_files: []
94
- has_rdoc:
@@ -1,5 +0,0 @@
1
- class NumatoGPIO
2
-
3
- VERSION = '0.1'
4
-
5
- end