arduino_firmata 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.6 2013-03-13
2
+
3
+ * select blocking/nonblocking IO on connect
4
+
1
5
  === 0.2.5 2013-03-13
2
6
 
3
7
  * add sysex command test
data/README.md CHANGED
@@ -45,6 +45,7 @@ require 'arduino_firmata'
45
45
  arduino = ArduinoFirmata.connect # use default arduino
46
46
  arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
47
47
  arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :bps => 57600
48
+ arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name', :nonblock_io => true
48
49
  ```
49
50
 
50
51
  Board Version
data/bin/arduino_firmata CHANGED
@@ -43,6 +43,6 @@ rescue StandardError, Timeout::Error => e
43
43
  exit 1
44
44
  end
45
45
 
46
- print arduino.instance_eval parser.argv.join(' ')
46
+ print arduino.instance_eval(parser.argv.join(' '))
47
47
  sleep 1
48
48
  arduino.close
@@ -3,9 +3,10 @@ module ArduinoFirmata
3
3
  class Arduino
4
4
  include EventEmitter
5
5
 
6
- attr_reader :version, :status
6
+ attr_reader :version, :status, :nonblock_io
7
7
 
8
8
  def initialize(serial_name, params)
9
+ @nonblock_io = !!params[:nonblock_io]
9
10
  @status = Status::CLOSE
10
11
  @wait_for_data = 0
11
12
  @execute_multi_byte_command = 0
@@ -160,12 +161,20 @@ module ArduinoFirmata
160
161
  private
161
162
  def write(cmd)
162
163
  return if status == Status::CLOSE
163
- @serial.write cmd.chr
164
+ if nonblock_io
165
+ @serial.write_nonblock cmd.chr
166
+ else
167
+ @serial.write cmd.chr
168
+ end
164
169
  end
165
170
 
166
171
  def read
167
172
  return if status == Status::CLOSE
168
- @serial.read 9600 rescue EOFError
173
+ if nonblock_io
174
+ @serial.read_nonblock 9600 rescue EOFError
175
+ else
176
+ @serial.read 9600 rescue EOFError
177
+ end
169
178
  end
170
179
 
171
180
  def process_input
@@ -6,7 +6,8 @@ module ArduinoFirmata
6
6
  :bps => 57600,
7
7
  :bit => 8,
8
8
  :parity => 0,
9
- :stopbit => 1
9
+ :stopbit => 1,
10
+ :nonblock_io => false
10
11
  }
11
12
  end
12
13
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module ArduinoFirmata
3
- VERSION = '0.2.5'
3
+ VERSION = '0.2.6'
4
4
  end
@@ -4,7 +4,8 @@ require 'rubygems'
4
4
  require 'sinatra'
5
5
  require 'arduino_firmata'
6
6
 
7
- arduino = ArduinoFirmata.connect
7
+ # arduino = ArduinoFirmata.connect
8
+ arduino = ArduinoFirmata.connect nil, :nonblock_io => true
8
9
 
9
10
  get '/' do
10
11
  redirect './on'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: arduino_firmata
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.5
5
+ version: 0.2.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sho Hashimoto