Testing pm3 communication
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ void clearCommandBuffer(void);
|
||||
|
||||
#define FLASHMODE_SPEED 460800
|
||||
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
|
||||
int TestProxmark(void);
|
||||
void CloseProxmark(void);
|
||||
|
||||
bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand *response, size_t ms_timeout, bool show_warning);
|
||||
|
||||
@@ -311,7 +311,6 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
port = argv[i];
|
||||
PrintAndLogEx(INFO, "Using UART port %s.\n", port);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -467,8 +466,10 @@ int main(int argc, char *argv[]) {
|
||||
if (port != NULL)
|
||||
usb_present = OpenProxmark(port, waitCOMPort, 20, false, speed);
|
||||
|
||||
if (TestProxmark() == 0)
|
||||
usb_present = false;
|
||||
if (!usb_present)
|
||||
PrintAndLogEx(NORMAL, "Running in " _YELLOW_("OFFLINE") "mode. Check \"%s -h\" if it's not what you want.\n", exec_name);
|
||||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Check \"%s -h\" if it's not what you want.\n", exec_name);
|
||||
|
||||
#ifdef HAVE_GUI
|
||||
|
||||
|
||||
Reference in New Issue
Block a user