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]  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 32082 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: 12076
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: 12076
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: 12076
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: 12076
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: 12076
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: 12076
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: 12076
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: 12076
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: 12076
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
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #20 - Sep 24th, 2012 at 9:43pm
Print Post  
Yes, I was talking about libraries .cpp files.
The reference to global variables does work.
I can set a breakpoint on the ino code and reference a global variable from ReefAngel Class and works just fine Smiley
It didn't find my breakpoints inside any libraries though Sad
I even tried one of the core Arduino libraries and did not work either.
I was trying to add a breakpoint on HardwareSerial.being() function inside HardwareSerial.cpp just to see if it was because of my custom libraries or not, but it seems none are working now. I'll wait for more good news Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #21 - Sep 24th, 2012 at 9:57pm
Print Post  
Bryan, I received your email thanks and have added the image to your post.

You are certainly talking about debug for .cpp in libraries. That is a neat system you guys are working with!

I have a few tips:

1) I notice you are trying to set a breakpoint on the call to initialise the wire i2c system. I know it is just an example for the picture because it isn't a useful breakpoint but have this information just in case. 

If you want to see what i2c device ids are available when the arduino boots up then there is visual micro debug option called "Startup I2C Report". Enabling this option will give you a list of connected i2c device ids in the debug output windows. 

If you are connecting and disconnecting i2c devices when the arduino is running then let me know because there is a {special variable} name you can add to breakpoints that will give an i2c report at any time during a debug session.

2)

All the classes in the reefAngel:Init should be accessible to breakpoints in the main .ino file.

I guess you can use something like this as a debug message from the .ino:-

Code
Select All
Joystick x pos ={Joystick.x} 



Does the main .ino file call something like ReefAngel.Init()? If so then you can add breakpoint conditions to that line (or anywhere after it) such as :-

Code
Select All
The value of joystick x pos ={Joystick.x} and other stuff = {LCD.blah},{TempSensor.blahblah} 



The breakpoint message about would result in 3 watched expressions
  • Joystick.x
  • LCD.blah
  • TempSensor.blahblah


And one debugger message

Quote:
The value of joystick x pos =456 and other stuff = 123,456


Or simply debug expressions without a message
Code
Select All
{Joystick.x}{LCD.blah}{TempSensor.blahblah} 



Hope this helps for now
« Last Edit: Sep 24th, 2012 at 10:26pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #22 - Sep 24th, 2012 at 10:01pm
Print Post  
Robero. 

Ignore my previous message I posted it before I saw your answer.

Yes we could add debug to some of the arduino core but probably should not. many things can't work until arduino is loaded such as hardwareSerial for debug Smiley

The location you picked for a test is certainly one location that will never work for debug. The debug can't be used before HardwareSerial is loaded  Cry
  
Back to top
WWW  
IP Logged
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #23 - Sep 24th, 2012 at 10:11pm
Print Post  
Yes, I was able to get that part working by referencing global variables, but will there be a way to debug private variables or temporary variables?
For example, I have a for (int a;a<10;a++) inside one of my libraries and I wanted to debug inside this loop. I know I can't do it now, but is it a possibility in the future?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #24 - Sep 25th, 2012 at 2:36am
Print Post  
Yes certainly and it makes sense. I just wasn't sure of the audience when I did it originally so excluded the libraries but it seems okay to do this. 

I wouldn't want your fish to die if something does wrong so I try to be careful as possible.   

New users don't know what they are doing, some programs have timing critical functions and the debug certainly can slow things down if you put a break-point in a very fast loop. But I have to assume that people take responsibility for their own actions  Undecided

  
Back to top
WWW  
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #25 - Sep 25th, 2012 at 6:30am
Print Post  
Roberto Imai wrote on Sep 24th, 2012 at 10:11pm:

For example, I have a for (int a;a<10;a++) inside one of my libraries and I wanted to debug inside this loop. I know I can't do it now, but is it a possibility in the future?


Would be the cat's meow if it could, as it's usually these type of scenarios that little bugs creep in and can be the hardest to debug. Smiley
« Last Edit: Sep 25th, 2012 at 6:50am by Bryan »  
Back to top
 
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #26 - Sep 25th, 2012 at 6:37am
Print Post  
Tim@Visual Micro wrote on Sep 24th, 2012 at 9:57pm:


1) I notice you are trying to set a breakpoint on the call to initialise the wire i2c system. I know it is just an example for the picture because it isn't a useful breakpoint but have this information just in case.


Yes, i was just trying to set a breakpoint in a *.cpp class no particular interest in debugging at that particular breakpoint. Tried your suggestions of quoting global variables and it works, will be very helpful, Cheesy Cheesy

I too have found the "Find References" very useful, Roberto's project is very complex and with a click of the mouse I can find where the relevant code is. Smiley
  
Back to top
 
IP Logged
 
Bryan
Junior Member
**
Offline


Posts: 58
Location: Canada
Joined: Sep 8th, 2012
Re: Breakpoint Not Hit
Reply #27 - Sep 25th, 2012 at 6:39am
Print Post  
Tim@Visual Micro wrote on Sep 24th, 2012 at 9:57pm:
That is a neat system you guys are working with!


Can't take any credit for it, it is all Roberto's work.  Smiley 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #28 - Sep 25th, 2012 at 5:01pm
Print Post  
Roberto. Wow your ReefAngel project looks like the neatest and most well structured Arduino project on the planet!
« Last Edit: Sep 25th, 2012 at 5:01pm 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 #29 - Sep 25th, 2012 at 6:06pm
Print Post  
Smiley thanks
Fun too!!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #30 - Sep 25th, 2012 at 7:14pm
Print Post  
Yes it makes me want to get some fish. I have some Koi  but they are really boring.

I would end up killing them so best avoided.

I've been thinking about the debug in libraries. My concerns are probably better understood when considering the copter, plane and drone projects. I have been worried about new users thinking they can place breakpoints anywhere. 

However, having provided the capability to debug .ino and .cpp sketch files I don't think my concerns make sense. I think I am just a worrier  Cheesy
  
Back to top
WWW  
IP Logged
 
Roberto Imai
Junior Member
**
Offline


Posts: 22
Joined: Sep 9th, 2012
Re: Breakpoint Not Hit
Reply #31 - Sep 25th, 2012 at 7:50pm
Print Post  
You could make it as a setting in your general options.
Enable disable debug of libraries.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Breakpoint Not Hit
Reply #32 - Sep 25th, 2012 at 8:43pm
Print Post  
Yes that's a good idea. I think we also need a better disclaimer when the debugging is activated for the first time. Thanks
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: [1] 
Send TopicPrint