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
Very Hot Topic (More than 25 Replies) Fixed: Breakpoint Not Hit - arduino code was using a different serial speed than the default (Read 31971 times)
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Fixed: Breakpoint Not Hit - arduino code was using a different serial speed than the default
Sep 23rd, 2012 at 9:36am
Print Post  
Hi VM:

This may be hard for you to find the problem as it is not a standard Arduino project, but I am trying to debug a project and the debugging does not appear to work at all. No issues with debugging s simple Arduino blinker project.

The project compiles fine, uploads to the board and works as it should. But it will not debug. I commented out some of the code in the loop() and added a counter as a breakpoint test, but the breakpoint is never hit.

There is no messages in the Micro Debug Messages
I have added {cnt_} to the "When the breakpoint is hit"

I don't think it is debugging at all. 

Code
Select All
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <ReefAngel.h>

int cnt_ = 0;

void setup()
{
  ReefAngel.Init(); // Initialize Controller
  ReefAngel.AddStandardMenu();
  ReefAngel.AddDateTimeMenu(); 
  ReefAngel.FeedingModePorts = Port5Bit | Port6Bit; // Turn off Ports 5 and 6 when Feeding Mode is activated
  ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit; // Turn off Ports 1, 5, 6, 7 and 8 when Water Change Mode is activated
  ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port7Bit; // Turn off Ports 3, 4 and 7 when overheat occurs
  ReefAngel.LightsOnPorts = Port3Bit | Port4Bit; // Turn on/off Ports 3 and 4 when Light On/Off menu option is selected
  ReefAngel.OverheatProbe = T1_PROBE; // Use Temperature probe 1 to check for overheat
  ReefAngel.Relay.On(Port8); // Always on
  ReefAngel.LCD.SetContrast(20);
}

void loop()
{
	cnt_ ++;
 // ReefAngel.LCD.DrawLargeText(COLOR_STEELBLUE,COLOR_WHITE,28,121,"Reef Angel"); // Display Reef Angel banner
//  ReefAngel.StandardATO(Port1); // Standard ATO
 // ReefAngel.MoonLights(Port2); // Moonlights or Refugium
 // ReefAngel.StandardLights(Port3,30); // Actinic Lights
  //ReefAngel.StandardLights(Port4,0); // Daylight Lights
  //ReefAngel.Wavemaker1(Port5); // Wavemaker 1
  //ReefAngel.Wavemaker2(Port6); // Wavemaker 2
  //ReefAngel.StandardHeater(Port7); // Heater
  //ReefAngel.PWM.StandardDaylight(); // Dimming for Daylight Channel
  //ReefAngel.PWM.StandardActinic(30); // Dimming for Actinic Channel
  ReefAngel.ShowInterface(); // Display everything on the LCD screen
}

 

« Last Edit: Oct 18th, 2012 at 9:44pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #1 - Sep 23rd, 2012 at 1:28pm
Print Post  
This might be a few things I can ask some questions that might get us closer to the problem

First Questions

1)

Are you debugging using the standard serial port used for upload? If so does the reefangel code use the serial port, if so does it use a different speed? If so what happens if you set the debug properties called "Remote Speed" and "Local Speed" to the reefangel speed?

2)

When you compile do you see two compiles? One for normal compile and one for debug compile?
  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #2 - Sep 23rd, 2012 at 9:35pm
Print Post  
Hi VM:

Yes, debugging using the same port used to upload. Reef Angel board is programmed with Arduino and the speed is 115200

Tried Remote speed and Local speed to the same speed.

I can compile the project using both Debug and Release settings.


Roberto Imai on this board is the author of the project. Will drop him a line to see if he shed some light. From his posts it appears he has it working

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #3 - Sep 23rd, 2012 at 10:03pm
Print Post  
If you are using the default upload port then you do not need any entry in LocalPort or RemotePort.

There is a bug that if these properties are the same as the upload port then you don't get messages from Setup() method

If this is the problem then another works around is to tick DTR on the Serial window.

If this still fails please email all the files from the Visual Micro folder below your sketch so that I can see what properties you have set. Email to info [at] visualmicro.com

and Yes I was going to suggest asking Roberto if this is something other than the above Smiley
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #4 - Sep 23rd, 2012 at 10:26pm
Print Post  
Oh I have just remebered that we found for ReefAngel that you should also switch off library optimisation until the next vm update

Tools>Options>Visual Micro>Compiler>Optimize Libraries". Set it to false.

Seems that bug you asked about is still applicable in certain cases  Cry
« Last Edit: Sep 23rd, 2012 at 10:27pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #5 - Sep 23rd, 2012 at 10:45pm
Print Post  
Tim@Visual Micro wrote on Sep 23rd, 2012 at 10:26pm:
Oh

Tools>Options>Visual Micro>Compiler>Optimize Libraries". Set it to false.

Seems that bug you asked about is still applicable in certain cases  Cry


Hi VM

Have tried that toggle as well, still no luck, although I don't see the exact path you refer. Do you mean Tools->Options->Visual Micro->Compiler Optimization->Library Modified = False
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #6 - Sep 23rd, 2012 at 10:49pm
Print Post  
Got you email. 

1)

First thing you should do is this because you are using the defaults so these settings are not needed. The LocalPort might be causing the problem but clear all these anyway. It's simpler Smiley

Clear the LocalPort
Clear the localSpeed
Clear the RemoteSpeed
Clear the RemoteTransport

Does that work?

2)

If not then this might be an issue with the C++ comment stripper which is only used for debug compile. However it has been tested a lot so this might be a waste of time...

Can you see what happens if you add a blank line between the cnt_ ++ and the comment below?

Thanks, yes you were right about the name of the option. It is "Library Modified"
« Last Edit: Sep 23rd, 2012 at 10:50pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #7 - Sep 23rd, 2012 at 11:27pm
Print Post  
I used baud rate 57600
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #8 - Sep 23rd, 2012 at 11:38pm
Print Post  
Thanks Roberto. 

That means the ReefAngel code is using the Serial port and has overridden the speed. This is called "Shared Debug Mode" where both vm and your arduino program use the same port.

Visual Micro ensures that it sets the arduino communication speed early in the code which then allows ReefAngel to override it. 

Your windows pc needs to know what speed to use and this is what the "Local Speed" debug property is for. 

Setting "Local Speed" to be 57600 should be what is required
  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #9 - Sep 24th, 2012 at 1:56am
Print Post  
Thanks Roberto and VM:  That is what it was, before Roberto's post I found by trial and error that the VM debugger was hanging up at Serial.Begin(57600) when called from ReefAngel.init(), now I know why. 

All is well now  Cheesy Smiley Cheesy

p.s. I am positive I tried 57600 as the local speed before with no luck, but it could have been because of some other settings I may have mucked up.

« Last Edit: Sep 24th, 2012 at 2:03am by Bryan »  
Back to top
 
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #10 - Sep 24th, 2012 at 9:30am
Print Post  
Hi VM:

Breakpoint set at ReefAngel.ShowInterface(); and it is works as it should and displays a message in the Trace Window.  Cheesy

Code
Select All
void loop()
{
 // ReefAngel.LCD.DrawLargeText(COLOR_STEELBLUE,COLOR_WHITE,28,121,"Reef Angel"); // Display Reef Angel banner
  ReefAngel.StandardATO(Port1); // Standard ATO
  ReefAngel.MoonLights(Port2); // Moonlights or Refugium
  ReefAngel.StandardLights(Port3,30); // Actinic Lights
  ReefAngel.StandardLights(Port4,0); // Daylight Lights
  ReefAngel.Wavemaker1(Port5); // Wavemaker 1
  ReefAngel.Wavemaker2(Port6); // Wavemaker 2
  ReefAngel.StandardHeater(Port7); // Heater
 // ReefAngel.PWM.StandardDaylight(); // Dimming for Daylight Channel
 // ReefAngel.PWM.StandardActinic(30); // Dimming for Actinic Channel
  ReefAngel.ShowInterface(); // Display everything on the LCD screen
} 



but if i go into the Reefangel.cpp file and set another breakpoint at Refresh(); it is not hit. Removing the breakpoint from ReefAngel.Interface(), does not help either.?
Compile Optimization Library modified is set to false Cry

Code
Select All
void ReefAngelClass::ShowInterface()
{
    Refresh();

    // are we displaying the menu or not??
    if ( showmenu )
    {........ 

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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #11 - Sep 24th, 2012 at 9:55am
Print Post  
Hi, I haven't tested with a cpp recently. I guess the breakpoints that work are always in a pde or ino?
  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #12 - Sep 24th, 2012 at 10:28am
Print Post  
Ouch you are right, in the case of the ReefAngel project I would guess 95% of the code is in custom libraries and .cpp files Cry
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #13 - Sep 24th, 2012 at 1:48pm
Print Post  
Ok thanks, it will be fixed in the next release due in a week or so.
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #14 - Sep 24th, 2012 at 9:11pm
Print Post  
I've done some testing and .cpp files that are a part of the sketch are included in the debugging.

I know that there isn't any debug support for libraries yet.

So that I am clear on this problem can you please confirm that the cpp file you were testing with is a library file?


Thanks
« Last Edit: Sep 24th, 2012 at 9:27pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #15 - Sep 24th, 2012 at 9:15pm
Print Post  
Hi VM;

I will send you a e-mail as it may be more helpful seeing a jpg of the project. Can't seem to find a way to upload attachments.

EDIT By Visual Micro: Yes we have an issue with adding attachments at the moment. I have added your photo below you can edit this post and remove it if you want

« Last Edit: Sep 24th, 2012 at 9:42pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #16 - Sep 24th, 2012 at 9:19pm
Print Post  
I can't even see the .cpp file Sad
How do I get to show them?
  
Back to top
 
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #17 - Sep 24th, 2012 at 9:21pm
Print Post  
Project-->Show all Arduino Files  Cheesy
  
Back to top
 
IP Logged
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #18 - Sep 24th, 2012 at 9:23pm
Print Post  
Yay Smiley
That's awesome!!
That is getting better and better Smiley
I thought we were only gonna be able to debug ino, but if we can debug cpp too, it will be really cool!! Smiley
Let me play around here now.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #19 - Sep 24th, 2012 at 9:32pm
Print Post  
Ahah! Yep when you guys talk .cpp you are talking library files. Sorry no debug in library files yet  Cry

In Arduino it is possible to have cpp in the sketch folder but doesn't sound like reefAngel uses this feature. (debug .cpp in sketch folder works).

I'll look at the library debug as soon as I can, it shouldn't too difficult considering that sketch cpp files already work.

In the meantime, if any library objects are global then you should be able to reference them in breakpoints {myReefAngel.someVar} from the main loop() but I haven't had a chance to look at the ReefAngel code to see if my comment is valid or not. 

Tip unrelated to debug

By the way don't forget to look at the right click menu when you click on any code variable or function. Got to definition is useful and "Find all references" is very useful. 

I use "Find all references" all the time, it can make extending programs much safer because you get to see everywhere something is being used.
« Last Edit: Sep 24th, 2012 at 9:36pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint