emelianov/modbus-esp8266

BUG: Using #define MODBUSRTU_REDE's begin() leads to compilation error

fredlcore opened this issue · 2 comments

Hi,
I have a MAX485 board which requires DE/RE pins to be pulled high/low depending on sending/receiving data. Since I cannot tie both pins to one GPIO in my setup, I have to use two GPIOs to do that.
Therefore, I enabled MODBUSRTU_REDE and used this command to begin in the Modbus-RTU slave example of your repository:
mb.begin(&Serial2, 4, 5, true);

This results in a compiler error:

In file included from /Users/frederik/Documents/Arduino/RS485Slave/RS485Slave.ino:14:
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.h: In member function 'bool ModbusRTUTemplate::begin(T*, int16_t, int16_t, bool)':
/Users/frederik/Documents/Arduino/libraries/modbus-esp8266/src/ModbusRTU.h:96:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^

From what I can see, the error makes sense because the function is supposed to return a boolean value, but there is no return statement in the code.
I fixed this by adding return true; before the final closing bracket and the compiler error disappeared, but I don't know if there should be any kind of error checking to also return false if necessary.

Thank you!