I'm trying to creaper class wraper to use an Streamobject but I've an error when I try to compile.
My .hfile :
#include <Arduino.h>
class TestSerialListener {
public:
TestSerialListener(Stream &serial);
void testPrint(void);
private:
bool _listener_start;
Stream &_serial;
void startListener(void);
};
my cppfile
#include "TestSerialListener.h"
#include <Arduino.h>
TestSerialListener::TestSerialListener(Stream &serial) : _serial(serial)
{
}
void TestSerialListener::testPrint(){
_serial.begin(115200); <---------- error compilation
_serial.println("test");
}
void TestSerialListener::startListener(void)
{
if(!_listener_start){
_listener_start = true;
}
}
And when i try to compile it I got this error : error: 'class Stream' has no member named 'begin'Why I can't use begin()in my classe ?
Streamclass has no method namedbegin”. Does this answer your question? – Edgar Bonet Jan 30 '23 at 08:43SerialUSB.begin(115200)in my sketch ? @EdgarBonet – simon Jan 30 '23 at 08:44SerialUSBdoes have a method namedbegin. SomeStream-derived classes can have such a method, It's just not something you can expect from anyStreamobject. – Edgar Bonet Jan 30 '23 at 08:48