From c3547cd39a9eee0d22dc5275cd87fba8221dc6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Althaus?= Date: Wed, 16 Oct 2024 11:45:44 +0200 Subject: [PATCH] When using absolute addressing, only read the minimal required words --- modbusApp/src/drvModbusAsyn.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modbusApp/src/drvModbusAsyn.cpp b/modbusApp/src/drvModbusAsyn.cpp index 16bad6a..4b72709 100644 --- a/modbusApp/src/drvModbusAsyn.cpp +++ b/modbusApp/src/drvModbusAsyn.cpp @@ -517,7 +517,7 @@ asynStatus drvModbusAsyn::readUInt32Digital(asynUser *pasynUser, epicsUInt32 *va /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(1, modbusLength_)); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; readOnceDone_ = true; @@ -667,7 +667,7 @@ asynStatus drvModbusAsyn::readInt32 (asynUser *pasynUser, epicsInt32 *value) /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(2, modbusLength_)); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; readOnceDone_ = true; @@ -828,7 +828,7 @@ asynStatus drvModbusAsyn::readInt64 (asynUser *pasynUser, epicsInt64 *value) /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(4, modbusLength_)); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; readOnceDone_ = true; @@ -974,7 +974,7 @@ asynStatus drvModbusAsyn::readFloat64 (asynUser *pasynUser, epicsFloat64 *value) /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(4, modbusLength_)); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; readOnceDone_ = true; @@ -1117,7 +1117,7 @@ asynStatus drvModbusAsyn::readInt32Array (asynUser *pasynUser, epicsInt32 *data, /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(maxChans, static_cast(modbusLength_))); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; } else { @@ -1287,7 +1287,7 @@ asynStatus drvModbusAsyn::readOctet(asynUser *pasynUser, char *data, size_t maxC /* If absolute addressing then there is no poller running */ if (checkModbusFunction(&modbusFunction)) return asynError; ioStatus_ = doModbusIO(modbusSlave_, modbusFunction, - offset, data_, modbusLength_); + offset, data_, std::min(maxChars, static_cast(modbusLength_))); if (ioStatus_ != asynSuccess) return(ioStatus_); offset = 0; } else {