hybridgroup-firmata 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +6 -2
- data/examples/blink_led.rb +1 -1
- data/firmata.gemspec +5 -4
- data/lib/firmata/board.rb +6 -10
- data/lib/firmata/version.rb +1 -1
- data/test/board_test.rb +3 -3
- data/test/fake_serial_port.rb +0 -1
- metadata +38 -26
- data/Gemfile.lock +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba95efafd486c6832d30cddf13dc3357d6c91fd
|
4
|
+
data.tar.gz: cbe87f61f453cd14d53a2edec6b945f01ee1848f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c11c81e46fbeb18a3bbd7f3f9061b2b1b8a314c134b48eac5c4b1bc96c8ccbc8e0da3bf56defc7f2dc0d563342d9aba4843c91c3ef23058979ab831788c2789e
|
7
|
+
data.tar.gz: 50e6bdddb92137c12fbb9f21f4743b9b0800a130a850fa08a204690290c215e7fc4787f537f1ed99ee541568b5f3ec410cb48b3fe9d6d57d426d1308c5358de5
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/examples/blink_led.rb
CHANGED
data/firmata.gemspec
CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Firmata::VERSION
|
17
17
|
|
18
|
-
gem.add_development_dependency
|
19
|
-
gem.add_development_dependency
|
20
|
-
gem.add_development_dependency
|
18
|
+
gem.add_development_dependency "rake", "~>10.1.0"
|
19
|
+
gem.add_development_dependency "pry", "~>0.9.12.2"
|
20
|
+
gem.add_development_dependency "minitest", "~>5.0.6"
|
21
21
|
|
22
|
-
gem.add_runtime_dependency
|
22
|
+
gem.add_runtime_dependency "event_emitter", "~>0.2.5"
|
23
|
+
gem.add_runtime_dependency "rubyserial", "~>0.1.1"
|
23
24
|
end
|
data/lib/firmata/board.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'event_emitter'
|
3
|
+
require 'rubyserial'
|
3
4
|
|
4
5
|
module Firmata
|
5
6
|
class Board
|
@@ -24,9 +25,7 @@ module Firmata
|
|
24
25
|
# port - a String port or an Object that responds to read and write.
|
25
26
|
def initialize(port)
|
26
27
|
if port.is_a?(String)
|
27
|
-
|
28
|
-
@serial_port = SerialPort.new(port, 57600, 8, 1, SerialPort::NONE)
|
29
|
-
@serial_port.read_timeout = 2
|
28
|
+
@serial_port = Serial.new(port, 57600, 8)
|
30
29
|
else
|
31
30
|
@serial_port = port
|
32
31
|
end
|
@@ -41,8 +40,6 @@ module Firmata
|
|
41
40
|
@async_events = []
|
42
41
|
|
43
42
|
trap_signals 'INT', 'KILL', 'TERM'
|
44
|
-
rescue LoadError
|
45
|
-
puts "Please 'gem install hybridgroup-serialport' for serial port support."
|
46
43
|
end
|
47
44
|
|
48
45
|
# Public: Check if a connection to Arduino has been made.
|
@@ -63,7 +60,7 @@ module Firmata
|
|
63
60
|
catch(:initialized) do
|
64
61
|
loop do
|
65
62
|
query_report_version #unless @major_version.zero?
|
66
|
-
sleep
|
63
|
+
sleep 1
|
67
64
|
read_and_process
|
68
65
|
end
|
69
66
|
end
|
@@ -242,6 +239,7 @@ module Firmata
|
|
242
239
|
ret.push(END_SYSEX)
|
243
240
|
write(*ret)
|
244
241
|
end
|
242
|
+
|
245
243
|
# Public: Set i2c config.
|
246
244
|
# I2C config
|
247
245
|
# 0 START_SYSEX (0xF0) (MIDI System Exclusive)
|
@@ -289,16 +287,14 @@ module Firmata
|
|
289
287
|
#
|
290
288
|
# Returns nothing.
|
291
289
|
def write(*commands)
|
292
|
-
serial_port.
|
290
|
+
serial_port.write(commands.map(&:chr).join)
|
293
291
|
end
|
294
292
|
|
295
293
|
# Internal: Read data from the underlying serial port.
|
296
294
|
#
|
297
295
|
# Returns String data read for serial port.
|
298
296
|
def read
|
299
|
-
return serial_port.
|
300
|
-
rescue EOFError
|
301
|
-
rescue Errno::EAGAIN
|
297
|
+
return serial_port.read(1024)
|
302
298
|
end
|
303
299
|
|
304
300
|
# Internal: Process a series of bytes.
|
data/lib/firmata/version.rb
CHANGED
data/test/board_test.rb
CHANGED
@@ -16,7 +16,7 @@ module Firmata
|
|
16
16
|
yield mock_port
|
17
17
|
else
|
18
18
|
expected = args.map(&:chr).join
|
19
|
-
mock_port.expect(:
|
19
|
+
mock_port.expect(:write, 1, [expected])
|
20
20
|
end
|
21
21
|
|
22
22
|
mock_port
|
@@ -131,7 +131,7 @@ module Firmata
|
|
131
131
|
|
132
132
|
def test_toggling_pin_reporting
|
133
133
|
mock_sp = mock_serial_port do |mock|
|
134
|
-
mock.expect(:
|
134
|
+
mock.expect(:write, 2, [[Board::REPORT_DIGITAL | 13, 1].map(&:chr).join])
|
135
135
|
end
|
136
136
|
|
137
137
|
board = Board.new(mock_sp)
|
@@ -139,7 +139,7 @@ module Firmata
|
|
139
139
|
board.toggle_pin_reporting(13)
|
140
140
|
mock_sp.verify
|
141
141
|
|
142
|
-
mock_sp.expect(:
|
142
|
+
mock_sp.expect(:write, 2, [[Board::REPORT_DIGITAL | 13, 0].map(&:chr).join])
|
143
143
|
board.toggle_pin_reporting(13, 0)
|
144
144
|
mock_sp.verify
|
145
145
|
|
data/test/fake_serial_port.rb
CHANGED
metadata
CHANGED
@@ -1,72 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hybridgroup-firmata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- '
|
8
|
-
Magaña'''
|
7
|
+
- "'Mike Breen', 'Adrian Zankich', 'Ron Evans', 'Isaac A. Murchie', 'Rafael Magaña'"
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- -
|
17
|
+
- - "~>"
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
19
|
+
version: 10.1.0
|
21
20
|
type: :development
|
22
21
|
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- -
|
24
|
+
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
26
|
+
version: 10.1.0
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
28
|
name: pry
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
31
30
|
requirements:
|
32
|
-
- -
|
31
|
+
- - "~>"
|
33
32
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
33
|
+
version: 0.9.12.2
|
35
34
|
type: :development
|
36
35
|
prerelease: false
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
|
-
- -
|
38
|
+
- - "~>"
|
40
39
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
40
|
+
version: 0.9.12.2
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
42
|
name: minitest
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
45
44
|
requirements:
|
46
|
-
- -
|
45
|
+
- - "~>"
|
47
46
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
47
|
+
version: 5.0.6
|
49
48
|
type: :development
|
50
49
|
prerelease: false
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
52
51
|
requirements:
|
53
|
-
- -
|
52
|
+
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
54
|
+
version: 5.0.6
|
56
55
|
- !ruby/object:Gem::Dependency
|
57
56
|
name: event_emitter
|
58
57
|
requirement: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
|
-
- -
|
59
|
+
- - "~>"
|
61
60
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
61
|
+
version: 0.2.5
|
63
62
|
type: :runtime
|
64
63
|
prerelease: false
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
66
65
|
requirements:
|
67
|
-
- -
|
66
|
+
- - "~>"
|
68
67
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
68
|
+
version: 0.2.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubyserial
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.1
|
70
83
|
description: A lib for working with the Firmata protocol in Ruby.
|
71
84
|
email:
|
72
85
|
- info@hybridgroup.com
|
@@ -74,10 +87,9 @@ executables: []
|
|
74
87
|
extensions: []
|
75
88
|
extra_rdoc_files: []
|
76
89
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
79
92
|
- Gemfile
|
80
|
-
- Gemfile.lock
|
81
93
|
- LICENSE
|
82
94
|
- README.md
|
83
95
|
- Rakefile
|
@@ -104,17 +116,17 @@ require_paths:
|
|
104
116
|
- lib
|
105
117
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
118
|
requirements:
|
107
|
-
- -
|
119
|
+
- - ">="
|
108
120
|
- !ruby/object:Gem::Version
|
109
121
|
version: '0'
|
110
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
123
|
requirements:
|
112
|
-
- -
|
124
|
+
- - ">="
|
113
125
|
- !ruby/object:Gem::Version
|
114
126
|
version: '0'
|
115
127
|
requirements: []
|
116
128
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.2.2
|
118
130
|
signing_key:
|
119
131
|
specification_version: 4
|
120
132
|
summary: ''
|
data/Gemfile.lock
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
hybridgroup-firmata (0.4.5)
|
5
|
-
event_emitter
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
coderay (1.0.9)
|
11
|
-
event_emitter (0.2.5)
|
12
|
-
method_source (0.8.2)
|
13
|
-
minitest (5.0.6)
|
14
|
-
pry (0.9.12.2)
|
15
|
-
coderay (~> 1.0.5)
|
16
|
-
method_source (~> 0.8)
|
17
|
-
slop (~> 3.4)
|
18
|
-
rake (10.1.0)
|
19
|
-
slop (3.4.6)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
ruby
|
23
|
-
|
24
|
-
DEPENDENCIES
|
25
|
-
hybridgroup-firmata!
|
26
|
-
minitest
|
27
|
-
pry
|
28
|
-
rake
|