Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 9 months ago.
Serial class as a member of my custom class
Hello, I have a problem with inicilization of class in another class. Here is my constructor:
PpmIn::PpmIn(PinName pin): ppm(pin), pc_com(USBTX, USBRX) { pc_com.printf("Constructor say hi!"); current_channel = 0; ...
pc_com is initialized in header file like this:
protected: Serial pc_com; InterruptIn ppm; ...
I think, that there shouldn't be a problem, but I always end with this error: Error: "mbed::Stream::Stream(const mbed::Stream &)" (declared at /extras/mbed-os.lib/drivers/Stream.h:68 is inaccessible in "extras/mbed-os.lib/drivers/Serial.h", Line: 52, Col: 43
Similar problem was discussed here: https://developer.mbed.org/forum/helloworld/topic/2771/
It seems, that I can't access constructor in mbed::Stream? Really? Do you know how to get over this? Thank you very much.
edy05
1 Answer
6 years, 9 months ago.
Hello Eduard,
That's strange because the following compiled for me with no errors:
PpmIn.h
#include "mbed.h" class PpmIn { public: PpmIn(PinName pin); protected: InterruptIn ppm; Serial pc_com; };
PpmIn.cpp
#include "PpmIn.h" PpmIn::PpmIn(PinName pin): ppm(pin), pc_com(USBTX, USBRX) { pc_com.printf("Constructor say hi!"); }
main.cpp
#include "mbed.h" #include "PpmIn.h" PpmIn myPpm(PA_9); int main(void) { while(1) {} }
Did you include the header files?
Strange. Could you please look at the full code here? https://developer.mbed.org/users/edy05/code/pwm-output/ I don't see any difference there.
posted by 09 Jun 2017