diff --git a/client/comms.c b/client/comms.c index 7c349c908..4bcc2b7b8 100644 --- a/client/comms.c +++ b/client/comms.c @@ -570,7 +570,9 @@ int TestProxmark(void) { SendCommandOLD(CMD_PING, 0, 0, 0, NULL, 0); if (WaitForResponseTimeout(CMD_ACK, &resp, 5000)) { conn.send_via_fpc = resp.oldarg[0] == 1; - PrintAndLogEx(INFO, "Communicating with PM3 over %s.", conn.send_via_fpc ? "FPC" : "USB"); + PrintAndLogEx(INFO, "Communicating with PM3 over %s.", conn.send_via_fpc ? _YELLOW_("FPC") : _YELLOW_("USB-CDC")); + if (conn.send_via_fpc) + PrintAndLogEx(INFO, "UART Serial baudrate: " _YELLOW_("%u") "\n", conn.uart_speed); return 1; } else { return 0; @@ -619,7 +621,7 @@ void CloseProxmark(void) { // Let's take 2x (maybe we need more for BT link?) static size_t communication_delay(void) { if (conn.send_via_fpc) // needed also for Windows USB USART?? - return 2 * (12000000 / uart_speed); + return 2 * (12000000 / conn.uart_speed); return 100; } diff --git a/client/comms.h b/client/comms.h index 8ddbcd271..7952ce18c 100644 --- a/client/comms.h +++ b/client/comms.h @@ -47,6 +47,8 @@ typedef struct { bool send_with_crc_on_fpc; // "Session" flag, to tell via which interface next msgs are sent: USB or FPC USART bool send_via_fpc; + // To memorise baudrate, we don't want to call get_speed systematically + uint32_t uart_speed; } communication_arg_t; extern communication_arg_t conn; diff --git a/uart/uart.h b/uart/uart.h index 4cbea26c8..f97327953 100644 --- a/uart/uart.h +++ b/uart/uart.h @@ -39,6 +39,7 @@ #include #include #include "common.h" +#include "comms.h" #include "util_posix.h" // msclock @@ -103,7 +104,6 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed); /* Gets the current speed of the serial port, in baud. */ uint32_t uart_get_speed(const serial_port sp); -extern uint32_t uart_speed; #endif // _UART_H_ diff --git a/uart/uart_posix.c b/uart/uart_posix.c index e022c1ac0..30a9ba098 100644 --- a/uart/uart_posix.c +++ b/uart/uart_posix.c @@ -60,9 +60,6 @@ # define SOL_TCP IPPROTO_TCP #endif -// To memorise baudrate, we don't want to call get_speed systematically -uint32_t uart_speed; - typedef struct termios term_info; typedef struct { int fd; // Serial port file descriptor @@ -214,8 +211,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } } } - uart_speed = uart_get_speed(sp); - printf("[=] UART Setting serial baudrate %u\n", uart_speed); + conn.uart_speed = uart_get_speed(sp); return sp; } @@ -422,7 +418,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) { cfsetospeed(&ti, stPortSpeed); bool result = tcsetattr(spu->fd, TCSANOW, &ti) != -1; if (result) - uart_speed = uiPortSpeed; + conn.uart_speed = uiPortSpeed; return result; } diff --git a/uart/uart_win32.c b/uart/uart_win32.c index 36a10731a..80d6b8a24 100644 --- a/uart/uart_win32.c +++ b/uart/uart_win32.c @@ -42,9 +42,6 @@ #ifdef _WIN32 #include -// To memorise baudrate, we don't want to call get_speed systematically -uint32_t uart_speed; - typedef struct { HANDLE hPort; // Serial port handle DCB dcb; // Device control settings @@ -124,8 +121,7 @@ serial_port uart_open(const char *pcPortName, uint32_t speed) { } } } - uart_speed = uart_get_speed(sp); - printf("[=] UART Setting serial baudrate %u\n", uart_speed); + conn.uart_speed = uart_get_speed(sp); return sp; } @@ -157,7 +153,7 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed) { bool result = SetCommState(spw->hPort, &spw->dcb); PurgeComm(spw->hPort, PURGE_RXABORT | PURGE_RXCLEAR); if (result) - uart_speed = uiPortSpeed; + conn.uart_speed = uiPortSpeed; return result; }