mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
cleaning up, simplify
This commit is contained in:
parent
f2a954b422
commit
7eb7685559
2 changed files with 9 additions and 18 deletions
|
@ -503,7 +503,6 @@ static int CmdConnect(const char *Cmd) {
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
|
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
bool shall_free = false;
|
|
||||||
|
|
||||||
// default back to previous used serial port
|
// default back to previous used serial port
|
||||||
if (strlen(Cmd) == 0 ) {
|
if (strlen(Cmd) == 0 ) {
|
||||||
|
@ -511,9 +510,7 @@ static int CmdConnect(const char *Cmd) {
|
||||||
if ( len == 0 ) {
|
if ( len == 0 ) {
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
}
|
}
|
||||||
port = calloc(len + 1, sizeof(uint8_t));
|
port = (char *)conn.serial_port_name;
|
||||||
memcpy(port, conn.serial_port_name, len);
|
|
||||||
shall_free = true;
|
|
||||||
} else {
|
} else {
|
||||||
port = (char *)Cmd;
|
port = (char *)Cmd;
|
||||||
}
|
}
|
||||||
|
@ -522,12 +519,9 @@ static int CmdConnect(const char *Cmd) {
|
||||||
return usage_hw_connect();
|
return usage_hw_connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// always disconnect first.
|
|
||||||
PrintAndLogEx(INFO, "Disconnecting from current serial port");
|
PrintAndLogEx(INFO, "Disconnecting from current serial port");
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
session.pm3_present = false;
|
|
||||||
|
|
||||||
// try to open serial port
|
|
||||||
session.pm3_present = OpenProxmark(port, false, 20, false, USART_BAUD_RATE);
|
session.pm3_present = OpenProxmark(port, false, 20, false, USART_BAUD_RATE);
|
||||||
|
|
||||||
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
if (session.pm3_present && (TestProxmark() != PM3_SUCCESS)) {
|
||||||
|
@ -535,10 +529,6 @@ static int CmdConnect(const char *Cmd) {
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
session.pm3_present = false;
|
session.pm3_present = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( shall_free )
|
|
||||||
free(port);
|
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -556,9 +556,11 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// start the communication thread
|
// start the communication thread
|
||||||
|
if ( portname != (char*)conn.serial_port_name) {
|
||||||
uint16_t len = MIN( strlen(portname), FILE_PATH_SIZE - 1);
|
uint16_t len = MIN( strlen(portname), FILE_PATH_SIZE - 1);
|
||||||
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
memset(conn.serial_port_name, 0, FILE_PATH_SIZE);
|
||||||
memcpy(conn.serial_port_name, portname, len);
|
memcpy(conn.serial_port_name, portname, len);
|
||||||
|
}
|
||||||
conn.run = true;
|
conn.run = true;
|
||||||
conn.block_after_ACK = flash_mode;
|
conn.block_after_ACK = flash_mode;
|
||||||
// Flags to tell where to add CRC on sent replies
|
// Flags to tell where to add CRC on sent replies
|
||||||
|
@ -571,8 +573,7 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
||||||
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
__atomic_clear(&comm_thread_dead, __ATOMIC_SEQ_CST);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
// create a mutex to avoid interlacing print commands from our different threads
|
|
||||||
//pthread_mutex_init(&print_lock, NULL);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue