Custom Arduino Breakpoint Debug Output

by Visual Micro 14. April 2018 04:40

The "when hit" breakpoint command can be used to output custom arrays andother data from the Arduino during debug sessions.

For example we can add a command:- MyArray values are {GetMyArrayValues()}

This will output an array as semi-colon sep values in the debugger windows during debugging.

char GetMyArrayValues()
{
     for (int i = 0; i < inputBufferSize; i++)
     {
           Serial.print(inputBuffer[i]);
           Serial.print("; ");
     }

  return ''
} 

Share The Arduino Serial Port With The Debugger

by Visual Micro 5. May 2012 17:16

The example below shows a single Arduino Serial Port being used for both debug and static serial messages.

The example goes one step further by making use of the DEBUG symbol allowing the static messages to only be included in the program when debuging is enabled for the project.

Notes

In the example above the code in the Serial.begin() in the setup() function is not required because both the debugger and the project are using the same port. However, if the defined(DEBUG) condition is removed from the code then Serial.begin() would be required. Therefore it is safer to add Serial.begin() if your sketch code directly uses the Serial port.

The same would apply if the debug "Remote Port" on the project properties was set to a port other than "Serial". In this case you would certainly need to initialise the Serial port.