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
Normal Topic brakepoint/trace for array of char (Read 687 times)
Udo
Newbies
*
Offline


Posts: 1
Joined: Oct 23rd, 2015
brakepoint/trace for array of char
Oct 23rd, 2015 at 9:04pm
Print Post  
Hello,

before I installed Visual Micro I used Serial.print for debugging
Code (C++)
Select All
if (DEBUG) { for (int i= 0; i<rxPacket.length; i++) { Serial.print(rxPacket.data[i]);;Serial.print(" "); }}
 


Is it possible to do something similar with a breakpoint (trace)?

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: brakepoint/trace for array of char
Reply #1 - Oct 24th, 2015 at 1:21pm
Print Post  
Hi,

Visual Micro auto detects char arrays so for fixed len arrays you could simply use this {rxPacket.data} in the breakpoint  "when hit" action

Alternatives

If you need to provide the length then you can call your own methods. 

For example a "when hit" of {debugPacket} would expect a method called debugPacket() to be fined.

You can also use the visual micro project property "#define _DEBUG constant" to a value such as 1. This property is dependent on selected configuration so when you switch between "Release" and "Debugg/Local windows debugger" the constant will define or un-define and the code will show that state accordingly.

Alternatively use #if VM_DEBUG which visual micro defines during complication if a debug compile is being performed.

This example uses the project #define _DEBUG constant to print your array.

Code
Select All
#if _DEBUG

char debugPacket()
{
	for (int i = 0; i<rxPacketLen; i++)
	{
		Serial.print(rxPacketData[i]);
		Serial.print(" ");
	}
	return ' ';
}

#endif
 



note: the debug method needs to return at least one char which is why the example returns a single space. You could alternatively copy the array into a zero terminated string and return that from the method. This would avoid your having to use serial print but would consume more memory.

Of course you can use the above constants and leave your normal debug code in place. 

Lastly the project properties has a "Constants (configuration)" property where you can add "DEBUG" as a define. This will allow your existing debug code to work in tandem with the visual studio toolbar configuration switch "Release\Debug" etc. The visual micro debugger uses serial but your code can still print to serial as long as your own .print() commands are terminated with a line feed .println()

Hope this helps.
« Last Edit: Oct 24th, 2015 at 2:25pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint