arduino_firmata 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source :rubygems
2
2
 
3
3
  gem 'hoe'
4
4
  gem 'newgem'
5
+ gem 'minitest'
5
6
  gem 'serialport'
@@ -5,6 +5,7 @@ GEM
5
5
  activesupport (2.3.14)
6
6
  hoe (3.1.0)
7
7
  rake (~> 0.8)
8
+ minitest (4.1.0)
8
9
  newgem (1.5.3)
9
10
  RedCloth (>= 4.1.1)
10
11
  activesupport (~> 2.3.4)
@@ -22,5 +23,6 @@ PLATFORMS
22
23
 
23
24
  DEPENDENCIES
24
25
  hoe
26
+ minitest
25
27
  newgem
26
28
  serialport
@@ -1,3 +1,8 @@
1
+ === 0.0.5 2012-10-24
2
+
3
+ * ArduinoFirmata::Arduino.close
4
+ * add tests
5
+
1
6
  === 0.0.4 2012-10-24
2
7
 
3
8
  * use ArduinoFirmata.connect
@@ -18,6 +18,7 @@ or
18
18
 
19
19
  arduino = ArduinoFirmata.connect '/dev/tty.usb-device-name'
20
20
 
21
+
21
22
  Board Version
22
23
 
23
24
  puts "firmata version #{arduino.version}"
@@ -42,10 +43,17 @@ Analog Write (PWM)
42
43
  sleep 0.01
43
44
  end
44
45
 
46
+
45
47
  Analog Read
46
48
 
47
49
  puts arduino.analog_read 0 # => 0 ~ 1023
48
50
 
51
+
52
+ Close
53
+
54
+ arduino.close
55
+
56
+
49
57
  see samples https://github.com/shokai/arduino_firmata/tree/gem/samples
50
58
 
51
59
  == REQUIREMENTS:
@@ -8,5 +8,5 @@ require 'arduino_firmata/const'
8
8
  require 'arduino_firmata/arduino'
9
9
 
10
10
  module ArduinoFirmata
11
- VERSION = '0.0.4'
11
+ VERSION = '0.0.5'
12
12
  end
@@ -10,7 +10,7 @@ module ArduinoFirmata
10
10
  @multi_byte_channel = 0
11
11
  @stored_input_data = []
12
12
  @parsing_sysex = false
13
- @sysex_bytes_read
13
+ @sysex_bytes_read = nil
14
14
 
15
15
  @digital_output_data = Array.new(16, 0)
16
16
  @digital_input_data = Array.new(16, 0)
@@ -19,6 +19,7 @@ module ArduinoFirmata
19
19
  @version = nil
20
20
 
21
21
  @serial = SerialPort.new(serial_name, params[:bps], params[:bit], params[:stopbit], params[:parity])
22
+ @serial.read_timeout = 3
22
23
  sleep 3
23
24
 
24
25
  Thread.new{
@@ -45,6 +46,10 @@ module ArduinoFirmata
45
46
 
46
47
  end
47
48
 
49
+ def close
50
+ @serial.close
51
+ end
52
+
48
53
  def digital_read(pin)
49
54
  (@digital_input_data[pin >> 3] >> (pin & 0x07)) & 0x01 > 0
50
55
  end
@@ -1,11 +1,20 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestArduinoFirmata < Test::Unit::TestCase
3
+ class TestArduinoFirmata < MiniTest::Unit::TestCase
4
4
 
5
5
  def setup
6
+ @arduino = ArduinoFirmata.connect
6
7
  end
7
-
8
- def test_truth
9
- assert true
8
+
9
+ def test_arduino
10
+ assert @arduino.version > '2.0'
11
+ @arduino.close
12
+ end
13
+
14
+ def test_analog_read
15
+ 0.upto(5).each do |pin|
16
+ assert 0 < @arduino.analog_read(pin)
17
+ end
18
+ @arduino.close
10
19
  end
11
20
  end
@@ -1,3 +1,5 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/arduino_firmata'
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+
4
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
5
+ require 'arduino_firmata'
metadata CHANGED
@@ -1,104 +1,96 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: arduino_firmata
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Sho Hashimoto
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-10-24 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-10-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: serialport
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 19
28
- segments:
29
- - 1
30
- - 1
31
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
32
21
  version: 1.1.0
33
22
  - - <
34
- - !ruby/object:Gem::Version
35
- hash: 15
36
- segments:
37
- - 2
38
- - 0
39
- - 0
23
+ - !ruby/object:Gem::Version
40
24
  version: 2.0.0
41
25
  type: :runtime
42
- name: serialport
43
- version_requirements: *id001
44
- - !ruby/object:Gem::Dependency
45
26
  prerelease: false
46
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
47
28
  none: false
48
- requirements:
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.0
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: 2.0.0
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
49
41
  - - ~>
50
- - !ruby/object:Gem::Version
51
- hash: 19
52
- segments:
53
- - 3
54
- - 10
55
- version: "3.10"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.10'
56
44
  type: :development
57
- name: rdoc
58
- version_requirements: *id002
59
- - !ruby/object:Gem::Dependency
60
45
  prerelease: false
61
- requirement: &id003 !ruby/object:Gem::Requirement
46
+ version_requirements: !ruby/object:Gem::Requirement
62
47
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 5
67
- segments:
68
- - 1
69
- - 5
70
- - 3
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: '3.10'
52
+ - !ruby/object:Gem::Dependency
53
+ name: newgem
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
71
59
  version: 1.5.3
72
60
  type: :development
73
- name: newgem
74
- version_requirements: *id003
75
- - !ruby/object:Gem::Dependency
76
61
  prerelease: false
77
- requirement: &id004 !ruby/object:Gem::Requirement
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: 1.5.3
68
+ - !ruby/object:Gem::Dependency
69
+ name: hoe
70
+ requirement: !ruby/object:Gem::Requirement
78
71
  none: false
79
- requirements:
72
+ requirements:
80
73
  - - ~>
81
- - !ruby/object:Gem::Version
82
- hash: 5
83
- segments:
84
- - 3
85
- - 1
86
- version: "3.1"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.1'
87
76
  type: :development
88
- name: hoe
89
- version_requirements: *id004
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '3.1'
90
84
  description: Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
91
- email:
85
+ email:
92
86
  - hashimoto@shokai.org
93
87
  executables: []
94
-
95
88
  extensions: []
96
-
97
- extra_rdoc_files:
89
+ extra_rdoc_files:
98
90
  - History.txt
99
91
  - Manifest.txt
100
92
  - README.rdoc
101
- files:
93
+ files:
102
94
  - .gitignore
103
95
  - Gemfile
104
96
  - Gemfile.lock
@@ -124,38 +116,33 @@ files:
124
116
  - .gemtest
125
117
  homepage: http://github.com/shokai/arduino_firmata
126
118
  licenses: []
127
-
128
119
  post_install_message:
129
- rdoc_options:
120
+ rdoc_options:
130
121
  - --main
131
122
  - README.rdoc
132
- require_paths:
123
+ require_paths:
133
124
  - lib
134
- required_ruby_version: !ruby/object:Gem::Requirement
125
+ required_ruby_version: !ruby/object:Gem::Requirement
135
126
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- hash: 3
140
- segments:
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ segments:
141
132
  - 0
142
- version: "0"
143
- required_rubygems_version: !ruby/object:Gem::Requirement
133
+ hash: 3496627900308316678
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
135
  none: false
145
- requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
152
140
  requirements: []
153
-
154
141
  rubyforge_project: arduino_firmata
155
142
  rubygems_version: 1.8.24
156
143
  signing_key:
157
144
  specification_version: 3
158
145
  summary: Arduino Firmata protocol (http://firmata.org) implementation on Ruby.
159
- test_files:
146
+ test_files:
160
147
  - test/test_arduino_firmata.rb
161
148
  - test/test_helper.rb