emelianov / modbus-esp8266

Most complete Modbus library for Arduino. A library that allows your Arduino board to communicate via Modbus protocol, acting as a master, slave or both. Supports network transport (Modbus TCP) and Serial line/RS-485 (Modbus RTU). Supports Modbus TCP Security for ESP8266/ESP32.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

fredlcore opened this issue · 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.