Skip to content

Commit

Permalink
Bugfix: icarus: Never set timeout to 0, since it disables the timeout…
Browse files Browse the repository at this point in the history
… altogether
  • Loading branch information
luke-jr committed Jul 9, 2015
1 parent 23eb22f commit e75cce8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions driver-icarus.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ int icarus_read(const char * const repr, uint8_t *buf, const int fd, struct time
{
if (remaining_ms > 100)
remaining_ms = 100;
else
if (remaining_ms < 1)
remaining_ms = 1;
vcom_set_timeout_ms(fd, remaining_ms);
// Read first byte alone to get earliest tv_finish
ret = read(fd, buf, first ? 1 : read_size);
Expand Down
1 change: 1 addition & 0 deletions lowl-vcom.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
_serial_read(fd, buf, bufsiz, &eol)
extern int serial_close(int fd);

// NOTE: timeout_ms=0 means it never times out
extern bool vcom_set_timeout_ms(int fd, unsigned timeout_ms);
#define vcom_set_timeout(fd, timeout) vcom_set_timeout_ms(fd, (timeout) * 100)
extern enum bfg_gpio_value get_serial_cts(int fd);
Expand Down

0 comments on commit e75cce8

Please sign in to comment.