SoftwareSerial reference instance from sketch in a library?

Hello,

I created a SoftwareSerial instance in my main sketch, mymain.ino. I want to reference that instance in an included library. I want to be able to debug the program from a softwareserial port in the main sketch and the library. So, here is what I have, I get an error when I try to DebugPort.print in the .cpp file.

//mymain.ino
#include <SoftwareSerial.h>
#include <MyLibrary.h>
SoftwareSerial DebugPort(2,3);
...
DebugPort.print("something");
...

//mylibrary.cpp
...
DebugPort.print("something"); -->get an error from compiler DebugPort was not declared in this scope
...

Thanks,

-ren

Try:

//mylibrary.cpp
...
#include <SoftwareSerial.h>

extern SoftwareSerial DebugPort;

...
DebugPort.print("something");  -->get an error from compiler DebugPort was not declared in this scope
...

Not tested though.

Nick,

Thanks, works well.

-ren