Go Down

Topic: No begin in Stream, how to handle soft and hard serials as one general class? (Read 738 times) previous topic - next topic

liudr

I am trying to write code that can take either software or hardware serial object (arduino 1.0) and use it for communication. I'm aware that both inherit from Stream but after checking out the Stream code, I didn't find begin. Read, available are both there. I suppose the print and write are inherited from Print.

So my options are:
* Split into one function that does soft serial with a begin and another function that does hard serial with a begin.
* Demand the port to be initialized with a begin before the code can accept the pointer to the port and have one function to handle both initialized (begun) soft and hard serial ports.
* Any more elegant ways? Thank you!!!

Go Up