I am trying to write a library that interfaces with a serial device, and I want to use a NewSoftSerial (NSS) port to do so. I've written code in the past using NSS, so at that level (I think) I know what I am doing there. But I am trying to put together all the code relevant to the device into a class. I have a bunch of code, but I've stripped things down to a small .cpp, a small .h, and a small sketch that together show the problem I'm encountering (using Arduino 022 on Windows).
Here's the contents of the file TESTLIB.h:
#ifndef TESTLIB_H
#define TESTLIB_H
#include <WProgram.h>
#include "../NewSoftSerial/NewSoftSerial.h"
class TESTLIB : NewSoftSerial
{
public:
TESTLIB ( uint8_t receivePin, uint8_t transmitPin );
~TESTLIB ( void );
};
#endif
Here's the contents of TESTLIB.cpp:
#include <WProgram.h>
#include "TESTLIB.H"
TESTLIB::TESTLIB ( uint8_t receivePin, uint8_t transmitPin ) : NewSoftSerial ( receivePin, transmitPin )
{
begin ( 9600 );
}
TESTLIB::~TESTLIB ( void )
{
}
And here's the code in my sketch:
#include <TESTLIB.h>
TESTLIB tl ( 1, 2 );
void setup ( )
{
}
void loop ( )
{
}
The errors I get back from the compiler are as follows:
TESTLIB\TESTLIB.cpp.o: In function `~TESTLIB':
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:11: undefined reference to `NewSoftSerial::~NewSoftSerial()'
TESTLIB\TESTLIB.cpp.o: In function `TESTLIB':
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:4: undefined reference to `NewSoftSerial::NewSoftSerial(unsigned char, unsigned char, bool)'
C:\Users\TASTEWAR\Documents\Arduino\libraries\TESTLIB/TESTLIB.cpp:6: undefined reference to `NewSoftSerial::begin(long)'
TESTLIB\TESTLIB.cpp.o:(.rodata._ZTV7TESTLIB+0x4): undefined reference to `NewSoftSerial::write(unsigned char)'
Can anyone help me understand what I've done wrong? Also, with the NSS lib installed in my user libraries area, I have to use the funky relative path reference. Is there a better way? How should a user library build upon another user library?
Thank you!