How to initialize SoftwareSerial in a class in another Library
this might silly question have forgotten c/c++ classes long time ago. trying create library gprs shield , want include softwareserial object inside new object creating. header file include presume declaration of class member:
the constructor softwareserial have passed rx , tx pins. , want these parameters of function, maybe begin:
not sure if should use "new" or not.
code: [select]
class sms
{
public:
sms();
void begin();
softwareserial smsserial;
private:
}
the constructor softwareserial have passed rx , tx pins. , want these parameters of function, maybe begin:
code: [select]
sms::sms()
{
smsflags = b00000000;
}
void sms::begin(int rxpin, int txpin)
{
smsserial = new softwareserial(rxpin,txpin); //<---- i'm supposed do?
}
not sure if should use "new" or not.
i think 'new' work, avoided.
the 'new' allocate memory, makes harder detect when arduino has run out of ram memory.
you want rx , tx pin variables, have no choice , must use 'new'.
but why on earth want rx , tx pins variables? perhaps there different solution that.
the 'new' allocate memory, makes harder detect when arduino has run out of ram memory.
you want rx , tx pin variables, have no choice , must use 'new'.
but why on earth want rx , tx pins variables? perhaps there different solution that.
Arduino Forum > Using Arduino > Programming Questions > How to initialize SoftwareSerial in a class in another Library
arduino
Comments
Post a Comment