diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-12-08 11:47:43 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-02-28 19:29:00 +0100 |
commit | b9e72caeed17149cd20f146e895bf66523daeff5 (patch) | |
tree | d56655061c58be9fab323a1da9d3993ed71da652 /NitrokeyManager.cc | |
parent | e25a83d6d704db7b5505d113c2d89811c6c2fc60 (diff) | |
download | libnitrokey-b9e72caeed17149cd20f146e895bf66523daeff5.tar.gz libnitrokey-b9e72caeed17149cd20f146e895bf66523daeff5.tar.bz2 |
Return USB path as id, when device is running long operation
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r-- | NitrokeyManager.cc | 18 |
1 files 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; |