MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

MinorChanges: SoftwareSerial for RS485

Open ploeffler opened this issue 6 years ago • 3 comments

Todo: +) include SoftwareSerial to drivers +) include espsoftwareserial to drivers

Changes in File MySensors.h replace line 372 with

#if defined(MY_RS485_SWSERIAL) #if defined(ESP8266) || defined(ESP32) #include "drivers/ESPSoftwareSerial/SoftwareSerial.cpp" #elif #include "drivers/SoftwareSerial/SoftwareSerial.cpp" #endif #elif #include "drivers/AltSoftSerial/AltSoftSerial.cpp" #endif

File hal/transport/RS485/MyTransportRS485.cpp replace line 90 with:

#if defined(MY_RS485_SWSERIAL) SoftwareSerial& _dev = MY_RS485_SWSERIAL; #elif #include "drivers/AltSoftSerial/AltSoftSerial.cpp" #endif

thank you! (sorry for the formating)

ploeffler avatar Jun 14 '19 08:06 ploeffler

Thanks for your suggestion.

AVR (and maybe others) already use soft serial for rs485 by default, so there is no need to introduce a new define.

include SoftwareSerial to drivers

Could you describe which software serial you mean?

include espsoftwareserial to drivers

Do you mean https://github.com/plerup/espsoftwareserial ? (There are multiple libraries matching that name and it would be good if we knew which one to use.)

For reference, AltSoftSerial (which is currently used if a RS485 node or gateway is compiled for ESP8266/ESP32 with MySensors) provides this output during compilation:

In file included from ...\Arduino\libraries\MySensors/drivers/AltSoftSerial/AltSoftSerial.cpp:35:0,

                 from ...\Arduino\libraries\MySensors/MySensors.h:372,

                 from ...\Arduino\libraries\MySensors\examples\GatewaySerialRS485\GatewaySerialRS485.ino:89:

...\Arduino\libraries\MySensors/drivers/AltSoftSerial/config/AltSoftSerial_Boards.h:146:2: error: #error "Please define your board timer and pins"

 #error "Please define your board timer and pins"

  ^

Using library MySensors at version 2.3.2-beta in folder: ...\Arduino\libraries\MySensors

mfalkvidd avatar Jun 15 '19 09:06 mfalkvidd

sorry, no experiences with Altsoftserial, except the same you had (and had no motivation to read that part of the code too)

SoftwareSerial: i have read the discussions (some months ago) with the changes in the source too, its really not important WHICH of them to be used. just keep in mind that ESP's need another one then the AVR's

ploeffler avatar Jun 15 '19 13:06 ploeffler

I've created #1510 which implements the suggest fix. This enables RS485 communication on any compatible pin pair while keeping the default Serial interface for debugging purposes.

Please let me know if there is anything that needs to be adjusted to make it compatible with the project standards and concepts. Thanks!

kasparsd avatar Oct 29 '21 15:10 kasparsd