Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
moberg
Commits
fab36bc5
Commit
fab36bc5
authored
Mar 09, 2021
by
Anders Blomdell
Browse files
serial2002: discard pending characters before polling config
parent
ba16f90b
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/serial2002/serial2002_lib.c
View file @
fab36bc5
...
@@ -204,6 +204,23 @@ static struct moberg_status update_channel(struct serial2002_channel *channel,
...
@@ -204,6 +204,23 @@ static struct moberg_status update_channel(struct serial2002_channel *channel,
return
MOBERG_OK
;
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
(
static
struct
moberg_status
do_read_config
(
int
fd
,
int
fd
,
long
timeout
,
long
timeout
,
...
@@ -211,6 +228,7 @@ static struct moberg_status do_read_config(
...
@@ -211,6 +228,7 @@ static struct moberg_status do_read_config(
{
{
struct
serial2002_data
data
=
{
0
,
0
};
struct
serial2002_data
data
=
{
0
,
0
};
discard_pending
(
fd
);
memset
(
config
,
0
,
sizeof
(
*
config
));
memset
(
config
,
0
,
sizeof
(
*
config
));
serial2002_poll_channel
(
fd
,
31
);
serial2002_poll_channel
(
fd
,
31
);
while
(
1
)
{
while
(
1
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment