diff --git a/client/src/comms.c b/client/src/comms.c index df4c404df..5976cfcc1 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -349,7 +349,7 @@ __attribute__((force_align_arg_pointer)) // main thread will kill and restart this thread. if (commfailed) { if (conn.last_command != CMD_HARDWARE_RESET) { - PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed")); + PrintAndLogEx(WARNING, "\nCommunicating with Proxmark3 device " _RED_("failed")); } __atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST); break; diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index d2840a1f7..d820e297d 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -117,23 +117,23 @@ static void prompt_compose(char *buf, size_t buflen, const char *promptctx, cons snprintf(buf, buflen - 1, PROXPROMPT_COMPOSE, promptdev, promptctx); } -#ifdef HAVE_READLINE static int check_comm(void) { // If communications thread goes down. Device disconnected then this should hook up PM3 again. if (IsCommunicationThreadDead() && session.pm3_present) { + PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n"); prompt_dev = PROXPROMPT_DEV_OFFLINE; +#ifdef HAVE_READLINE char prompt[PROXPROMPT_MAX_SIZE] = {0}; prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev); char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0}; memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors); rl_set_prompt(prompt_filtered); rl_forced_update_display(); +#endif CloseProxmark(); - PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Use "_YELLOW_("\"hw connect\"") " to reconnect\n"); } return 0; } -#endif // first slot is always NULL, indicating absence of script when idx=0 static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0}; @@ -293,13 +293,17 @@ check_script: printprompt = true; } else { +#ifdef HAVE_READLINE + rl_event_hook = check_comm; +#else + check_comm(); +#endif prompt_ctx = PROXPROMPT_CTX_INTERACTIVE; char prompt[PROXPROMPT_MAX_SIZE] = {0}; prompt_compose(prompt, sizeof(prompt), prompt_ctx, prompt_dev); char prompt_filtered[PROXPROMPT_MAX_SIZE] = {0}; memcpy_filter_ansi(prompt_filtered, prompt, sizeof(prompt_filtered), !session.supports_colors); #ifdef HAVE_READLINE - rl_event_hook = check_comm; cmd = readline(prompt_filtered); #else printf("%s", prompt_filtered); diff --git a/client/src/ui.c b/client/src/ui.c index 04e002950..e84d4203c 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -22,10 +22,6 @@ #include #include -#ifdef HAVE_READLINE -#include -#endif - #include #include "util.h" #include "proxmark3.h" // PROXLOG