-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to choose the Serial port to work with #9
Comments
@chris007de What would be the workaround for now? I would like to use SoftwareSerial.h and pass that to the RS458 Class would that be possible? |
I'm using a fork as a workaround for now which changes the HardwareSerial parameter to a Stream danielmcmillan@0193f4e It is compatible with the ArduinoModbus library so long as a custom RS485 object is provided, so it can be used for Modbus over software serial. |
This issue also prevents the use of this library on the M4 core of the Portenta H7 board that does not define For me this solution would be the best:
|
This issue also fails on Raspberry Pi Pico as it does not define SERIAL_PORT_HARDWARE. |
I'm trying to get this working on STM32 which is a platform that uses The workarounds sound promising but L181 link above is to master which I now think is the wrong line number? Tempted to try the fork but that is some commits behind now too. What is the current workaround/solution to this? Thanks |
So I'm using the @danielmcmillan fork. Its allowed me to use this lib on STM32. Thanks. Would really love to see this (or similar) added to the official package here as it would improve compatibility vastly. |
Currently (1.0.0), the library automatically creates a RS485 object running on the
SERIAL_PORT_HARDWARE
serial port (https://github.com/arduino-libraries/ArduinoRS485/blob/master/src/RS485.cpp#L181).Although it might be idiomatic for Arduino libraries to automatically create an object to work with, for this library it causes trouble on some platforms and use cases:
Serial
, you still have to live with the automatically created RS485 object onSerial
, which is a waste of memory.Serial
is of typeUSBSerial
. As the RS485 constructor only acceptsHardwareSerial
, and you cannot set another Serial port, this causes that the library cannot be compiled for these platforms. Workaround is to remove L181 of RS485.cpp.So actually, I propose two changes:
Stream
as interface type for the RS485 constructor, so it can be created withHardwareSerial
as well as withUSBSerial
interfaces.SERIAL_PORT_HARDWARE
, but rather require the user to actively chose the desired port as a parameter in thebegin
method (I guess it is ok to haveSERIAL_PORT_HARDWARE
as the default value for the port parameter.) Drawback: This change is not backwards-compatible. Current users of the library will have to add a line to create the RS485 object manually.The text was updated successfully, but these errors were encountered: