Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
5.10.0
-
None
Description
QModbusServer only supports subsequent data unit register addresses. If one tries to add multiple ranges of values, the current implementation breaks and fails to read/write data units.
My current workaround: Sub-class QModbusServer and implement separate data unit storages, one for each register type. I've introduced a new method called initDataUnit(), which I use iso. setMap(). I'd suggest implementing something similar in Qt in order to support scattered register maps.
typedef QMap<int, QModbusDataUnit> RegisterMap; class MyModbusServer : public QModbusServer { { //... public: bool setMap(...) { return false; } void initDataUnit(const QModbusDataUnit &dataUnit) { /* add unit to one of the maps */ } protected: bool writeData(...) { ... } bool readData(...) { ... } private: RegisterMap m_coils; RegisterMap m_discrete_input; RegisterMap m_input_registers; RegisterMap m_holding_registers; }