Commit fab36bc5 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

serial2002: discard pending characters before polling config

parent ba16f90b
......@@ -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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment