I am trying to modify this class so that I can use both SoftwareSerial and HardwareSerial objects. I therefore added a constructor that takes in a Stream object, the superclass of both Software and HardwareSerial:
/**
* Instantiates an SBUS object
* @param Stream* A HardwareSerial or SoftwareSerial object pointer
*/
SBUS::SBUS(const Stream *serialPort){
port = serialPort;
}
Unfortunately, in the SBUS::begin()
method I must call port->begin(BAUDRATE)
, and although begin()
exists as a method in both subclasses, because it is not in the Stream superclass, I cannot call it.
How can I call port->begin()
? I have tried to call begin()
on the Hardware or SoftwareSerial object externally in between SBUS construction and the SBUS::begin()
method, but this does not seem to initialize the SBUS object properly. Is there a way to call begin()
from inside the SBUS class?
I greatly appreciate any help. (FUTABA_SBUS was changed to SBUS for ease of programming)