nickexists
Active member
I'm trying to write a class to help manage serial communications in my project. I'm trying to make it so that the constructor saves a reference to the serial object it is given and then methods of the class will write to and read from the serial object. The problem is that Serial1 Serial2 and Serial3 are different HardwareSerial objects while Serial is a usb_serial_class object. How can I make my class compatible with both types.
Example:
Example:
Code:
class Comms
{
public:
Comms(HardwareSerial& serial);
void floatToBytes(float in);
private:
HardwareSerial& _serial;
};
Comms::Comms(HardwareSerial& serial):_serial(serial)
{
}
void Comms::doStuff(int in)
{
_serial.write(b);
}
}