mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-19 06:29:53 +08:00
Reset WaitForResponse timeout every time we get a packet
as cmds sending a lot of Dbprintf msgs can take ages on slow links e.g. "hw status" on 9600 baud link takes 26.5s with "reply_old" Dbprintf
This commit is contained in:
parent
75ee60f267
commit
913c03d3c4
1 changed files with 12 additions and 5 deletions
|
@ -50,6 +50,10 @@ static int cmd_tail = 0;
|
|||
// to lock rxBuffer operations from different threads
|
||||
static pthread_mutex_t rxBufferMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// Global start time for WaitForResponseTimeout, so we can reset timeout when we get Dbprintf packets
|
||||
// as sending lot of these packets can slow down things wuite a lot on slow links (e.g. hw status at 9600)
|
||||
static uint64_t WaitForResponseTimeout_start_time;
|
||||
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
||||
|
||||
// These wrappers are required because it is not possible to access a static
|
||||
|
@ -240,6 +244,9 @@ static void PacketResponseReceived(PacketResponseNG *packet) {
|
|||
// PrintAndLogEx(NORMAL, "RECV %s magic %08x length %04x status %04x crc %04x cmd %04x",
|
||||
// packet->ng ? "NG" : "OLD", packet->magic, packet->length, packet->status, packet->crc, packet->cmd);
|
||||
|
||||
// we got a packet, reset WaitForResponseTimeout timeout
|
||||
WaitForResponseTimeout_start_time = msclock();
|
||||
|
||||
switch (packet->cmd) {
|
||||
// First check if we are handling a debug message
|
||||
case CMD_DEBUG_PRINT_STRING: {
|
||||
|
@ -599,29 +606,29 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
|
|||
if (ms_timeout != (size_t)-1)
|
||||
ms_timeout += communication_delay();
|
||||
|
||||
uint64_t start_time = msclock();
|
||||
WaitForResponseTimeout_start_time = msclock();
|
||||
|
||||
// Wait until the command is received
|
||||
while (true) {
|
||||
|
||||
while (getReply(response)) {
|
||||
if (cmd == CMD_UNKNOWN || response->cmd == cmd) {
|
||||
// PrintAndLogEx(INFO, "Waited %i ms", msclock() - start_time);
|
||||
// PrintAndLogEx(INFO, "Waited %i ms", msclock() - WaitForResponseTimeout_start_time);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (msclock() - start_time > ms_timeout)
|
||||
if (msclock() - WaitForResponseTimeout_start_time > ms_timeout)
|
||||
break;
|
||||
|
||||
if (msclock() - start_time > 3000 && show_warning) {
|
||||
if (msclock() - WaitForResponseTimeout_start_time > 3000 && show_warning) {
|
||||
// 3 seconds elapsed (but this doesn't mean the timeout was exceeded)
|
||||
PrintAndLogEx(INFO, "Waiting for a response from the proxmark3...");
|
||||
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
|
||||
show_warning = false;
|
||||
}
|
||||
}
|
||||
// PrintAndLogEx(INFO, "Wait timeout after %i ms", msclock() - start_time);
|
||||
// PrintAndLogEx(INFO, "Wait timeout after %i ms", msclock() - WaitForResponseTimeout_start_time);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue