at_tools: fix bugs

1 reset buffer before each read
2 increase sleep duration
This commit is contained in:
fujr 2025-01-19 02:03:48 +08:00
parent d66ae5e830
commit e9c43e11b1

View File

@ -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); time_t start_time = time(NULL);
int exitcode = TIMEOUT_WAITING_NEWLINE; int exitcode = TIMEOUT_WAITING_NEWLINE;
while (difftime(time(NULL), start_time) < soft_timeout) while (difftime(time(NULL), start_time) < soft_timeout)
{ {
memset(tmp, 0, LINE_BUF);
if (fgets(tmp, LINE_BUF, fdi)) if (fgets(tmp, LINE_BUF, fdi))
{ {
read_flag = 1; read_flag = 1;
dbg_msg("%s", tmp); dbg_msg("%s", tmp);
if (output != NULL) if (output != NULL)
msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp); msg_len += snprintf(output + msg_len, len - msg_len, "%s", tmp);
if (strncmp(tmp, "OK", 2) == 0 || 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 #endif
usleep(1000); usleep(10000);
} }
if (read_flag == 0) if (read_flag == 0)
{ {