Mazurel / Modbus

Modbus library for modern C++
MIT License
64 stars 15 forks source link

Exception on creating dummy (empty) ModbusRequest #6

Closed maxpejs closed 1 month ago

maxpejs commented 11 months ago

If I create an ModbusRequest without any values, it uses the ctor with default values. There is a switch statement and a valid function code value is required, so exception will be thrown

switch (functionRegisters()) { case utils::OutputCoils: ...

Mazurel commented 1 month ago

Thanks a lot for your report ! I have pushed a relevant fix, disallowing default ctors.

I will also try to review all classes constructors, for which I have created separate issue #10 When I was initially developing this library, I was not aware how complicated constructors can be in C++ ;)