mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-13 01:57:25 -07:00
Testing pm3 communication
This commit is contained in:
parent
3cba736841
commit
04c0384d3e
6 changed files with 25 additions and 3 deletions
|
@ -1443,7 +1443,11 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
|||
SendStatus();
|
||||
break;
|
||||
case CMD_PING:
|
||||
#ifdef WITH_FPC_HOST
|
||||
cmd_send(CMD_ACK, reply_via_fpc, 0, 0, 0, 0);
|
||||
#else
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
#endif
|
||||
break;
|
||||
#ifdef WITH_LCD
|
||||
case CMD_LCD_RESET:
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ struct timeval timeout = {
|
|||
};
|
||||
|
||||
serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||
printf("[=] Using UART port %s.\n", pcPortName);
|
||||
serial_port_unix *sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
|
||||
if (sp == 0) return INVALID_SERIAL_PORT;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef struct {
|
|||
} serial_port_windows;
|
||||
|
||||
serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||
printf("[=] Using UART port %s.\n", pcPortName);
|
||||
char acPortName[255];
|
||||
serial_port_windows *sp = calloc(sizeof(serial_port_windows), sizeof(uint8_t));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue