From b9e72caeed17149cd20f146e895bf66523daeff5 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 8 Dec 2017 11:47:43 +0100 Subject: Return USB path as id, when device is running long operation Signed-off-by: Szczepan Zalega --- NitrokeyManager.cc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index b3c92a1..162ad93 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -136,11 +136,18 @@ using nitrokey::misc::strcpyT; try{ if (d->connect()){ device = d; - const auto status = get_status_storage(); - const auto sc_id = status.ActiveSmartCardID_u32; - const auto sd_id = status.ActiveSD_CardID_u32; + std::string id; + try { + const auto status = get_status_storage(); + const auto sc_id = status.ActiveSmartCardID_u32; + const auto sd_id = status.ActiveSD_CardID_u32; + id = std::to_string(sc_id) + ":" + std::to_string(sd_id); + } + catch (const LongOperationInProgressException &e) { + LOGD1(std::string("Long operation in progress, setting ID to: ") + p); + id = p; + } - auto id = std::to_string(sc_id) + ":" + std::to_string(sd_id); connected_devices_byID[id] = d; res.push_back(id); LOGD1( std::string("Found: ") + p + " => " + id); @@ -173,6 +180,9 @@ using nitrokey::misc::strcpyT; try{ get_status(); } + catch (const LongOperationInProgressException &){ + //ignore + } catch (const DeviceCommunicationException &){ d->disconnect(); connected_devices_byID[id] = nullptr; -- cgit v1.2.3