diff --git a/client/cmdhw.c b/client/cmdhw.c index 8c687e232..fc4f4c422 100644 --- a/client/cmdhw.c +++ b/client/cmdhw.c @@ -491,7 +491,14 @@ void pm3_version(bool verbose) { PacketResponseNG resp; clearCommandBuffer(); SendCommandOLD(CMD_VERSION, 0, 0, 0, NULL, 0); +#ifdef USART_SLOW_LINK + // 10s timeout for slow FPC, e.g. over BT + // as this is the very first command sent to the pm3 + // that initiates the BT connection + if (WaitForResponseTimeout(CMD_ACK, &resp, 10000)) { +#else if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { +#endif #ifdef __WIN32 PrintAndLogEx(NORMAL, "\n [ Proxmark3 RFID instrument ]\n"); #else diff --git a/client/comms.c b/client/comms.c index 12157f41e..c52872870 100644 --- a/client/comms.c +++ b/client/comms.c @@ -421,7 +421,7 @@ __attribute__((force_align_arg_pointer)) PacketResponseOLD rx_old; memcpy(&rx_old, &rx_raw.pre, sizeof(PacketResponseNGPreamble)); if ((!uart_receive(sp, ((uint8_t *)&rx_old) + sizeof(PacketResponseNGPreamble), sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble), &rxlen)) || (rxlen != sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble))) { - PrintAndLogEx(WARNING, "Received packet frame error var part too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble)); + PrintAndLogEx(WARNING, "Received packet OLD frame payload error too short? %d/%d", rxlen, sizeof(PacketResponseOLD) - sizeof(PacketResponseNGPreamble)); error = true; } if (!error) { diff --git a/common/usart.c b/common/usart.c index 4200fb5fb..3e10d13bf 100644 --- a/common/usart.c +++ b/common/usart.c @@ -122,7 +122,14 @@ uint32_t usart_read_ng(uint8_t *data, size_t len) { // uint32_t highest_observed_try = 0; // Empirical max try observed: 3000000 / USART_BAUD_RATE // Let's take 10x - uint32_t maxtry = 10 * (3000000 / USART_BAUD_RATE); + + uint32_t tryconstant = 0; +#ifdef USART_SLOW_LINK + // Experienced up to 13200 tries on BT link even at 460800 + tryconstant = 50000; +#endif + + uint32_t maxtry = 10 * (3000000 / USART_BAUD_RATE) + tryconstant; while (len) { uint32_t available = usart_rxdata_available(); diff --git a/include/usb_cmd.h b/include/usb_cmd.h index a52271d61..38381e97a 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -13,6 +13,9 @@ #ifndef __USB_CMD_H #define __USB_CMD_H +// Use it e.g. when using slow links such as BT +#define USART_SLOW_LINK + #ifdef _MSC_VER typedef DWORD uint32_t; typedef BYTE uint8_t;