Saturday, March 5, 2011

Basic debugging hints



Okay, getting to know what your embedded device or program is doing is very much important when debugging. i went through ups and downs to get a good debugging etiquette. in windows or UNIX programming printf() helps really well,
what if there is a while loop and you need to check every point step by step. there another one such thing called the getche(). these functions come really handy when debugging embedded stuff and look into the problem step by step.
  • printf() can really come handy. but while debugging a huge set of inputs its quite hassle to get all the input shooting over the screen. rather than using printf("blah blah ... \n"); you could replace \n with a neat \r. it simple returns the character blinky thing to the start position. voila things look pretty neat now! Some of my screen shots here.

[top] pretty bad stuff.. this could ruin the computational speed of the program. I suffered quite with this. the simulated robot was all going slow.


[top] with the replacement of \n to \r made things look pretty well.
  • even the \a "alarm bell" helps a lot to observe minute things. it never worked in Visual Studio 2010. but works well for UNIX systems.
the getche() is also useful. the functions just sits until the user presses a key. if you could add put these here and there when you are debugging. the actual break point can be observed.


P.S: you will need to #include for getche()

No comments:

Post a Comment