mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
unplug detection
This commit is contained in:
parent
7785dcbce4
commit
de54d35d5f
3 changed files with 5 additions and 15 deletions
|
@ -533,14 +533,6 @@ bool IsCommunicationThreadDead(void) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool ReConnectProxmark(void) {
|
||||
char *port = serial_port_name;
|
||||
bool res = OpenProxmark(port, true, 20, false, _speed);
|
||||
if ( res )
|
||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||
|
||||
char *portname = (char *)port;
|
||||
|
@ -583,6 +575,7 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
conn.send_via_fpc_usart = false;
|
||||
|
||||
pthread_create(&communication_thread, NULL, &uart_communication, &conn);
|
||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||
|
||||
fflush(stdout);
|
||||
// create a mutex to avoid interlacing print commands from our different threads
|
||||
|
|
|
@ -64,7 +64,6 @@ void clearCommandBuffer(void);
|
|||
#define FLASHMODE_SPEED 460800
|
||||
void GetSavedSerialPortName( char **dest );
|
||||
bool IsCommunicationThreadDead(void);
|
||||
bool ReConnectProxmark(void);
|
||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
int TestProxmark(void);
|
||||
void CloseProxmark(void);
|
||||
|
|
|
@ -54,11 +54,9 @@ static void showBanner(void) {
|
|||
|
||||
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;
|
||||
}
|
||||
if ( IsCommunicationThreadDead() && session.pm3_present) {
|
||||
session.pm3_present = false;
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Use \"hw connect\" to reconnect\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -158,7 +156,7 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
|||
printprompt = true;
|
||||
|
||||
} else {
|
||||
//rl_event_hook = check_comm;
|
||||
rl_event_hook = check_comm;
|
||||
if (session.pm3_present )
|
||||
cmd = readline(PROXPROMPT);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue