CMB27 / ModbusRTUMaster

A library to implement the master/client portion of the Modbus RTU protocol on Arduino
MIT License
41 stars 7 forks source link

Problem with ESP8266 #6

Closed cturqueti closed 10 months ago

cturqueti commented 10 months ago

i try work with ESP8266 an ai have a problem:

c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.cpp:43:6: error: no declaration matches 'void ModbusRTUMaster::begin(long unsigned int, uint8_t)'
   43 | void ModbusRTUMaster::begin(unsigned long baud, uint8_t config) {
      |      ^~~~~~~~~~~~~~~
In file included from c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.cpp:1:
c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.h:22:10: note: candidate is: 'void ModbusRTUMaster::begin(uint32_t, uint8_t)'
   22 |     void begin(uint32_t baud, uint8_t config = SERIAL_8N1);
      |          ^~~~~
c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.h:12:7: note: 'class ModbusRTUMaster' defined here
   12 | class ModbusRTUMaster {
      |       ^~~~~~~~~~~~~~~
c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.cpp:289:6: error: no declaration matches 'void ModbusRTUMaster::_calculateTimeouts(long unsigned int, uint8_t)'
  289 | void ModbusRTUMaster::_calculateTimeouts(unsigned long baud, uint8_t config) {
      |      ^~~~~~~~~~~~~~~
In file included from c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.cpp:1:
c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.h:57:10: note: candidate is: 'void ModbusRTUMaster::_calculateTimeouts(uint32_t, uint8_t)'
   57 |     void _calculateTimeouts(uint32_t baud, uint8_t config);
      |          ^~~~~~~~~~~~~~~~~~
c:\Users\Carlos\Documents\Arduino\libraries\ModbusRTUMaster\src\ModbusRTUMaster.h:12:7: note: 'class ModbusRTUMaster' defined here
   12 | class ModbusRTUMaster {
      |       ^~~~~~~~~~~~~~~

exit status 1

Compilation error: exit status 1
CMB27 commented 10 months ago

Can I get some more information?

cturqueti commented 10 months ago

I removed the config variable and it worked on the ESP32, I think that on the ESP32 there is no serial configuration SERIAL8N1

CMB27 commented 10 months ago

As per HardwareSerial from the Espressif arduino-esp32 core, there is a SERIAL_8N1, however the defined value requires a 32 bit variable to store it. Up until recently I have used 8 bit variables to store/transfer the configuration, which is sufficient for an AVR, but not an RP2040 or ESP32, therefore I have changed all the variables that handle configuration from uint8_t to uint32_t. Using the latest version of this library may solve your issue.

cturqueti commented 10 months ago

It worked, thank you.