diff --git a/plugins/serial2002/serial2002.c b/plugins/serial2002/serial2002.c index a8902487fd123426a1a0d9f91d66e8695c6ea7b9..e94ca95c6066d176dd91214f4d6c89283c612c9f 100644 --- a/plugins/serial2002/serial2002.c +++ b/plugins/serial2002/serial2002.c @@ -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: