From e9c43e11b18979a63f471e7c5620e3801bf6a798 Mon Sep 17 00:00:00 2001 From: fujr Date: Sun, 19 Jan 2025 02:03:48 +0800 Subject: [PATCH] at_tools: fix bugs 1 reset buffer before each read 2 increase sleep duration --- application/tom_modem/src/ttydevice.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/application/tom_modem/src/ttydevice.c b/application/tom_modem/src/ttydevice.c index 3569985..7c042c7 100644 --- a/application/tom_modem/src/ttydevice.c +++ b/application/tom_modem/src/ttydevice.c @@ -132,12 +132,13 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_ time_t start_time = time(NULL); int exitcode = TIMEOUT_WAITING_NEWLINE; while (difftime(time(NULL), start_time) < soft_timeout) - { + { + memset(tmp, 0, LINE_BUF); if (fgets(tmp, LINE_BUF, fdi)) { read_flag = 1; dbg_msg("%s", tmp); - if (output != NULL) + if (output != NULL) msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp); if (strncmp(tmp, "OK", 2) == 0 || @@ -176,7 +177,7 @@ int tty_read_keyword(FILE *fdi, char *output, int len, char *key_word, int soft_ } } #endif - usleep(1000); + usleep(10000); } if (read_flag == 0) {