Arduino: Better way to monitor variables than Serial.print()? - arduino

When I test my code, I add Serial.print messages temporarily, to see what my code does. This is quite tedious, because there's no such thing as printf() in the Arduino world. Plus sometimes I forget to remove the Serial.print()s and I must search them later in my code to remove them. And if I put the Serial.print()s into a loop, the output will scroll so fast that I can't really track how the values are changing. Then I need delay(), which are yet another piece of test code to remove later.
Is there any library or tool out there that makes this task easier?

If you've got Visual Studio you can use VisualMicro for real debugging including breakpoints and value monitoring:
http://www.visualmicro.com/page/Debugging-for-Arduino.aspx
It works with the community edition of Visual Studio (which is free):
http://www.visualstudio.com/products/visual-studio-community-vs
I've used VisualMicro a lot and it's a real time saver because you can really focus on debugging and not on adding log calls.

You can use the tried and true conditional compilation method such as with:
#ifdef DEBUGGING
Serial.print (something);
Serial.print (somethingElse);
delay (1000);
#endif
Then, compile yor test code with the DEBUGGING flag set, whilst leaving it off in the production code.
That way, you don't need to remove the debug code from your source, it's removed automatically by the compiler itself.

Related

dspic33fj128mc804 and eeprom 25LC256 by SPI

I am trying to write and read from the EEPROM (25LC256) with my dsPIC 33FJ128MC804, I tried to use the examples from the website, however they used the explorer16 with the dsPIC 33FJ256MC710, so I take the code and I made the changes to used it in my dsPIC but I started to use interruptions, right now I can send data, but I am not able to read from the memory, even if I follow the steps in the datasheet of the EEPROM and using the configuration of the SPI.
Could you help me please with this little problem please?
UPDATE: I just noticed that whenever I send the code for read the STATUS register I always get zero as answer, is it normal?
source code: https://www.dropbox.com/s/wdahlmhjrilcqw6/main.c?dl=0

IAR Embedded Workbench breakpoint failure

I've been using IAR embedded workbench for quite some time but there is still one thing I'm unable to wrap my head around. And that's the inconsistency of the breakpoint operation.
I have a quite big project which runs an RTOS (might this affect the problem?) and when I place a breakpoint there is no guarantee the debugger will stop at this breakpoint. Sometimes it does, sometimes it doesn't.
A workaround I found is manually stopping the processor and placing the breakpoint while the processor is paused. But even this has not a 100% success rate.
I'm generating debug information and I'm running in debug mode
Anyone had similar issues or anyone with some ideas?
Try to reduce number of breakpoints that you use (possibly just keep this one that causes problem), also you could use a “Log” breakpoint in order to print a message in the Debug Log window instead of stopping at that point (you may also want to try a different point in the same section of the code). If they don't help, I could say with a high degree of certainty that the debugger does not stop at the breakpoint because it simply does not hit it, and you do not enter that block of code. Consider that in an embedded project (especially when using an RTOS) some conditions are met only at the beginning or upon certain requests in certain conditions so you might want to figure out when the breakpoint is actually hit what conditions were met and what is the new state now.

Debugger jumping all over the place

I have added a reference to a DLL from another project (contained in the bin folder) and I have set Copy local to true. When I step through the code; the debugger jumps all over the place. I believe this is because the code is optimised. I have two questions:
Is this because the code is optimised
If (1) is true then why can I step through the code in the first place i.e. without Reflector.
My guess is the jumping is due to the PDB (symbols) being out of sync with the compiled DLL, thus the symbols tell VS to go to a line number that does not actually match up with what the code is actually doing; optimization may also play a part as well, because of in-lining functions.
Other things that influence the debugging experience are:
Just My Code setting
Methods explicitly marked with DebuggerNonUserCode attribute
Debugging optimized code may "jump around", as some functions become inlined. The most telling thing is that local variables usually get optimized away, giving a message to that effect when trying to read them.
If the jumping seems to make very little sense, though, then it's more likely you have the wrong PDB (which maps to line numbers) or source (which has the line numbers).

How can I find syntax errors in QML files?

I'm doing development for Blackberry 10 using Cascades, which includes QT and QML. I find that I sometimes make mistakes in my QML file, but they don't get picked up at compilation time. How can I check whether I've made a syntax error, or mis-named a function call, or other typical errors?
QML is a dynamic language that is evaluated at Runtime. There is no compilation step and due to the nature of javascript and the dynamic nature of the global context there is no way for it to tell if what you are writing is correct/incorrect until it is evaluated. QtCreator can help with some of the QML errors you will find, but there is unfortunately no good way to get syntax errors about your javascript until it is evaluated and it explodes.
Personally, I have found good usage of the debugger to be the key to making these sort of fixes easy.
tldr; Keep your javascript clean and to a minimum there is no compile time checking.
open terminal in IDE connect your device or emulator using blackberry-SSH after connecting enter slog2info it show syntax and all typical error JavaScript with description and line NO.
If there are any mistakes it will show those lines in RED marks. It is dynamically checks there is no need to worry about compile.
If you done wrong you will not see the DESIGN CONSOLE correctly.

GDB in Qt not refreshing values correctly

I am trying to use the debugger in a thread but the values of the watched variables dont get updated in them unless i remove the break point, make it run for a while then put break point back. They also get refreshed if a messageBox appears. Why is this?
There could be a number of reasons. My best guess is that you're putting break points in decompiled code, where as the compiled code may not occur in that order (as the compiler will move things around). You should consider setting your compiler to a lower level of optimization.

Resources