From 2a3e72179f1cadc01897d74a5fc87686863ec258 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 25 May 2017 13:10:36 +0200 Subject: Show warning message about invalid incoming packet's CRC Signed-off-by: Szczepan Zalega --- include/device_proto.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index b557384..c126acd 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -352,12 +352,6 @@ namespace nitrokey { clear_packet(outp); - if (!resp.isCRCcorrect()) - LOGD(std::string("Accepting response from device with invalid CRC. ") - + "Command ID: " + std::to_string(resp.command_id) + " " + - commandid_to_string(static_cast(resp.command_id)) - ); - if (status <= 0) { dev->m_counters.receiving_error++; @@ -398,6 +392,14 @@ namespace nitrokey { dev->m_counters.successful_storage_commands++; } + if (!resp.isCRCcorrect()) + LOG(std::string("Accepting response from device with invalid CRC. ") + + "Command ID: " + std::to_string(resp.command_id) + " " + + commandid_to_string(static_cast(resp.command_id)) + " " + + "Reported and calculated: " + std::to_string(resp.crc) + "!=" + std::to_string(resp.calculate_CRC()), + Loglevel::WARNING + ); + // See: DeviceResponse return resp; } -- cgit v1.2.1 From 7e9fb2806f301f98b48e462d18fd1d3531db024a Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Mon, 11 Sep 2017 10:57:30 +0200 Subject: Do not make longer waiting than 500ms on iteration Signed-off-by: Szczepan Zalega --- include/device_proto.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index c126acd..691c17b 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -312,6 +312,7 @@ namespace nitrokey { std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2); } else { retry_timeout *= 2; + retry_timeout = std::min(retry_timeout, 500ms); busy_counter = 0; LOG("Status busy, decreasing receiving_retry_counter counter: " + std::to_string(receiving_retry_counter) + ", current delay:" -- cgit v1.2.1 From ff1f2248b830ad78833e347be8d8c8dc9cb03c85 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 15 Sep 2017 16:34:11 +0200 Subject: Correct mutex placement Move mutex from template instantation to single compilation unit to make it work as desired Signed-off-by: Szczepan Zalega --- include/device_proto.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index 691c17b..4a548a0 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -37,6 +37,9 @@ namespace nitrokey { namespace proto { + extern std::mutex send_receive_mtx; + + /* * POD types for HID proto commands * Instances are meant to be __packed. @@ -215,7 +218,6 @@ namespace nitrokey { using namespace ::nitrokey::log; using namespace std::chrono_literals; - static std::mutex send_receive_mtx; std::lock_guard guard(send_receive_mtx); LOG(__FUNCTION__, Loglevel::DEBUG_L2); -- cgit v1.2.1 From 09d699a7c7edce60547a3e9900301e1ea62188f6 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 15 Sep 2017 16:35:46 +0200 Subject: Decrease busy-delay count Signed-off-by: Szczepan Zalega --- include/device_proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index 4a548a0..6631d2f 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -308,7 +308,7 @@ namespace nitrokey { } if (resp.device_status == static_cast(stick10::device_status::busy)) { dev->m_counters.busy++; - if (busy_counter++<10) { + if (busy_counter++<3) { receiving_retry_counter++; LOG("Status busy, not decreasing receiving_retry_counter counter: " + std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2); -- cgit v1.2.1 From a83419fe4a13bc77005d455dd89685b8c1443d96 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 15 Sep 2017 16:36:18 +0200 Subject: Set lower maximum between-sending delay Signed-off-by: Szczepan Zalega --- include/device_proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/device_proto.h') diff --git a/include/device_proto.h b/include/device_proto.h index 6631d2f..bb14b42 100644 --- a/include/device_proto.h +++ b/include/device_proto.h @@ -314,7 +314,7 @@ namespace nitrokey { std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2); } else { retry_timeout *= 2; - retry_timeout = std::min(retry_timeout, 500ms); + retry_timeout = std::min(retry_timeout, 300ms); busy_counter = 0; LOG("Status busy, decreasing receiving_retry_counter counter: " + std::to_string(receiving_retry_counter) + ", current delay:" -- cgit v1.2.1