Skip to content

Commit 3073311

Browse files
committed
tom_modem: fix: use difftime instead count
Signed-off-by: sfwtw <wtw@cr.cx>
1 parent 85efaca commit 3073311

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

application/tom_modem/src/ttydevice.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ int tty_read_keyword(FILE *fdi, AT_MESSAGE_T *message, char *key_word, PROFILE_T
139139
int read_flag = 0;
140140
time_t start_time = time(NULL);
141141
int exitcode = TIMEOUT_WAITING_NEWLINE;
142-
int flush_count = 0;
143142

144-
while (flush_count < 50 && fgets(tmp, LINE_BUF, fdi) != NULL) {
143+
while (difftime(time(NULL), start_time) < 1) {
144+
if (fgets(tmp, LINE_BUF, fdi) == NULL) {
145+
break;
146+
}
145147
dbg_msg("Flushed stale data: %s", tmp);
146-
usleep(10000);
147-
flush_count++;
148148
}
149149

150150
while (difftime(time(NULL), start_time) < profile->timeout) {

0 commit comments

Comments
 (0)