mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-24 15:15:39 -07:00
Merge pull request #2225 from wh201906/reconnect
Some fixes for the reconnect feature
This commit is contained in:
commit
722b5cc66d
4 changed files with 21 additions and 11 deletions
|
@ -355,6 +355,8 @@ void *uart_reconnect(void *targ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
// throttle
|
||||||
|
msleep(200);
|
||||||
if (OpenProxmarkSilent(&g_session.current_device, connection->serial_port_name, speed) == false) {
|
if (OpenProxmarkSilent(&g_session.current_device, connection->serial_port_name, speed) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -699,7 +701,7 @@ size_t GetCommunicationRawReceiveNum(void) {
|
||||||
|
|
||||||
bool OpenProxmarkSilent(pm3_device_t **dev, const char *port, uint32_t speed) {
|
bool OpenProxmarkSilent(pm3_device_t **dev, const char *port, uint32_t speed) {
|
||||||
|
|
||||||
sp = uart_open(port, speed);
|
sp = uart_open(port, speed, true);
|
||||||
|
|
||||||
// check result of uart opening
|
// check result of uart opening
|
||||||
if (sp == INVALID_SERIAL_PORT) {
|
if (sp == INVALID_SERIAL_PORT) {
|
||||||
|
@ -742,14 +744,14 @@ bool OpenProxmark(pm3_device_t **dev, const char *port, bool wait_for_port, int
|
||||||
|
|
||||||
if (!wait_for_port) {
|
if (!wait_for_port) {
|
||||||
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), port);
|
PrintAndLogEx(INFO, "Using UART port " _YELLOW_("%s"), port);
|
||||||
sp = uart_open(port, speed);
|
sp = uart_open(port, speed, false);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), port);
|
PrintAndLogEx(SUCCESS, "Waiting for Proxmark3 to appear on " _YELLOW_("%s"), port);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
int openCount = 0;
|
int openCount = 0;
|
||||||
PrintAndLogEx(INPLACE, "% 3i", timeout);
|
PrintAndLogEx(INPLACE, "% 3i", timeout);
|
||||||
do {
|
do {
|
||||||
sp = uart_open(port, speed);
|
sp = uart_open(port, speed, false);
|
||||||
msleep(500);
|
msleep(500);
|
||||||
PrintAndLogEx(INPLACE, "% 3i", timeout - openCount - 1);
|
PrintAndLogEx(INPLACE, "% 3i", timeout - openCount - 1);
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,10 @@ typedef void *serial_port;
|
||||||
* used for future references to that port.
|
* used for future references to that port.
|
||||||
*
|
*
|
||||||
* On errors, this method returns INVALID_SERIAL_PORT or CLAIMED_SERIAL_PORT.
|
* On errors, this method returns INVALID_SERIAL_PORT or CLAIMED_SERIAL_PORT.
|
||||||
|
* If slient is set to false, this function will print the error information
|
||||||
|
* when error occurs.
|
||||||
*/
|
*/
|
||||||
serial_port uart_open(const char *pcPortName, uint32_t speed);
|
serial_port uart_open(const char *pcPortName, uint32_t speed, bool slient);
|
||||||
|
|
||||||
/* Closes the given port.
|
/* Closes the given port.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,7 +81,7 @@ uint32_t uart_get_timeouts(void) {
|
||||||
return newtimeout_value;
|
return newtimeout_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
serial_port uart_open(const char *pcPortName, uint32_t speed, bool slient) {
|
||||||
serial_port_unix_t_t *sp = calloc(sizeof(serial_port_unix_t_t), sizeof(uint8_t));
|
serial_port_unix_t_t *sp = calloc(sizeof(serial_port_unix_t_t), sizeof(uint8_t));
|
||||||
|
|
||||||
if (sp == 0) {
|
if (sp == 0) {
|
||||||
|
@ -98,7 +98,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
|
|
||||||
char *prefix = str_dup(pcPortName);
|
char *prefix = str_dup(pcPortName);
|
||||||
if (prefix == NULL) {
|
if (prefix == NULL) {
|
||||||
PrintAndLogEx(ERR, "error: string duplication");
|
PrintAndLogEx(ERR, "error: string duplication");
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
free(addrPortStr);
|
free(addrPortStr);
|
||||||
|
|
||||||
if (rp == NULL) { /* No address succeeded */
|
if (rp == NULL) { /* No address succeeded */
|
||||||
PrintAndLogEx(ERR, "error: Could not connect");
|
if (slient == false) {
|
||||||
|
PrintAndLogEx(ERR, "error: Could not connect");
|
||||||
|
}
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
@ -292,7 +294,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
if (connect(sfd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
|
||||||
PrintAndLogEx(ERR, "Error: cannot connect device " _YELLOW_("%s") " over Bluetooth", addrstr);
|
if (slient == false) {
|
||||||
|
PrintAndLogEx(ERR, "Error: cannot connect device " _YELLOW_("%s") " over Bluetooth", addrstr);
|
||||||
|
}
|
||||||
close(sfd);
|
close(sfd);
|
||||||
free(addrstr);
|
free(addrstr);
|
||||||
free(sp);
|
free(sp);
|
||||||
|
|
|
@ -82,7 +82,7 @@ static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
serial_port uart_open(const char *pcPortName, uint32_t speed, bool slient) {
|
||||||
char acPortName[255] = {0};
|
char acPortName[255] = {0};
|
||||||
serial_port_windows_t *sp = calloc(sizeof(serial_port_windows_t), sizeof(uint8_t));
|
serial_port_windows_t *sp = calloc(sizeof(serial_port_windows_t), sizeof(uint8_t));
|
||||||
sp->hSocket = INVALID_SOCKET; // default: serial port
|
sp->hSocket = INVALID_SOCKET; // default: serial port
|
||||||
|
@ -99,7 +99,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
|
|
||||||
char *prefix = str_dup(pcPortName);
|
char *prefix = str_dup(pcPortName);
|
||||||
if (prefix == NULL) {
|
if (prefix == NULL) {
|
||||||
PrintAndLogEx(ERR, "error: string duplication");
|
PrintAndLogEx(ERR, "error: string duplication");
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
free(addrPortStr);
|
free(addrPortStr);
|
||||||
|
|
||||||
if (rp == NULL) { /* No address succeeded */
|
if (rp == NULL) { /* No address succeeded */
|
||||||
PrintAndLogEx(ERR, "error: Could not connect");
|
if (slient == false) {
|
||||||
|
PrintAndLogEx(ERR, "error: Could not connect");
|
||||||
|
}
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
free(sp);
|
free(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue