9 years, 4 months ago.

The proper way to use Serial as my class member

I'd like to wrap a Serial member into my own class:

for example: in my myOBD.h file, define uart class member class myOBD { public: myOBD(PinName tx, PinName rx);

private: Serial uart; };

then, in myOBD.cpp, use member initializer list to intialize the uart with right TX and RX pin !! myOBD::myOBD(PinName tx, PinName rx) : uart(tx, rx) {};

but then, when I try to use the uart in other member function, it seems not working, anyone has some suggestions?

Thanks,

Question relating to:

That is proper way, so you need to give more details.

posted by Erik - 23 Jul 2015

Thanks Erik, I just confirmed on another mbed, it's working fine. So the original problem might be caused by hardware issue. Thanks!

posted by Hank Fang 23 Jul 2015
Be the first to answer this question.