Skip to content
Snippets Groups Projects
Commit fab36bc5 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

serial2002: discard pending characters before polling config

parent ba16f90b
No related branches found
No related tags found
No related merge requests found
......@@ -204,6 +204,23 @@ static struct moberg_status update_channel(struct serial2002_channel *channel,
return MOBERG_OK;
}
static void discard_pending(int fd)
{
struct pollfd pollfd;
while (1) {
pollfd.fd = fd;
pollfd.events = POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR;
int err = poll(&pollfd, 1, 0);
if (err <= 0) {
break;
} else {
char discard;
read(fd, &discard, 1);
}
}
}
static struct moberg_status do_read_config(
int fd,
long timeout,
......@@ -211,6 +228,7 @@ static struct moberg_status do_read_config(
{
struct serial2002_data data = { 0, 0 };
discard_pending(fd);
memset(config, 0, sizeof(*config));
serial2002_poll_channel(fd, 31);
while (1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment