aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NK_C_API.cc7
-rw-r--r--NK_C_API.h1
-rw-r--r--NitrokeyManager.cc9
-rw-r--r--include/NitrokeyManager.h2
-rw-r--r--unittest/constants.py1
-rw-r--r--unittest/test_storage.py15
6 files changed, 34 insertions, 1 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index fc6d3c5..2a28ede 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -464,6 +464,13 @@ extern const char* NK_get_SD_usage_data() {
});
}
+extern int NK_get_progress_bar_value() {
+ auto m = NitrokeyManager::instance();
+ return get_with_result([&](){
+ return m->get_progress_bar_value();
+ });
+}
+
}
diff --git a/NK_C_API.h b/NK_C_API.h
index e5b414c..b71aeb8 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -339,6 +339,7 @@ extern int NK_change_update_password(const char* current_update_password,
const char* new_update_password);
extern const char* NK_get_status_storage();
extern const char* NK_get_SD_usage_data();
+extern int NK_get_progress_bar_value();
}
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 49b34c4..fdf1e05 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -562,5 +562,14 @@ namespace nitrokey{
return strdup(p.data().dissect().c_str());
}
+ int NitrokeyManager::get_progress_bar_value(){
+ try{
+ stick20::GetDeviceStatus::CommandTransaction::run(*device);
+ return -1;
+ }
+ catch (LongOperationInProgressException &e){
+ return e.progress_bar_value;
+ }
+ }
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 7a3ffcc..2d5859f 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -106,6 +106,8 @@ namespace nitrokey {
const char *get_SD_usage_data();
+ int get_progress_bar_value();
+
~NitrokeyManager();
private:
NitrokeyManager();
diff --git a/unittest/constants.py b/unittest/constants.py
index 258619e..78a219b 100644
--- a/unittest/constants.py
+++ b/unittest/constants.py
@@ -18,6 +18,7 @@ class DefaultPasswords(Enum):
class DeviceErrorCode(Enum):
STATUS_OK = 0
+ BUSY = 1 # busy or busy progressbar in place of wrong_CRC status
NOT_PROGRAMMED = 3
WRONG_PASSWORD = 4
STATUS_NOT_AUTHORIZED = 5
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index b02b1eb..600faf2 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -83,7 +83,20 @@ def test_clear_new_sd_card_notification(C):
@pytest.mark.skip
def test_fill_SD_card(C):
- assert C.NK_fill_SD_card_with_random_data(DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
+ status = C.NK_fill_SD_card_with_random_data(DefaultPasswords.ADMIN)
+ assert status == DeviceErrorCode.STATUS_OK or status == DeviceErrorCode.BUSY
+ while 1:
+ value = C.NK_get_progress_bar_value()
+ if value == -1: break
+ assert 0 <= value <= 100
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
+ wait(5)
+
+
+def test_get_busy_progress_on_idle(C):
+ value = C.NK_get_progress_bar_value()
+ assert value == -1
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
def test_change_update_password(C):