-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Labels
topic: codeRelated to content of the project itselfRelated to content of the project itselftype: enhancementProposed improvementProposed improvement
Description
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:
- If you want to use a different Serial port than
Serial, you still have to live with the automatically created RS485 object onSerial, which is a waste of memory. - On some platforms (e.g. some STM32),
Serialis 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:
- Use
Streamas interface type for the RS485 constructor, so it can be created withHardwareSerialas well as withUSBSerialinterfaces. - Do not create a RS485 object on
SERIAL_PORT_HARDWARE, but rather require the user to actively chose the desired port as a parameter in thebeginmethod (I guess it is ok to haveSERIAL_PORT_HARDWAREas 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.
danielmcmillan, romainreignier, per1234, dabenman, bobemoe and 2 more
Metadata
Metadata
Assignees
Labels
topic: codeRelated to content of the project itselfRelated to content of the project itselftype: enhancementProposed improvementProposed improvement