Skip to content
Snippets Groups Projects
Commit 94c46dc2 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Fix overflow error in serial2002 driver

parent 574666d1
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment