summaryrefslogtreecommitdiff
path: root/include/device_proto.h
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-17 22:10:18 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-10-19 16:35:22 +0200
commit803a6aa41e82828dcbe7e02bcdcf20d776b60050 (patch)
tree565ebe2820b6713011e5d87844df70b8f8823efb /include/device_proto.h
parenta47a7bc3c838a37e15e4464be75736cd83573da2 (diff)
downloadlibnitrokey-803a6aa41e82828dcbe7e02bcdcf20d776b60050.tar.gz
libnitrokey-803a6aa41e82828dcbe7e02bcdcf20d776b60050.tar.bz2
Code refactoring: rename - disambiguate receiving counter from sending
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'include/device_proto.h')
-rw-r--r--include/device_proto.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/device_proto.h b/include/device_proto.h
index 2d39a04..9f0d1e9 100644
--- a/include/device_proto.h
+++ b/include/device_proto.h
@@ -218,7 +218,7 @@ namespace nitrokey {
if (!outp.isValid()) throw std::runtime_error("Invalid outgoing packet");
- int retry = 0;
+ int receiving_retry_counter = 0;
int sending_retry_counter = 3;
while (sending_retry_counter-->0) {
status = dev.send(&outp);
@@ -230,8 +230,8 @@ namespace nitrokey {
std::this_thread::sleep_for(dev.get_send_receive_delay());
// FIXME make checks done in device:recv here
- retry = dev.get_retry_count();
- while (retry-- > 0) {
+ receiving_retry_counter = dev.get_retry_count();
+ while (receiving_retry_counter-- > 0) {
status = dev.recv(&resp);
if (dev.get_device_model() == DeviceModel::STORAGE &&
@@ -265,8 +265,8 @@ namespace nitrokey {
// if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isCRCcorrect()) break;
if (resp.device_status == 0 && resp.last_command_crc == outp.crc && resp.isValid()) break;
if (resp.device_status == 1 ) {
- retry++;
- Log::instance()("Status busy, not decresing retry counter: " + std::to_string(retry), Loglevel::DEBUG_L2);
+ receiving_retry_counter++;
+ Log::instance()("Status busy, not decresing receiving_retry_counter counter: " + std::to_string(receiving_retry_counter), Loglevel::DEBUG_L2);
}
Log::instance()(std::string("Retry status - dev status, equal crc, correct CRC: ")
+ std::to_string(resp.device_status) + " " +
@@ -297,11 +297,11 @@ namespace nitrokey {
Log::instance()("Incoming HID packet:", Loglevel::DEBUG);
Log::instance()((std::string) (resp), Loglevel::DEBUG);
- Log::instance()(std::string("Retry count: ") + std::to_string(retry), Loglevel::DEBUG);
+ Log::instance()(std::string("receiving_retry_counter count: ") + std::to_string(receiving_retry_counter), Loglevel::DEBUG);
if (!resp.isValid()) throw std::runtime_error("Invalid incoming packet");
- if (retry <= 0)
- throw std::runtime_error("Maximum retry count reached for receiving response from the device!");
+ if (receiving_retry_counter <= 0)
+ throw std::runtime_error("Maximum receiving_retry_counter count reached for receiving response from the device!");
if (resp.last_command_status != 0)
throw CommandFailedException(resp.command_id, resp.last_command_status);