hybridgroup-firmata 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/blink_led.rb +3 -0
- data/lib/firmata/board.rb +10 -11
- data/lib/firmata/version.rb +1 -1
- metadata +2 -2
data/examples/blink_led.rb
CHANGED
data/lib/firmata/board.rb
CHANGED
@@ -144,7 +144,7 @@ module Firmata
|
|
144
144
|
#
|
145
145
|
# Returns String data read for serial port.
|
146
146
|
def read
|
147
|
-
serial_port.read_nonblock(
|
147
|
+
return serial_port.read_nonblock(1024)
|
148
148
|
rescue EOFError
|
149
149
|
rescue Errno::EAGAIN
|
150
150
|
end
|
@@ -155,18 +155,17 @@ module Firmata
|
|
155
155
|
#
|
156
156
|
# Returns nothing.
|
157
157
|
def process(data)
|
158
|
-
bytes = StringIO.new(String(data))
|
159
|
-
bytes.
|
158
|
+
bytes = StringIO.new(String(data))
|
159
|
+
while byte = bytes.getbyte
|
160
160
|
case byte
|
161
161
|
when REPORT_VERSION
|
162
|
-
@major_version = bytes.
|
163
|
-
@minor_version = bytes.
|
164
|
-
|
162
|
+
@major_version = bytes.getbyte
|
163
|
+
@minor_version = bytes.getbyte
|
165
164
|
emit('report_version')
|
166
165
|
|
167
166
|
when ANALOG_MESSAGE_RANGE
|
168
|
-
least_significant_byte = bytes.
|
169
|
-
most_significant_byte = bytes.
|
167
|
+
least_significant_byte = bytes.getbyte
|
168
|
+
most_significant_byte = bytes.getbyte
|
170
169
|
|
171
170
|
value = least_significant_byte | (most_significant_byte << 7)
|
172
171
|
pin = byte & 0x0F
|
@@ -180,8 +179,8 @@ module Firmata
|
|
180
179
|
|
181
180
|
when DIGITAL_MESSAGE_RANGE
|
182
181
|
port = byte & 0x0F
|
183
|
-
first_bitmask = bytes.
|
184
|
-
second_bitmask = bytes.
|
182
|
+
first_bitmask = bytes.getbyte
|
183
|
+
second_bitmask = bytes.getbyte
|
185
184
|
port_value = first_bitmask | (second_bitmask << 7)
|
186
185
|
|
187
186
|
8.times do |i|
|
@@ -197,7 +196,7 @@ module Firmata
|
|
197
196
|
when START_SYSEX
|
198
197
|
current_buffer = [byte]
|
199
198
|
begin
|
200
|
-
current_buffer.push(bytes.
|
199
|
+
current_buffer.push(bytes.getbyte)
|
201
200
|
end until current_buffer.last == END_SYSEX
|
202
201
|
|
203
202
|
command = current_buffer[1]
|
data/lib/firmata/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hybridgroup-firmata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|