Add cmd response time to debugging log output

This commit is contained in:
Jason Rhinelander 2020-11-27 17:55:46 -04:00
parent 87fe444303
commit f6ba1a465e
2 changed files with 8 additions and 3 deletions

View file

@ -36,6 +36,7 @@
#include "cryptonote_core/cryptonote_tx_utils.h"
#include "common/lock.h"
#include "common/varint.h"
#include <chrono>
namespace hw {
@ -376,14 +377,16 @@ namespace hw {
std::string cmd;
for (size_t i = 0; i < 5; i++)
cmd += lokimq::to_hex(buffer_send + i, buffer_send + (i + 1)) + " ";
MDEBUG("CMD : " << cmd << lokimq::to_hex(buffer_send + 5, buffer_send + length_send));
MDEBUG("CMD: " << cmd << lokimq::to_hex(buffer_send + 5, buffer_send + length_send));
last_cmd = std::chrono::steady_clock::now();
}
}
void device_ledger::logRESP() {
if (apdu_verbose)
MDEBUG("RESP : " << lokimq::to_hex(std::string_view{reinterpret_cast<const char*>(&sw), sizeof(sw)})
<< ' ' << lokimq::to_hex(buffer_recv, buffer_recv + length_recv));
MDEBUG("RESP (+" << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - last_cmd).count() << "ms): "
<< lokimq::to_hex(std::string_view{reinterpret_cast<const char*>(&sw), sizeof(sw)})
<< ' ' << lokimq::to_hex(buffer_recv, buffer_recv + length_recv));
}
int device_ledger::set_command_header(unsigned char ins, unsigned char p1, unsigned char p2) {

View file

@ -30,6 +30,7 @@
#pragma once
#include <chrono>
#include <cstddef>
#include <string>
#include "device.hpp"
@ -169,6 +170,7 @@ namespace hw {
unsigned char buffer_recv[BUFFER_RECV_SIZE];
unsigned int sw;
unsigned int id;
std::chrono::steady_clock::time_point last_cmd;
void logCMD(void);
void logRESP(void);
unsigned int exchange(unsigned int ok=SW_OK, unsigned int mask=0xFFFF);