mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-20 03:48:33 +08:00
chg: init timeout values everytime.
This commit is contained in:
parent
f68a398e42
commit
6113d6bbb4
1 changed files with 7 additions and 8 deletions
|
@ -82,6 +82,9 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
serial_port_unix *sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
|
serial_port_unix *sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
|
||||||
if (sp == 0) return INVALID_SERIAL_PORT;
|
if (sp == 0) return INVALID_SERIAL_PORT;
|
||||||
|
|
||||||
|
// init timeouts
|
||||||
|
uart_reconfigure_timeouts(sp, UART_FPC_CLIENT_RX_TIMEOUT_MS);
|
||||||
|
|
||||||
if (memcmp(pcPortName, "tcp:", 4) == 0) {
|
if (memcmp(pcPortName, "tcp:", 4) == 0) {
|
||||||
struct addrinfo *addr, *rp;
|
struct addrinfo *addr, *rp;
|
||||||
char *addrstr = strdup(pcPortName + 4);
|
char *addrstr = strdup(pcPortName + 4);
|
||||||
|
@ -147,7 +150,6 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sp->fd = open(pcPortName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
|
sp->fd = open(pcPortName, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
|
||||||
if (sp->fd == -1) {
|
if (sp->fd == -1) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
|
@ -200,15 +202,12 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||||
tcflush(sp->fd, TCIOFLUSH);
|
tcflush(sp->fd, TCIOFLUSH);
|
||||||
|
|
||||||
if (!uart_set_speed(sp, speed)) {
|
if (!uart_set_speed(sp, speed)) {
|
||||||
// trying some fallbacks automatically
|
// try fallback automatically
|
||||||
speed = 115200;
|
speed = 115200;
|
||||||
if (!uart_set_speed(sp, speed)) {
|
if (!uart_set_speed(sp, speed)) {
|
||||||
speed = 9600;
|
uart_close(sp);
|
||||||
if (!uart_set_speed(sp, speed)) {
|
printf("[!] UART error while setting baudrate\n");
|
||||||
uart_close(sp);
|
return INVALID_SERIAL_PORT;
|
||||||
printf("[!] UART error while setting baudrate\n");
|
|
||||||
return INVALID_SERIAL_PORT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn.uart_speed = uart_get_speed(sp);
|
conn.uart_speed = uart_get_speed(sp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue