From 767e24572db2bbc4b9837c32ffc0bab4e1ad0b81 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 3 Feb 2017 17:07:32 +0100 Subject: Disconnect device as soon as the communication issue appears Signed-off-by: Szczepan Zalega --- include/device_proto.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/device_proto.h b/include/device_proto.h index 9401428..1e07277 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -243,10 +243,13 @@ namespace nitrokey { int sending_retry_counter = dev->get_retry_sending_count(); while (sending_retry_counter-- > 0) { status = dev->send(&outp); - if (status <= 0) + if (status <= 0){ + Log::instance()("Encountered communication error, disconnecting device", Loglevel::DEBUG_L2); + dev->disconnect(); throw DeviceSendingFailure( std::string("Device error while sending command ") + std::to_string(status)); + } std::this_thread::sleep_for(dev->get_send_receive_delay()); -- cgit v1.2.3