|
|
@ -88,7 +88,7 @@ class MiniTerm
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def connetion_reset
|
|
|
|
def connection_reset
|
|
|
|
@target_serial&.close
|
|
|
|
@target_serial&.close
|
|
|
|
@target_serial = nil
|
|
|
|
@target_serial = nil
|
|
|
|
@host_console.cooked!
|
|
|
|
@host_console.cooked!
|
|
|
@ -96,14 +96,14 @@ class MiniTerm
|
|
|
|
|
|
|
|
|
|
|
|
# When the serial lost power or was removed during R/W operation.
|
|
|
|
# When the serial lost power or was removed during R/W operation.
|
|
|
|
def handle_reconnect(_error)
|
|
|
|
def handle_reconnect(_error)
|
|
|
|
connetion_reset
|
|
|
|
connection_reset
|
|
|
|
|
|
|
|
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
puts "[#{@name_short}] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}"
|
|
|
|
puts "[#{@name_short}] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def handle_unexpected(error)
|
|
|
|
def handle_unexpected(error)
|
|
|
|
connetion_reset
|
|
|
|
connection_reset
|
|
|
|
|
|
|
|
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
puts "[#{@name_short}] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}"
|
|
|
|
puts "[#{@name_short}] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}"
|
|
|
@ -120,7 +120,7 @@ class MiniTerm
|
|
|
|
rescue StandardError => e
|
|
|
|
rescue StandardError => e
|
|
|
|
handle_unexpected(e)
|
|
|
|
handle_unexpected(e)
|
|
|
|
ensure
|
|
|
|
ensure
|
|
|
|
connetion_reset
|
|
|
|
connection_reset
|
|
|
|
puts
|
|
|
|
puts
|
|
|
|
puts "[#{@name_short}] Bye 👋"
|
|
|
|
puts "[#{@name_short}] Bye 👋"
|
|
|
|
end
|
|
|
|
end
|
|
|
|