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.
@@ -8,6 +8,9 @@ board = Firmata::Board.new(sp)
8
8
 
9
9
  board.connect
10
10
 
11
+ puts "Firmware name #{board.firmware_name}"
12
+ puts "Firmata version #{board.version}"
13
+
11
14
  pin_number = 3
12
15
  rate = 0.5
13
16
 
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(4096)
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)).bytes
159
- bytes.each do |byte|
158
+ bytes = StringIO.new(String(data))
159
+ while byte = bytes.getbyte
160
160
  case byte
161
161
  when REPORT_VERSION
162
- @major_version = bytes.next
163
- @minor_version = bytes.next
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.next
169
- most_significant_byte = bytes.next
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.next
184
- second_bitmask = bytes.next
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.next)
199
+ current_buffer.push(bytes.getbyte)
201
200
  end until current_buffer.last == END_SYSEX
202
201
 
203
202
  command = current_buffer[1]
@@ -1,3 +1,3 @@
1
1
  module Firmata
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry