Skip to content

HardwareSerial and SoftwareSerial should have a common super class #4185

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

Open
drmpf opened this issue Nov 19, 2015 · 2 comments
Open

HardwareSerial and SoftwareSerial should have a common super class #4185

drmpf opened this issue Nov 19, 2015 · 2 comments
Assignees
Labels
Component: HardwareSerial The hardware serial functionality of the core libraries feature request A request to make an enhancement (not a bug fix)

Comments

@drmpf
Copy link

drmpf commented Nov 19, 2015

HardwareSerial and SoftwareSerial are supposed to be variations on a Serial connection, but they do not share a common superclass

Please add a superclass, 'Serial_", or some such, which contains the methods common to both HardwareSerial and SoftwareSerial.

At present libraries cannot accept HardwareSerial / SoftwareSerial objects interchangeably.

Particular use case is a library to determine the baud rate of an attached device.
Need to call multiple begin() methods with different baud rates, but have to have lots of extra code to workout if user is using HardwareSerial or SoftwareSerial for the connection.
On UNO, most likely has to use SoftwareSerial.
On Mega can/should use HardwareSerial

@hicklin-james
Copy link

Any progress on this as of yet? I am attempting to write a library for the ESP8266 wifi module and would like it's constructor to accept either a SoftwareSerial or HardwareSerial object. I can get most of the way there using the Stream superclass, but unfortunately it doesn't implement the begin function.

@NicoHood
Copy link
Contributor

NicoHood commented Apr 6, 2016

I dont think this is a good idea. This adds just more overhead. And you will not use softserial and hardwareserial at the same time. If you really want to support both of them a template would be the better choice or simply two different constructors.

Also in my opinion softserial is unreliable in most cases
https://github.com/arduino/Arduino/issues/4822

@per1234 per1234 added Component: HardwareSerial The hardware serial functionality of the core libraries feature request A request to make an enhancement (not a bug fix) labels Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: HardwareSerial The hardware serial functionality of the core libraries feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

No branches or pull requests

5 participants