arduino_firmata 0.2.5 → 0.2.6
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.
- data/History.txt +4 -0
- data/README.md +1 -0
- data/bin/arduino_firmata +1 -1
- data/lib/arduino_firmata/arduino.rb +12 -3
- data/lib/arduino_firmata/const.rb +2 -1
- data/lib/arduino_firmata/version.rb +1 -1
- data/samples/sinatra_arduino.rb +2 -1
- metadata +1 -1
data/History.txt
CHANGED
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
@@ -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
|
-
|
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
|
-
|
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
|
data/samples/sinatra_arduino.rb
CHANGED