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
Mattias Fält
moberg
Commits
94c46dc2
Commit
94c46dc2
authored
Apr 03, 2019
by
Anders Blomdell
Browse files
Fix overflow error in serial2002 driver
parent
574666d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/serial2002/serial2002.c
View file @
94c46dc2
...
...
@@ -134,7 +134,14 @@ static struct moberg_status analog_out_write(
struct
moberg_channel_context
*
channel
=
&
analog_out
->
channel_context
;
struct
moberg_device_context
*
device
=
channel
->
device
;
struct
analog_map
map
=
device
->
analog_out
.
map
[
channel
->
index
];
long
as_long
=
(
desired_value
-
map
.
min
)
/
map
.
delta
;
long
as_long
;
if
(
desired_value
<
map
.
min
)
{
as_long
=
0
;
}
else
if
(
desired_value
>
map
.
max
)
{
as_long
=
map
.
maxdata
;
}
else
{
as_long
=
(
desired_value
-
map
.
min
)
/
map
.
delta
;
}
if
(
as_long
<
0
)
{
as_long
=
0
;
}
else
if
(
as_long
>
map
.
maxdata
)
{
...
...
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