domotics-arduino 0.2.2 → 0.2.3

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.
@@ -185,7 +185,7 @@ module Domotics
185
185
 
186
186
  # Default event handler simple prints event.
187
187
  def event_handler(hash)
188
- #raise ArduinoError, hash[:event].inspect
188
+ raise hash[:e] if hash[:e].is_a? ArduinoError
189
189
  end
190
190
 
191
191
  # Send command directly to board
@@ -250,7 +250,7 @@ module Domotics
250
250
  end
251
251
  # Connect to board
252
252
  def connect
253
- @board.close if @board
253
+ @board.close if @board and !@board.closed?
254
254
  # Release command lock
255
255
  @reply.push(FAILREPRLY) if @command_lock.locked?
256
256
  @logger.info { "Open serial connection to board [#{@port_str}]..." }
@@ -283,6 +283,7 @@ module Domotics
283
283
  @logger.info { "done." } if send_command(DEFAULTS)
284
284
  rescue Exception => e
285
285
  @logger.error { e.message }
286
+ #@logger.debug { e.backtrace.join }
286
287
  tries = tries || 0
287
288
  tries += 1
288
289
  if tries <= 3
@@ -291,8 +292,7 @@ module Domotics
291
292
  retry
292
293
  end
293
294
  @logger.error { "Board [#{@port_str}] malfunction. Automatic restart failed." }
294
- event_handler :event => :malfunction
295
- raise ArduinoError, "Board [#{@port_str}] malfunction. Automatic restart failed."
295
+ event_handler event: :malfunction, e: ArduinoError.new("Board [#{@port_str}] malfunction. Automatic restart failed.")
296
296
  end
297
297
  # Checks
298
298
  def check_pin(pin)
@@ -1,5 +1,5 @@
1
1
  module Domotics
2
2
  module Arduino
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
data/test/test_arduino.rb CHANGED
@@ -10,12 +10,12 @@ class ArduinoTest < Test::Unit::TestCase
10
10
  def asetup
11
11
  @brd = ArduinoTestBoard.new(port: BoardEmulator.new.port)
12
12
  end
13
- def atest_dead_board
13
+ def test_dead_board
14
14
  assert_raise Domotics::Arduino::ArduinoError do
15
15
  ArduinoTestBoard.new(port: BoardEmulator.new(type: :dead).port)
16
16
  end
17
17
  end
18
- def atest_crasy_board
18
+ def test_crasy_board
19
19
  assert_raise Domotics::Arduino::ArduinoError do
20
20
  ArduinoTestBoard.new(port: BoardEmulator.new(type: :crasy).port)
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domotics-arduino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: