For this project after using “pre-made” arduino compatible boards (ITEAD G-Board Pro) I started to design my own board based on 1284P and following “maniacbug” tutorial.
I need 3 serials : 1 for Xbee, 1 for GPRS (GPRSBEE) and 1 for debug.
I want to use the 2 harware serials for Xbee and Gprs and have a Software serial for Debug.
I manage to use sotware serial without problems.
The situation I now face is that inside the Library I use for GPRS connection i want to use software serial prints for debuging.
When doing so I get an error at the compilation with a message that says dans the software serial object is not declared, and if I try to declare it… it says that there is a multiple declaration…
No whining involved, English not being my mother tongue I guess there’s been a bit of misunderstanding.
I obviously don’t expect to be shown exactly how to do it, I’d just like to know in which direction to search.
The declaration is done with these lines in the main code :
Where is #include GPRS ( or whatever the real library name is )? Is it before SoftwareSerial or after? Are you aware that “Serial” - not SoftwareSerial - is physically and in core software “wired” / attached to COM monitor? If you are going to use “print” for debugging you have to use plain “Serial”.
I just experienced this problem with NeoGPS. The IDE does not add the include path for SoftwareSerial in “some” cases. For me, it happened when the include statement was in an included file (nested includes). I just moved the include to the outer-level include files.
Maybe you could add the “-I/libraries/SoftwareSerial” flag to the compiler switches. This is what’s really missing. Definitely an IDE problem.
Or, you might be able to declare a global Stream type variable, extern it in the problem CPP and use it for debug prints. In the INO, include SoftwareSerial.h, create the SoftwareSerial variable and assign it to the global Stream variable:
That’s if the Stream type gets correctly included… It’s in the normal include path instead of being down in a library subdirectory, so you may be able to include <Stream.h> without problems.
I thought it was better practice to have the most important devices on “Hardware” serial and use the Software serial for debugging purposes.
I now program with the AVR ISP through MISO/MOSI/SCK etc…
So you “new” version has no #include <GPRSBEE.h> at all? How can it work?
I don’t think sharing the hardware / Serial will work unless you make provisions in code to do that.
AVR ISP through MISO/MOSI/SCK - so apparently you cannot use “standard” COM port for debugging, right?
Ether way - seems complicated way to run things, but that is your choice.
My suggestion is to test your code using only one hardware device at a time , not all of them at once.
I would start with “print” first , than you have a tool to debug the rest of the code.
Vaclav:
So you “new” version has no #include <GPRSBEE.h> at all? How can it work?
Ether way - seems complicated way to run things, but that is your choice.
My suggestion is to test your code using only one hardware device at a time , not all of them at once.
I would start with “print” first , than you have a tool to debug the rest of the code.
I work on this for a long time and of course I built the code one piece at the time. The system works fine but the problem I have is that with my “new” serials allocation I can’t get debugging messages from within the GprsBee library.
Of course I have #include <GPRSBEE.h>.
I’m sorry if I’m not clear enough.
On the 1284P I have 2 hardware serial, I have now wired and coded for :
Serial number 1 : Xbee
Serial number 2 : GPRSBEE
I use an FTDI adapter linked to the Software Serial Pins to get my debug messages.
I have now “commented” the lines of Gprsbee.cpp that were used for debugging purposes.
Everything works fine (only I can’t get the debugging messages from the GPRSBEE.CPP code).
Anyways, I thank you for your answers I have now plenty of things to try.
I work on this for a long time and of course I built the code one piece at the time. The system works fine but the problem I have is that with my “new” serials allocation I can’t get debugging messages from within the GprsBee library.
Of course I have #include <GPRSBEE.h>.
I’m sorry if I’m not clear enough.
On the 1284P I have 2 hardware serial, I have now wired and coded for :
Serial number 1 : Xbee
Serial number 2 : GPRSBEE
I use an FTDI adapter linked to the Software Serial Pins to get my debug messages.
I have now “commented” the lines of Gprsbee.cpp that were used for debugging purposes.
Everything works fine (only I can’t get the debugging messages from the GPRSBEE.CPP code).
Anyways, I thank you for your answers I have now plenty of things to try.
I’ll get back ASAP with the final word.
Sorry for the poor formatting.
JB
No problem, your original post was pretty clear what the issue is, just your next to last post thru me off.
No worries about formatting - as they say - do not worry about small stuff.
Good luck.
Addendum
Of course I have #include <GPRSBEE.h>.
Sorry, my fault I missed the last line in you "new’ code.
For software serial debugging output I use a transmit-only version (attached below) so I don’t have to waste a pin on RX or screw around with code to disable it. The transmit-only software serial is just a cut down copy of the one from the core (1.6.x). Since it has a different name you just put it in your libraries folder like any other third party library.
#include <tSoftSerial.h>
tSoftSerial ss(DEBUG_TX_PIN); // optional second parameter for inverse logic
PaulS:
Header files need include guards, to prevent the problems you are seeing.
Wha-whaaat? SoftwareSerial.h does have guards, and my nested include had a guard, but not of that form. Why would the including file need that form? Investigating...
[Edit] Indeed, it works with that form. Weird! See later reply...
Header files do NOT value variables. They ONLY declare them.
Source files value variables.
Do you mean "define variables" vs. declare variables? Definitions can have an optional initial value, if that's what you're talking about.
jboyton:
For software serial debugging output I use a transmit-only version (attached below) so I don’t have to waste a pin on RX or screw around with code to disable it. The transmit-only software serial is just a cut down copy of the one from the core (1.6.x). Since it has a different name you just put it in your libraries folder like any other third party library.
#include <tSoftSerial.h>
tSoftSerial ss(DEBUG_TX_PIN); // optional second parameter for inverse logic
ss.begin(9600);
ss.print(F(“Hello world”));
I am not sure I follow your logic. .
How will replacing SoftwareSerial with tSoftwareSerial help?
The issue is accessing SofwareSerial.
Probably the old Nemesis of IDE messing up #includes.
I usually copy the “library” files ( from Github) to my own header file ( local copy sort of) which is always controllable than letting IDE including or ( as in this case) not including files.
jboyton:
For software serial debugging output I use a transmit-only version (attached below)
Cute! You can also pass an invalid pin number for the RX pin. When it tries to lookup the control and mask registers, it fails and skips the rest. I just pass pin 0xFF.
But SoftwareSerial also grabs all of the pin change interrupt vectors. That can be pretty annoying when you want to use one of them for another purpose at the same time. The transmit side doesn't use interrupts.
D:\Program Files\Arduino\1.0.5-ERW\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall
-fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L
-MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105
-ID:\Program Files\Arduino\1.0.5-ERW\hardware\arduino\cores\arduino
-ID:\Program Files\Arduino\1.0.5-ERW\hardware\arduino\variants\mega
C:\Users\SlashDev\AppData\Local\Temp\build2991499811398485666.tmp\includeTest.cpp
-o C:\Users\SlashDev\AppData\Local\Temp\build2991499811398485666.tmp\includeTest.cpp.o
In file included from includeTest.ino:1:
/A.h:4:28: warning: SoftwareSerial.h: No such file or directory
includeTest:3: error: 'SoftwareSerial' does not name a type
:’( The include works if it is in includeTest.ino.
jboyton:
SoftwareSerial also grabs all of the pin change interrupt vectors. That can be pretty annoying when you want to use one of them for another purpose
Yep. Cosa got this part right because it treats the PCInts as a Global resource.
Which is exactly what I suggested ( include as "new" tab / local file in x.ino file) to do to bypass Arduino IDE #include problem.
This long outstanding problem is nothing new and to my knowledge has not been seriously addressed by IDE "team" developers.
And I am not going to check released 1.6.6 to find out if it is still a problem. I do not like to be a tester, mainly because the developers do not appreciate feedback and I have a hack to fix it in my code.
So call me selfish.