Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 8 Replies) Debugger with software serial (Read 19432 times)
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Debugger with software serial
Aug 20th, 2014 at 9:49pm
Print Post  
I looked but didn't find info on if the debugger can be told to run a software serial port on pins x,y.

EDIT: I finally after 15 minutes found it. I kept using right-mouse-button click on the project's name and that gives me irrelevant properties. 
If I hit ALT-ENTER with project highlighted, I get the VM properties needed for the debugger. 

Please fix the debugger overview doc. And other places it talks about getting to the VM properties and VM debugger properties.
« Last Edit: Aug 20th, 2014 at 10:05pm by stevech »  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #1 - Aug 20th, 2014 at 10:16pm
Print Post  

What have I done wrong to setup software serial debug?
Here's the compiler output:

Code
Select All
Binary sketch size: 16,782 bytes (used 53% of a 31,744 byte maximum) (0.54 secs)
Compiling debug version of 'fileXdemo' for 'Anarduino miniWireless m328P 16MHz 57.6Kbaud. MW-optiboot 1KB'
Build folder: file:///C:/Users/steve/AppData/Local/VMicro/Arduino/Builds/fileXdemo/Anarduino
fileXdemo.ino:In function 'void setup()'
fileXdemo.ino:102: error: 'MicroDebug' was not declared in this scope
fileXdemo.ino:102: error: 'VM_DBG_Transport' was not declared in this scope
fileXdemo.ino:In function 'void messaging()'
fileXdemo.ino:183: error: 'MicroDebug' was not declared in this scope
fileXdemo.ino:222: error: 'MicroDebug' was not declared in this scope
Error compiling
.
.......................................................
***** Visual Micro Debugger Compiler Error Help ******* 



attached is the properties. One obvious confusion on my part: What goes in "Remote Port" for software serial?
« Last Edit: Aug 20th, 2014 at 10:16pm by stevech »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #2 - Aug 20th, 2014 at 10:17pm
Print Post  
Hi,

Glad you found it. Please use the "Documentation" and Search on the web site. If you search for software serial this link is the 2nd one in the results.

You can also find the link in the "Debugger" section of the "Documentation"

http://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-With-Different-Por...

Hope that helps

Thanks
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #3 - Aug 20th, 2014 at 10:22pm
Print Post  
Hi,

Our posts crossed.

You have it setup correctly. remote port should be empty unless using a custom object which you are not.

You should try adding the SoftwareSerial library to a test project to see if it is supported for the board you are using. 

This is what Visual Micro does when you select the SoftwareSerial option, in the background it adds the Software Serial library to the compile.

If Software serial compiles okay then please email the sketchname.cpp from your build folder to info[at]visualmicro.com.

Thanks
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #4 - Aug 20th, 2014 at 10:38pm
Print Post  
Yes, I've used software serial in my own program and it works OK.  The terminology is new: "Local port" means a PC's COM port (FTDI device) which connects to the software serial pin #, right? That's what I now have set in properties. But the build errors still happen.
The board has an AVR mega328P, 16MHz. The built-in serial to USB is used by the app and that's why the debugger needs to use software serial.

I don't know how to correct the errors shown above.

Thanks for the help.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #5 - Aug 20th, 2014 at 10:42pm
Print Post  
Hi,

Yes LocalPort means the USB/COM/FTDI on the PC. The other end of the cable will connect to the Arduino. 

But this will not cause this problem.

Please zip your entire sketch folder after attempting a debug upload. Include the /visual micro sub folder in the zip and email to info[at]visualmicro.com

I'll take a look at it tomorrow.

Thanks
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #6 - Aug 20th, 2014 at 10:45pm
Print Post  
Hi,

I hope you don't mind I have deleted your message about opening the properties.

That was best included in a new thread because the subject was different and would be confusing to answer in this software serial post.

I couldn't move it because there was already other posts after it.

If you open a new thread I will explain.

Thanks
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #7 - Aug 20th, 2014 at 11:04pm
Print Post  
thank you. I'll send what you requested.
  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #8 - Aug 21st, 2014 at 6:50am
Print Post  
Here's a clue for you, instead of me sending you a zillion lines of code to pore over...

If I add these lines to my program, the build errors go away. Seems like the debugger is supposed to insert them if I enable the debugger in the project settings.

Code (C++)
Select All
#include <SoftwareSerial.h>
SoftwareSerial sserial(7,8); // class instance 



sserial instance is my name, used when I enable software serial for my own debug messages. I have it disabled so pins 7,8 can be used by the debugger's software serial instance whatever name and place that is.

I'm getting output from the debugger displayed in my FTDI COM34 and I see in the IDE output window Breakpoint hit. Progress. Not yet able to get keyboard input from COM34 to go in (using serial terminal monitor within AS/VM). I did a loopback test and COM34 pins work. So I will pursue why no input as a hardware issue. 
« Last Edit: Aug 21st, 2014 at 6:52am by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #9 - Aug 21st, 2014 at 12:27pm
Print Post  
Thanks,

Yes that is exactly what Visual Micro adds to the sketch during compile. It would be useful to see the sketch.cpp from the build folder when you have a moment free.

Yes both tx and rx work in my tests and the serial monitor does not know the difference between COM ports so should  work as normal.

I am intrigued to understand why the software serial is not being initialized correctly. I can only guess that Visual Micro is incorrectly inserting the commands in a place that is surrounded by a conditional #define that is not being hit?? The cpp from the build folder should show the issue clearly.

Thanks for the great info.
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #10 - Aug 21st, 2014 at 4:35pm
Print Post  
I'll work on sending you something but the project is many and a library that is downloaded to the Arduino library folder. 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #11 - Aug 21st, 2014 at 4:51pm
Print Post  
Hi,

I don't need anything that I can build at this point. Just to look at what the debugger has included in the sketchname.cpp in the build folder. It's just one file and always present in the build folder.

Sorry that wasn't clear. Do you know how to find the build folder?

Thanks
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #12 - Aug 21st, 2014 at 10:16pm
Print Post  
The problem is that the debugger build is inserting its own software serial code in the wrong place. It's putting it inside my #ifdef where that #ifdef block is false. In that block is my (disabled) code for declaring my own software serial. Since I'm going to use the same pins for the debugger software serial, I had #ifdef'd to disable that block. But the debugger code for some reason, skipped way down to my code inside the block and inserted. It's like the debugger is scanning for "SoftwareSerial" and/or "<SoftwareSerial.h>" and inserting at that point, even though that's within the #ifdef block.

So I changed my #ifdef block to all // comments. Then the insert of this worked OK...
Code (C++)
Select All
#include "arduino.h"
#include <SoftwareSerial.h>
SoftwareSerial VM_DBG_Transport = SoftwareSerial(7,8);

#include <VM_DBG.h> 



Odd though, the insert began at line 62 of the cpp in the build folder. Lines 1-62 are #includes, some of my #defines and so on. So the choice of where to insert seems screwy, and the debug build elected to insert in the middle of an #ifdef block. Since (re)inserts #include arduino.h I'd think it'd be OK to insert at the top of the file. 
(By the way, shouldn't that be <arduino.h> rather than "arduino.h" ? )

  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #13 - Aug 21st, 2014 at 10:29pm
Print Post  
Additional... Here's the code from the build directory, cpp file generated by the Arduino gods and with the debugger's insertion lines. Note my #ifdef DBSERIAL block; the next line down is the debugger's inserted code, 4 lines.

Code (C++)
Select All
#include <Arduino.h>
#include <RadioHead.h>
#include <avr/eeprom.h>
#include <SPI.h>
#include <RH_RF69.h>
#include <RH_Serial.h>
#include "fileX.h"

#include "metaMessages.h"

#ifdef DBSERIAL
#include "arduino.h"
#include <SoftwareSerial.h>
SoftwareSerial VM_DBG_Transport = SoftwareSerial(7,8);

#include <VM_DBG.h>

//
//
void messaging();
void LEDset(bool state);
void LEDtoggle();
void LEDblink(uint8_t count);
char printbuf[80];
#if DBSERIAL == sserial
#include <SoftwareSerial.h>
SoftwareSerial sserial(7,8);
#endif
#endif 

« Last Edit: Aug 21st, 2014 at 10:34pm by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #14 - Aug 22nd, 2014 at 4:18pm
Print Post  
Hi,

Yes this is always a problem. Vm is supposed to do the same as the Arduino IDE which find the first line of code before any variables are declared and inserts the Arduino.h header.

Because you have inserted the Arduino.h manually you have never hit this issue which becomes more apparent when other code such as softwareSerial needs to be included.

I will try to improve the regex expression that attempts to determine the correct insertion point but generally it is best to put the first #ifdef after some variable or expressions have been declared.

Thanks for all the info

  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #15 - Aug 22nd, 2014 at 4:53pm
Print Post  
Couldn't you just insert at line 0?

My Arduino.h is in the first couple of lines of code in the file.  I think VM inserted the other Arduino.h.

If you have a suggestion on how to code, and with #ifdef's, to avoid this, please advise.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #16 - Aug 22nd, 2014 at 5:48pm
Print Post  
Fair question but some Arduino projects make use of the "feature". It provides the ability to redefine some core elements prior to the Arduino.h loading.

Don't shoot me, I just do what Arduino does to prevent lots of complaints (most of the time)  Smiley
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #17 - Aug 22nd, 2014 at 8:12pm
Print Post  
what should I do to fiddle with my code and ifdefs to de-conflict?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Debugger with software serial
Reply #18 - Aug 22nd, 2014 at 8:41pm
Print Post  
Actually Visual Micro creates the file but it just follows the rules defined by Arduino with the addition of debug code when activated.

In your example the following is automatically inserted before the first line of code:-

Code
Select All
#include "arduino.h"
#include <SoftwareSerial.h>
SoftwareSerial VM_DBG_Transport = SoftwareSerial(7,8);

#include <VM_DBG.h>

//
//
void messaging();
void LEDset(bool state);
void LEDtoggle();
void LEDblink(uint8_t count); 



Unfortunately your first code line is inside the #ifdef so the code gets inserted in that exact location:-

Code
Select All
char printbuf[80]; 



So if you can add just one global variable prior to any #ifdefs things will work well.

I hope this makes sense?

Thanks



« Last Edit: Aug 22nd, 2014 at 9:14pm by Tim@Visual Micro »  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: Debugger with software serial
Reply #19 - Aug 22nd, 2014 at 8:47pm
Print Post  
OK will do. thanks.
like
char nada;
that's all.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint