From 1ab4fc9d64d3a4396457bc9f3230ce0f39fd722e Mon Sep 17 00:00:00 2001 From: LW Date: Sat, 17 Feb 2018 11:13:39 -0800 Subject: [PATCH] Removed the retrieving of version information on re-connect so we don't overwrite BigBuf --- client/cmdhw.c | 15 +++++++++++---- client/cmdhw.h | 3 ++- client/proxmark3.c | 15 +++------------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/client/cmdhw.c b/client/cmdhw.c index 2451ca77..66a9f0c9 100644 --- a/client/cmdhw.c +++ b/client/cmdhw.c @@ -408,15 +408,22 @@ int CmdVersion(const char *Cmd) return CmdVersionC(Cmd, false); } -int CmdVersionC(const char *Cmd, const bool no_cache) +int CmdVersionClearCache() +{ + return CmdVersionC(NULL, true); +} + +int CmdVersionC(const char *Cmd, const bool clear_cache) { UsbCommand c = {CMD_VERSION}; static UsbCommand resp = {0, {0, 0, 0}}; - if( no_cache ) + if (clear_cache) { memset( &resp, 0, sizeof(resp) ); - else - clearCommandBuffer(); + return 0; + } + + clearCommandBuffer(); if (resp.arg[0] == 0 && resp.arg[1] == 0) { // no cached information available SendCommand(&c); diff --git a/client/cmdhw.h b/client/cmdhw.h index c4d6a836..334357a0 100644 --- a/client/cmdhw.h +++ b/client/cmdhw.h @@ -23,6 +23,7 @@ int CmdSetDivisor(const char *Cmd); int CmdSetMux(const char *Cmd); int CmdTune(const char *Cmd); int CmdVersion(const char *Cmd); -int CmdVersionC(const char *Cmd, const bool no_cache); +int CmdVersionClearCache(); +int CmdVersionC(const char *Cmd, const bool clear_cache); #endif diff --git a/client/proxmark3.c b/client/proxmark3.c index 96132065..cc2b334f 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -73,7 +73,6 @@ static void *uart_receiver(void *targ) { size_t rxlen; bool need_reconnect = false; UsbCommand version_cmd = {CMD_VERSION}; - static bool request_version = false; while (arg->run) { if( need_reconnect ) { @@ -81,24 +80,22 @@ static void *uart_receiver(void *targ) { if( sp == INVALID_SERIAL_PORT || sp == CLAIMED_SERIAL_PORT ) { - PrintAndLog("Reconnect failed, retrying..."); + //PrintAndLog("Reconnect failed, retrying..."); if( txcmd_pending ) { PrintAndLog("Cannot send bytes to offline proxmark"); txcmd_pending = false; } - sleep(2); + sleep(1); continue; } PrintAndLog("Proxmark reconnected!"); need_reconnect = false; offline = 0; - //CmdVersionC(NULL, true); clearCommandBuffer(); - uart_send(sp, (byte_t*) &version_cmd, sizeof(UsbCommand)); // request it from the HW - request_version = true; + CmdVersionClearCache(); } rxlen = 0; @@ -110,12 +107,6 @@ static void *uart_receiver(void *targ) { } UsbCommandReceived((UsbCommand*)rx); - - if( request_version && ((UsbCommand*)rx)->cmd == CMD_ACK) - { - request_version = false; - CmdVersionC(NULL, true); - } } } else {