domotics-arduino 0.1.1 → 0.1.2
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/Rakefile +0 -1
- data/lib/domotics/arduino/arduino_serial.rb +6 -6
- data/lib/domotics/arduino/version.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
@@ -46,7 +46,7 @@ module Domotics
|
|
46
46
|
TIMER_5 = 5
|
47
47
|
def initialize(args = {})
|
48
48
|
# grab args from hash
|
49
|
-
case @
|
49
|
+
case @board_type = args[:board] || :mega
|
50
50
|
when :nano
|
51
51
|
@port_str = args[:port] || "/dev/ttyUSB0"
|
52
52
|
@number_of_pins = 22
|
@@ -117,7 +117,7 @@ module Domotics
|
|
117
117
|
|
118
118
|
# ---9--- SETPWMFREQ
|
119
119
|
def set_pwm_frequency(pin, divisor = 5)
|
120
|
-
case @
|
120
|
+
case @board_type
|
121
121
|
when :nano
|
122
122
|
case pin
|
123
123
|
when 9,10
|
@@ -235,8 +235,8 @@ module Domotics
|
|
235
235
|
@reply.push(FAILREPRLY) if @command_lock.locked?
|
236
236
|
# Close board connection
|
237
237
|
@board.close
|
238
|
-
@logger.info "Try to restart board[#{@port_str}] in
|
239
|
-
sleep
|
238
|
+
@logger.info "Try to restart board[#{@port_str}] in 2 seconds..."
|
239
|
+
sleep 2
|
240
240
|
connect
|
241
241
|
end
|
242
242
|
# Exit errored thread
|
@@ -281,8 +281,8 @@ module Domotics
|
|
281
281
|
tries = tries || 0
|
282
282
|
tries += 1
|
283
283
|
if tries <= 3
|
284
|
-
@logger.info { "Attempt #{tries}: try to reconnect in #{
|
285
|
-
sleep
|
284
|
+
@logger.info { "Attempt #{tries}: try to reconnect in #{2**tries} seconds." }
|
285
|
+
sleep 2**tries
|
286
286
|
retry
|
287
287
|
end
|
288
288
|
@logger.error { "Board[#{@port_str}] malfunction. Automatic restart failed." }
|