Open GoogleCodeExporter opened 9 years ago
This should probably be a new abstract base class (between Stream and
HardwareSerial), since the begin() method doesn't make sense for every Stream -
or, at least, wouldn't mean the same thing for all of them.
Original comment by dmel...@gmail.com
on 1 Aug 2011 at 1:20
my suggestion on how to implement this feature, for starters would be something
like a serial class extending Stream:
class AbstractSerial : public Stream
{
public:
virtual void begin(unsigned long);
virtual void begin(unsigned long, uint8_t);
virtual void end();
};
then, on HardwareSerial.h:
class HardwareSerial : public AbstractSerial
{
...
}
on SoftwareSerial.h:
class SoftwareSerial : public AbstractSerial
{
...
}
on USBAPI.h:
class Serial_ : public AbstractSerial
{
...
}
After this we could happily do things like:
#include <SoftwareSerial.h>
SoftwareSerial mySerial1(2, 3);
SoftwareSerial mySerial2(4, 5);
MIDI midiShield(mySerial1);
MIDI midiSynth(mySerial2);
void setup(){
...
...because now we could call the begin method regardless of what kind of Serial
port we're giving to the object using it.
I hope you look into this.
cheers.
Original comment by tiagocus...@gmail.com
on 13 Mar 2013 at 4:55
Original issue reported on code.google.com by
tiagocus...@gmail.com
on 18 Jul 2011 at 2:13