USBSerial and HardwareSerial agnostic lib

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
aster
Posts: 1
Joined: Tue Mar 24, 2020 12:51 pm

USBSerial and HardwareSerial agnostic lib

Post 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?
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: USBSerial and HardwareSerial agnostic lib

Post by stas2z »

Stream class is a parent class for both
Post Reply

Return to “General discussion”