Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: [duplicate] Arduino Debug via Serial

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    19

    [duplicate] Arduino Debug via Serial

    We have a created a Debugging tool compatible with the Teensyduino platform, for all Teensy boards, running over the Serial port. This is part of the Visual Studio development extension Visual Micro.

    This allows you to:
    • Step by Step execution using breakpoints
    • Performance Monitoring for execution time between breakpoints
    • Conditional breakpoints (based on data or hit count)
    • Variable monitoring with automatic min/max tracking
    • Change variables at runtime
    • Automatic Visual Pin monitoring
    • Easy to use Charting (for any data)


    Code Example (all features use standard breakpoints):


    Example of Charting Running, with data tracking and Min/Max data visible:


    Example of Performance Output:


    Video of Teensy Install + Basic Serial Debugging in Action


    Video of @Plot Charts with Serial Debugger (works the same on Teensy)


    @Plot Charting Further Info

    Visual Micro VS Extension Website
    Last edited by visual_micro; 01-09-2020 at 03:43 PM.

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,878
    Technically, how does this work? There seems to be additional code on the Teensy - what exactly does it?
    Or, better, do you have a link where the sourcecode is available? I'd like to see it.

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    19
    It's a good question. We support both the injected serial (or software serial) debugger described in this post and also hardware debuggers.

    Both types of debuggers have advantages and disadvantages. Without hardware debug users either add their own serial debug statements throughout their code and/or they can use the Visual Micro break/trace points. The number of break/trace points is limited only by mcu memory and do not change the real code.

    Manually adding serial statements to track min/max values, monitor the millis() between code points, update variable values at runtime can be tedious, therefore Visual Micro adds the same (or similar) serial statements, based on the configuration of each breakpoint. Debug message strings remain on the pc which can often end up consuming less memory than large serial.print diagnostics messages in the code.

    Injecting code into the temporary build files prior to compile works quite well for Arduino projects because, as you will know, the the build always happens in a hidden temp folder. This is because the .ino code needs to be merged into .cpp. The use of the temp folder gives perfect opportunity to inject code when in debug mode.

    To ensure this solution works with all Arduino board types, Visual Micro injects standard Arduino code such as Serial.read(), Serial.print() based on the user configured debug settings. All of the code produced by Visual Micro can be seen in the temp build folder after compliation. tip: The temp build folder is displayed in the build output when "vMicro>Compiler>Show build folder" or "Compile>Verbose" is enabled.

    Breakpoint properties such as {@plot} simply add the value (or expression result) to a delimited serial.print() prefixed by a breakpoint id (such as #1) The pc knows what to do with the data in terms of displaying messages, watches, plots or pin maps.

    Hopefully the following links explain a little more?

    https://www.visualmicro.com/page/Use...Explained.html

    https://www.visualmicro.com/page/Use...Debugging.html

    https://www.visualmicro.com/page/User-Guide.aspx


    Main Restrictions: It is not currently possible to single step code lines, it is only possible to step from one point to another. Variables and/or expressions to be watched and/or updated during runtime must be added to the breakpoint before upload. Breakpoint positions must be set prior to upload. Not possible to use in ISR. Not possible to use inside code parts that have mission critical timings but that applies to most debuggers.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,878
    Ah.. got it. This means, for Teensy, the sourcecode has to be rebuilt if you change a breakpoint or a variable-watch.
    Some code I wrote takes a minute to compile.. of course not all But it gets interesting on large projects. So If I enable or disable a breakpoint I have to wait...
    Well, I have to wait now - without your debugger - too.

    (I wonder if something similar can be done by inserting a (more or less complex) macro.)

    Nevertheless - it seems easy to use.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Posts
    19
    Yes we are currently looking at giving some more flexibility to serial debug without need to recompile. It's looking quite exciting so will update this post with more info when/if it works.

    One gotcha of dynamic breakpoints will be optimization settings. By identifying variables and expressions before upload ( and injecting references) we won't have to worry about the compiler optimization settings in the same way that we do for hardware debug. For hardware debug, changing the optimization is easy via our menus but some platforms have been designed not to work well or become too large with less optimization. Therefore dynamic breakpoints might not be as great as they sound.

    BTW: Teensy used to be a very fast build as did all the old avr tools. If I recall pjrc have been waiting for the Arduino IDE to move to newer toolchains, which I think they have just done. Hopefully we will shortly see super fast Teensy builds again. A couple of minutes will likely be reduced to sub 20 secs (going on past experience). Fingers crossed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •