arduino-libraries / ArduinoRS485

GNU Lesser General Public License v2.1
88 stars 68 forks source link

invalid conversion from 'uint16_t' to 'SerialConfig' #14

Open mostafahk opened 3 years ago

mostafahk commented 3 years ago

In last update of ESP8266 SDK, I got many errors:

.pio\libdeps\esp12e\ArduinoRS485\src\RS485.cpp:65:28: error: invalid conversion from 'uint16_t' {aka 'short unsigned int'} to 'SerialConfig' [-fpermissive]

error occurs in _serial->begin call.

I solved problem with following changes:

In RS485.h:

#ifdef __AVR__
#define RS485_DEFAULT_DE_PIN 2
#define RS485_DEFAULT_RE_PIN -1
#elif defined(ESP32) || defined(ESP8266)
#define RS485_DEFAULT_DE_PIN 0
#define RS485_DEFAULT_RE_PIN 0
#else
#define RS485_DEFAULT_DE_PIN A6
#define RS485_DEFAULT_RE_PIN A5
#endif

#if defined(ESP32) || defined(ESP8266)
#define RS485_SER_CONF_TYPE SerialConfig
#else
#define RS485_SER_CONF_TYPE uint16_t
#endif
....

class RS485Class{
....
RS485_SER_CONF_TYPE _config;
...
}

In RS485.cpp:

_serial->begin(baudrate, (RS485_SER_CONF_TYPE)config);
mostafahk commented 3 years ago

I've made my change in a fork and my pull request is here.

kscholty commented 2 years ago

Could someone please merge the according PR? This ssue makes it impossible to use the lib on ESP MCs. The ESP32's SERIAL_8N1 config value is a 32 bit value (0x800001C)

rseidt commented 5 months ago

I stumbled upon this problem, and (once again) fixed that issue, because the mentined PR #16 seem abononed (last commit 2 years ago). Please find an updated PR here: Added Compatibility to ESP32 and ESP8266 #53

mattl1598 commented 4 months ago

is this going to be approved soon? would be nice to use a proper release version of the library and keep it updated through the arduino ide