Skip to content

Commit

Permalink
devices/pipe-rtt: Properly handle timeout in RTT reads
Browse files Browse the repository at this point in the history
This change fixes the problem of plo's `wait` command not waiting while
using RTT console. Read operation was completed immediately instead of
blocking for at least `timeout`.

JIRA: NIL-596
  • Loading branch information
Darchiv committed Oct 16, 2024
1 parent 4c2dee7 commit 6faf84b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions devices/pipe-rtt/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@
static ssize_t pipe_read(unsigned int minor, addr_t offs, void *buff, size_t len, time_t timeout)
{
(void)offs;
(void)timeout;
time_t start = hal_timerGet();

return rtt_read(minor + 1, buff, len);
while (1 == 1) {
ssize_t ret = rtt_read(minor + 1, buff, len);

if (ret != 0) {
return ret;
}
if ((hal_timerGet() - start) >= timeout) {
return -ETIME;
}
}

return 0;
}


Expand Down

0 comments on commit 6faf84b

Please sign in to comment.