arduino-libraries / ArduinoRS485

GNU Lesser General Public License v2.1
92 stars 69 forks source link

Alternate serial port #19

Closed jahartley closed 2 years ago

jahartley commented 2 years ago

This modification will allow this library to be used with alternate serial ports on boards that have more than one hardware serial port. Changes originally found here: https://forum.arduino.cc/t/arduinomodbus-for-other-shields-and-with-different-serial-port/878764

github-actions[bot] commented 2 years ago

Memory usage change @ 16cb2f8a4ef9e57d2e036ea54b688a521601a4d6

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkr1000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrfox1200 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrgsm1400 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrnb1500 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrvidor4000 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1300 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwan1310 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrwifi1010 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:samd:mkrzero 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table Board|examples/RS485Passthrough
flash|%|examples/RS485Passthrough
RAM for global variables|%|examples/RS485Receiver
flash|%|examples/RS485Receiver
RAM for global variables|%|examples/RS485Sender
flash|%|examples/RS485Sender
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|- arduino:mbed_portenta:envie_m7|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkr1000|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrfox1200|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrgsm1400|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrnb1500|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrvidor4000|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrwan1300|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrwan1310|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrwifi1010|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0 arduino:samd:mkrzero|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0|0|0.0
Click for full report CSV ``` Board,examples/RS485Passthrough
flash,%,examples/RS485Passthrough
RAM for global variables,%,examples/RS485Receiver
flash,%,examples/RS485Receiver
RAM for global variables,%,examples/RS485Sender
flash,%,examples/RS485Sender
RAM for global variables,% arduino:mbed_portenta:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkr1000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrfox1200,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrgsm1400,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrnb1500,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrvidor4000,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrwan1300,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrwan1310,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrwifi1010,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 arduino:samd:mkrzero,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0 ```
facchinm commented 2 years ago

Hi @jahartley , you can already change the serial port via the constructor https://github.com/arduino-libraries/ArduinoRS485/blob/master/src/RS485.cpp#L22 . Since it's the recommended and only way to change the DE and RE pins too I would leave no ambiguity and keep it as the only configuration method.