Removed the retrieving of version information on re-connect so we don't overwrite BigBuf

This commit is contained in:
LW 2018-02-17 11:13:39 -08:00
commit 1ab4fc9d64
3 changed files with 16 additions and 17 deletions

View file

@ -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);

View file

@ -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

View file

@ -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 {