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
c13bcd2d
Commit
c13bcd2d
authored
Dec 04, 2019
by
Anders Blomdell
Browse files
Add sanity check of values returned from serial2002_read
parent
7486a175
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/serial2002/serial2002.c
View file @
c13bcd2d
...
...
@@ -118,6 +118,10 @@ static struct moberg_status analog_in_read(
}
result
=
serial2002_read
(
device
->
port
.
fd
,
device
->
port
.
timeout
,
&
data
);
if
(
OK
(
result
))
{
if
((
data
.
kind
!=
is_channel
)
||
(
data
.
index
!=
map
.
index
))
{
result
=
MOBERG_ERRNO
(
ECHRNG
);
goto
return_result
;
}
*
value
=
(
data
.
value
*
map
.
delta
+
map
.
min
);
}
return_result:
...
...
@@ -173,6 +177,10 @@ static struct moberg_status digital_in_read(
}
result
=
serial2002_read
(
device
->
port
.
fd
,
device
->
port
.
timeout
,
&
data
);
if
(
OK
(
result
))
{
if
((
data
.
kind
!=
is_digital
)
||
(
data
.
index
!=
map
.
index
))
{
result
=
MOBERG_ERRNO
(
ECHRNG
);
goto
return_result
;
}
*
value
=
data
.
value
!=
0
;
}
return_result:
...
...
@@ -216,6 +224,10 @@ static struct moberg_status encoder_in_read(
}
result
=
serial2002_read
(
device
->
port
.
fd
,
device
->
port
.
timeout
,
&
data
);
if
(
OK
(
result
))
{
if
((
data
.
kind
!=
is_channel
)
||
(
data
.
index
!=
map
.
index
))
{
result
=
MOBERG_ERRNO
(
ECHRNG
);
goto
return_result
;
}
*
value
=
(
data
.
value
);
}
return_result:
...
...
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