mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
Merge pull request #2023 from wh201906/timeout
Make communication timeout configurable
This commit is contained in:
commit
3b7f2be264
5 changed files with 59 additions and 3 deletions
|
@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Fixed timeout of TCP connections (@wh201906)
|
||||
- Fixed the timeout of TCP connections (@wh201906)
|
||||
- Made the connection timeout configurable (@wh201906)
|
||||
|
||||
## [Seven.4.16717][2023-06-25]
|
||||
- Change `hf 14a info` - now identifes QL88 tags (@iceman1001)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "pm3_cmd.h"
|
||||
#include "pmflash.h" // rdv40validation_t
|
||||
#include "cmdflashmem.h" // get_signature..
|
||||
#include "uart/uart.h" // configure timeout
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -924,6 +925,47 @@ static int CmdTia(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdTimeout(const char *Cmd) {
|
||||
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hw timeout",
|
||||
"Set the communication timeout on the client side",
|
||||
"hw timeout --> Show current timeout\n"
|
||||
"hw timeout -t 20 --> Set the timeout to 20ms\n"
|
||||
"hw timeout -t 500 --> Set the timeout to 500ms\n"
|
||||
);
|
||||
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_int0("t", "timeout", "<dec>", "timeout in ms"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
int32_t arg = arg_get_int_def(ctx, 1, -1);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint32_t oldTimeout = uart_get_timeouts();
|
||||
|
||||
// timeout is not given/invalid, just show the current timeout then return
|
||||
if(arg < 0) {
|
||||
PrintAndLogEx(INFO, "Current communication timeout: %ums", oldTimeout);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t newTimeout = arg;
|
||||
// UART_USB_CLIENT_RX_TIMEOUT_MS is considered as the minimum required timeout.
|
||||
if (newTimeout < UART_USB_CLIENT_RX_TIMEOUT_MS) {
|
||||
PrintAndLogEx(WARNING, "Timeout less than %ums might cause errors.", UART_USB_CLIENT_RX_TIMEOUT_MS);
|
||||
}
|
||||
else if(newTimeout > 5000) {
|
||||
PrintAndLogEx(WARNING, "Timeout greater than 5000ms makes the client unresponsive.");
|
||||
}
|
||||
uart_reconfigure_timeouts(newTimeout);
|
||||
PrintAndLogEx(INFO, "Old communication timeout: %ums", oldTimeout);
|
||||
PrintAndLogEx(INFO, "New communication timeout: %ums", newTimeout);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
static int CmdPing(const char *Cmd) {
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "hw ping",
|
||||
|
@ -1062,6 +1104,7 @@ static command_t CommandTable[] = {
|
|||
{"status", CmdStatus, IfPm3Present, "Show runtime status information about the connected Proxmark3"},
|
||||
{"tearoff", CmdTearoff, IfPm3Present, "Program a tearoff hook for the next command supporting tearoff"},
|
||||
{"tia", CmdTia, IfPm3Present, "Trigger a Timing Interval Acquisition to re-adjust the RealTimeCounter divider"},
|
||||
{"timeout", CmdTimeout, AlwaysAvailable, "Set the communication timeout on the client side"},
|
||||
{"tune", CmdTune, IfPm3Present, "Measure antenna tuning"},
|
||||
{"version", CmdVersion, AlwaysAvailable, "Show version information about the client and the connected Proxmark3, if any"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
|
|
|
@ -74,8 +74,12 @@ bool uart_set_speed(serial_port sp, const uint32_t uiPortSpeed);
|
|||
*/
|
||||
uint32_t uart_get_speed(const serial_port sp);
|
||||
|
||||
/* Reconfigure timeouts
|
||||
/* Reconfigure timeouts (ms)
|
||||
*/
|
||||
int uart_reconfigure_timeouts(uint32_t value);
|
||||
#endif // _UART_H_
|
||||
|
||||
/* Get timeouts (ms)
|
||||
*/
|
||||
uint32_t uart_get_timeouts(void);
|
||||
|
||||
#endif // _UART_H_
|
||||
|
|
|
@ -69,6 +69,10 @@ int uart_reconfigure_timeouts(uint32_t value) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t uart_get_timeouts(void) {
|
||||
return newtimeout_value;
|
||||
}
|
||||
|
||||
serial_port uart_open(const char *pcPortName, uint32_t speed) {
|
||||
serial_port_unix_t_t *sp = calloc(sizeof(serial_port_unix_t_t), sizeof(uint8_t));
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ int uart_reconfigure_timeouts(uint32_t value) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t uart_get_timeouts(void) {
|
||||
return newtimeout_value;
|
||||
}
|
||||
|
||||
static int uart_reconfigure_timeouts_polling(serial_port sp) {
|
||||
if (newtimeout_pending == false)
|
||||
return PM3_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue