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;
|
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) {
|
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
|
||||||
|
|
||||||
char *portname = (char *)port;
|
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;
|
conn.send_via_fpc_usart = false;
|
||||||
|
|
||||||
pthread_create(&communication_thread, NULL, &uart_communication, &conn);
|
pthread_create(&communication_thread, NULL, &uart_communication, &conn);
|
||||||
|
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
// create a mutex to avoid interlacing print commands from our different threads
|
// create a mutex to avoid interlacing print commands from our different threads
|
||||||
|
|
|
@ -64,7 +64,6 @@ void clearCommandBuffer(void);
|
||||||
#define FLASHMODE_SPEED 460800
|
#define FLASHMODE_SPEED 460800
|
||||||
void GetSavedSerialPortName( char **dest );
|
void GetSavedSerialPortName( char **dest );
|
||||||
bool IsCommunicationThreadDead(void);
|
bool IsCommunicationThreadDead(void);
|
||||||
bool ReConnectProxmark(void);
|
|
||||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||||
int TestProxmark(void);
|
int TestProxmark(void);
|
||||||
void CloseProxmark(void);
|
void CloseProxmark(void);
|
||||||
|
|
|
@ -54,11 +54,9 @@ static void showBanner(void) {
|
||||||
|
|
||||||
int check_comm(void) {
|
int check_comm(void) {
|
||||||
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
// If communications thread goes down. Device disconnected then this should hook up PM3 again.
|
||||||
if ( IsCommunicationThreadDead() ) {
|
if ( IsCommunicationThreadDead() && session.pm3_present) {
|
||||||
session.pm3_present = ReConnectProxmark();
|
|
||||||
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
|
||||||
session.pm3_present = false;
|
session.pm3_present = false;
|
||||||
}
|
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Use \"hw connect\" to reconnect\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +156,7 @@ main_loop(char *script_cmds_file, char *script_cmd) {
|
||||||
printprompt = true;
|
printprompt = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//rl_event_hook = check_comm;
|
rl_event_hook = check_comm;
|
||||||
if (session.pm3_present )
|
if (session.pm3_present )
|
||||||
cmd = readline(PROXPROMPT);
|
cmd = readline(PROXPROMPT);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue