Page 1 of 1

USBSerial and HardwareSerial agnostic lib

Posted: Tue Mar 24, 2020 12:57 pm
by aster
Hello,

I am writing a lib that takes a Serial port as argument ina function. I would like to make the library agnostic and use both USBSerial and HardwareSerial

For example if i write on a maple mini

Code: Select all

my_lib(Serial);
It won't work because the Serial is a USBSerial, instead

Code: Select all

my_lib(Serial1);
Would work

How can i write my library to use both?

Re: USBSerial and HardwareSerial agnostic lib

Posted: Tue Mar 24, 2020 2:27 pm
by stas2z
Stream class is a parent class for both