diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-09-20 12:54:01 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-09-20 12:54:01 +0200 |
commit | 7a04ee7dd3fad10e30581d22956234aeff2b2f3a (patch) | |
tree | 99770ff5bebd0816fd74e830e4308276b960dc9f /include | |
parent | 8f7435e4553916e6cc431e4b5316cc5861fd9063 (diff) | |
parent | a83419fe4a13bc77005d455dd89685b8c1443d96 (diff) | |
download | libnitrokey-7a04ee7dd3fad10e30581d22956234aeff2b2f3a.tar.gz libnitrokey-7a04ee7dd3fad10e30581d22956234aeff2b2f3a.tar.bz2 |
Merge branch 'osx-communication_issues' into OSX_merge_cleaned
Diffstat (limited to 'include')
-rw-r--r-- | include/device_proto.h | 21 | ||||
-rw-r--r-- | include/stick20_commands.h | 7 |
2 files changed, 19 insertions, 9 deletions
diff --git a/include/device_proto.h b/include/device_proto.h index b557384..bb14b42 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<std::mutex> guard(send_receive_mtx); LOG(__FUNCTION__, Loglevel::DEBUG_L2); @@ -306,12 +308,13 @@ namespace nitrokey { } if (resp.device_status == static_cast<uint8_t>(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); } else { retry_timeout *= 2; + 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:" @@ -352,12 +355,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<CommandID>(resp.command_id)) - ); - if (status <= 0) { dev->m_counters.receiving_error++; @@ -398,6 +395,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<CommandID>(resp.command_id)) + " " + + "Reported and calculated: " + std::to_string(resp.crc) + "!=" + std::to_string(resp.calculate_CRC()), + Loglevel::WARNING + ); + // See: DeviceResponse return resp; } diff --git a/include/stick20_commands.h b/include/stick20_commands.h index 5f99d28..f4da337 100644 --- a/include/stick20_commands.h +++ b/include/stick20_commands.h @@ -184,14 +184,19 @@ namespace nitrokey { print_to_ss( MagicNumber_StickConfig_u16 ); print_to_ss((int) ReadWriteFlagUncryptedVolume_u8 ); print_to_ss((int) ReadWriteFlagCryptedVolume_u8 ); + print_to_ss((int) ReadWriteFlagHiddenVolume_u8 ); print_to_ss((int) VersionInfo_au8[1] ); print_to_ss((int) VersionInfo_au8[3] ); - print_to_ss((int) ReadWriteFlagHiddenVolume_u8 ); print_to_ss((int) FirmwareLocked_u8 ); print_to_ss((int) NewSDCardFound_u8 ); + print_to_ss((int) NewSDCardFound_st.NewCard ); + print_to_ss((int) NewSDCardFound_st.Counter ); print_to_ss((int) SDFillWithRandomChars_u8 ); print_to_ss( ActiveSD_CardID_u32 ); print_to_ss((int) VolumeActiceFlag_u8 ); + print_to_ss((int) VolumeActiceFlag_st.unencrypted ); + print_to_ss((int) VolumeActiceFlag_st.encrypted ); + print_to_ss((int) VolumeActiceFlag_st.hidden); print_to_ss((int) NewSmartCardFound_u8 ); print_to_ss((int) UserPwRetryCount ); print_to_ss((int) AdminPwRetryCount ); |