From 1c7016360543d6f98aea9c9a4a4f57791e285cae Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 7 May 2019 01:06:01 +0200 Subject: [PATCH] reconnect fast --- client/proxmark3.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/client/proxmark3.c b/client/proxmark3.c index c0c745f09..3115af727 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -52,6 +52,17 @@ static void showBanner(void) { fflush(stdout); } +int check_comm(void) { + // If communications thread goes down. Device disconnected then this should hook up PM3 again. + if ( IsCommunicationThreadDead() ) { + session.pm3_present = ReConnectProxmark(); + if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) { + session.pm3_present = false; + } + } + return 0; +} + // Main thread of PM3 Client void #ifdef __has_attribute @@ -96,14 +107,6 @@ main_loop(char *script_cmds_file, char *script_cmd) { // loops every time enter is pressed... while (1) { bool printprompt = false; - - // If communications thread goes down. Device disconnected then this should hook up PM3 again. - if ( IsCommunicationThreadDead() ) { - session.pm3_present = ReConnectProxmark(); - if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) { - session.pm3_present = false; - } - } // If there is a script file if (sf) { @@ -155,6 +158,7 @@ main_loop(char *script_cmds_file, char *script_cmd) { printprompt = true; } else { + rl_event_hook = check_comm; cmd = readline(PROXPROMPT); fflush(NULL); }