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
025327b0
Commit
025327b0
authored
Mar 22, 2019
by
Anders Blomdell
Browse files
Only allow access to I/O that exists
parent
d57cfb63
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/serial2002/serial2002.c
View file @
025327b0
...
...
@@ -367,6 +367,28 @@ static int channel_down(struct moberg_channel *channel)
static
struct
moberg_status
channel_open
(
struct
moberg_channel
*
channel
)
{
struct
moberg_status
result
=
device_open
(
channel
->
context
->
device
);
int
count
=
0
;
switch
(
channel
->
kind
)
{
case
chan_ANALOGIN
:
count
=
channel
->
context
->
device
->
analog_in
.
count
;
break
;
case
chan_ANALOGOUT
:
count
=
channel
->
context
->
device
->
analog_out
.
count
;
break
;
case
chan_DIGITALIN
:
count
=
channel
->
context
->
device
->
digital_in
.
count
;
break
;
case
chan_DIGITALOUT
:
count
=
channel
->
context
->
device
->
digital_out
.
count
;
break
;
case
chan_ENCODERIN
:
count
=
channel
->
context
->
device
->
encoder_in
.
count
;
break
;
}
if
(
channel
->
context
->
index
>=
count
)
{
device_close
(
channel
->
context
->
device
);
result
=
MOBERG_ERRNO
(
ENODEV
);
}
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