arduino_firmata 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87e21383fdc0053837691237c377c338776f7faa
4
- data.tar.gz: 05f23f9a008c7a612f87770060264d57090b6068
3
+ metadata.gz: cb79730f81ce6d1e5cf252847c00bc6667cd46e4
4
+ data.tar.gz: 9f589cb5dbff2f8a143cdf8e29f1ae4890a3d8c5
5
5
  SHA512:
6
- metadata.gz: 61e0ef9f5cdc0adab8ba9095c8de85a3819fba6c849a386c97d83077971ca7344af60050ad1870b5c1c54bf18806447d48391f446eaadd66a1c4246c0b5f1afb
7
- data.tar.gz: fc8b15465cf376a04abe433d4baec6fe2eac4b23560aee5d4535dcf6d33443098ca62c98b16b139d1b36b3759b3ed8f7eb63559722afa399737a0055d26ab941
6
+ metadata.gz: ab7369bd8c68814f5273076fa845558e38531803c48a00454e0425a727edf33293f24307c1844f18b45c780f47f03bdb3f79bcbae2d12d7b6752e46f3ce7b92e
7
+ data.tar.gz: a8247133ee445fdab29b976f42a65ef5006b15af57950e56d47f573e8f285af82c585d149d3306df64823d1dfc2084c7b0a0d7da13f0a87126693e6d0b96ef5a
@@ -1,3 +1,7 @@
1
+ === 0.3.5 2013-11-12
2
+
3
+ * check arguments on digital/analog read/write #34
4
+
1
5
  === 0.3.4 2013-09-29
2
6
 
3
7
  * bugfix "write would block (Errno::EAGAIN)" with eventmachine
@@ -105,14 +105,17 @@ module ArduinoFirmata
105
105
  end
106
106
 
107
107
  def digital_read(pin)
108
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
108
109
  (@digital_input_data[pin >> 3] >> (pin & 0x07)) & 0x01 > 0
109
110
  end
110
111
 
111
112
  def analog_read(pin)
113
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
112
114
  @analog_input_data[pin]
113
115
  end
114
116
 
115
117
  def pin_mode(pin, mode)
118
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
116
119
  write SET_PIN_MODE
117
120
  write pin
118
121
  mode = case mode
@@ -129,6 +132,7 @@ module ArduinoFirmata
129
132
  end
130
133
 
131
134
  def digital_write(pin, value)
135
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
132
136
  pin_mode pin, OUTPUT
133
137
  port_num = (pin >> 3) & 0x0F
134
138
  if value == 0 or value == false
@@ -145,6 +149,8 @@ module ArduinoFirmata
145
149
  end
146
150
 
147
151
  def analog_write(pin, value)
152
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
153
+ raise ArgumentError, "invalid analog value (#{value})" if value.class != Fixnum or value < 0
148
154
  pin_mode pin, PWM
149
155
  write(ANALOG_MESSAGE | (pin & 0x0F))
150
156
  write(value & 0x7F)
@@ -154,6 +160,8 @@ module ArduinoFirmata
154
160
  end
155
161
 
156
162
  def servo_write(pin, angle)
163
+ raise ArgumentError, "invalid pin number (#{pin})" if pin.class != Fixnum or pin < 0
164
+ raise ArgumentError, "invalid angle (#{angle})" if angle.class != Fixnum or angle < 0
157
165
  pin_mode pin, SERVO
158
166
  write(ANALOG_MESSAGE | (pin & 0x0F))
159
167
  write(angle & 0x7F)
@@ -1,3 +1,3 @@
1
1
  module ArduinoFirmata
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arduino_firmata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-29 00:00:00.000000000 Z
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
- rubygems_version: 2.0.5
176
+ rubygems_version: 2.1.5
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Arduino Firmata protocol (http://firmata.org) implementation on Ruby.