mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
Linux: Detect soon when pm3 is unplugged
This commit is contained in:
parent
fa8bd85016
commit
ec5876ba35
1 changed files with 8 additions and 5 deletions
|
@ -319,7 +319,7 @@ __attribute__((force_align_arg_pointer))
|
||||||
*uart_communication(void *targ) {
|
*uart_communication(void *targ) {
|
||||||
communication_arg_t *connection = (communication_arg_t *)targ;
|
communication_arg_t *connection = (communication_arg_t *)targ;
|
||||||
uint32_t rxlen;
|
uint32_t rxlen;
|
||||||
bool sendfailed = false;
|
bool commfailed = false;
|
||||||
PacketResponseNG rx;
|
PacketResponseNG rx;
|
||||||
PacketResponseNGRaw rx_raw;
|
PacketResponseNGRaw rx_raw;
|
||||||
|
|
||||||
|
@ -336,8 +336,8 @@ __attribute__((force_align_arg_pointer))
|
||||||
|
|
||||||
// Signal to main thread that communications seems off.
|
// Signal to main thread that communications seems off.
|
||||||
// main thread will kill and restart this thread.
|
// main thread will kill and restart this thread.
|
||||||
if ( sendfailed ) {
|
if ( commfailed ) {
|
||||||
PrintAndLogEx(WARNING, "sending bytes to Proxmark3 device " _RED_("failed"));
|
PrintAndLogEx(WARNING, "Communicating with Proxmark3 device " _RED_("failed"));
|
||||||
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
__atomic_test_and_set(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -458,6 +458,9 @@ __attribute__((force_align_arg_pointer))
|
||||||
PrintAndLogEx(WARNING, "Received packet frame preamble too short: %d/%d", rxlen, sizeof(PacketResponseNGPreamble));
|
PrintAndLogEx(WARNING, "Received packet frame preamble too short: %d/%d", rxlen, sizeof(PacketResponseNGPreamble));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
if (res == PM3_ENOTTY) {
|
||||||
|
commfailed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&spMutex);
|
pthread_mutex_unlock(&spMutex);
|
||||||
|
@ -485,14 +488,14 @@ __attribute__((force_align_arg_pointer))
|
||||||
if (txBufferNGLen) { // NG packet
|
if (txBufferNGLen) { // NG packet
|
||||||
res = uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen);
|
res = uart_send(sp, (uint8_t *) &txBufferNG, txBufferNGLen);
|
||||||
if (res == PM3_EIO) {
|
if (res == PM3_EIO) {
|
||||||
sendfailed = true;
|
commfailed = true;
|
||||||
}
|
}
|
||||||
conn.last_command = txBufferNG.pre.cmd;
|
conn.last_command = txBufferNG.pre.cmd;
|
||||||
txBufferNGLen = 0;
|
txBufferNGLen = 0;
|
||||||
} else {
|
} else {
|
||||||
res = uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD));
|
res = uart_send(sp, (uint8_t *) &txBuffer, sizeof(PacketCommandOLD));
|
||||||
if (res == PM3_EIO) {
|
if (res == PM3_EIO) {
|
||||||
sendfailed = true;
|
commfailed = true;
|
||||||
}
|
}
|
||||||
conn.last_command = txBuffer.cmd;
|
conn.last_command = txBuffer.cmd;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue