QModbusDataUnit startAddress offset
-
Referring to the manufacturer modbus' register table, I noticed I have to pass to the
startAddress
parameter a value with offset -1. Example:QModbusDataUnit readRequest() { return QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 49, 2); // <--- actually is 50 } void read() { if (auto *reply = _device->sendReadRequest(readRequest(), 1)) { if (!reply->isFinished()) QObject::connect(reply, &QModbusReply::finished, [reply]() { // ..... }
In that table the actual address is 50. If I use, say,
modpoll
I pass 50 as start address. But withQModbusDataUnit
I have to pass 49!Is this offset documented anywhere?
-
Referring to the manufacturer modbus' register table, I noticed I have to pass to the
startAddress
parameter a value with offset -1. Example:QModbusDataUnit readRequest() { return QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 49, 2); // <--- actually is 50 } void read() { if (auto *reply = _device->sendReadRequest(readRequest(), 1)) { if (!reply->isFinished()) QObject::connect(reply, &QModbusReply::finished, [reply]() { // ..... }
In that table the actual address is 50. If I use, say,
modpoll
I pass 50 as start address. But withQModbusDataUnit
I have to pass 49!Is this offset documented anywhere?
-
@Mark81 seems like
modpoll
is starting its counting by 1 instead of 0.
Which is the incorrect way, since register 0 is defined as a valid register in the standard