Testing pm3 communication

This commit is contained in:
Philippe Teuwen 2019-04-14 17:25:17 +02:00
parent 3cba736841
commit 04c0384d3e
6 changed files with 25 additions and 3 deletions

View file

@ -334,7 +334,6 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
conn.block_after_ACK = flash_mode;
pthread_create(&USB_communication_thread, NULL, &uart_communication, &conn);
//pthread_create(&FPC_communication_thread, NULL, &uart_communication, &conn);
fflush(stdout);
// create a mutex to avoid interlacing print commands from our different threads
//pthread_mutex_init(&print_lock, NULL);
@ -342,6 +341,21 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
}
}
int TestProxmark(void) {
// check if we can communicate with Pm3
clearCommandBuffer();
UsbCommand resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
PrintAndLogEx(INFO, "Ping successful, communicating with PM3 over %s.", resp.arg[0] == 1 ? "FPC" : "USB");
return 1;
} else {
PrintAndLogEx(WARNING, _RED_("Ping failed"));
return 0;
}
}
void CloseProxmark(void) {
conn.run = false;